共用方式為


SetThreadStackGuarantee (KernelBase) function

[This function is exported from KernelBase.dll in Windows 7 and Windows Server 2008 R2. This may change in subsequent versions. Instead of calling this function directly in KernelBase.dll, call the function through Kernel32.dll. See SetThreadStackGuarantee.]

Sets the minimum size of the stack associated with the calling thread or fiber that will be available during any stack overflow exceptions. This is useful for handling stack overflow exceptions; the application can safely use the specified number of bytes during exception handling.

Syntax

BOOL WINAPI SetThreadStackGuarantee(
  _Inout_ PULONG StackSizeInBytes
);

Parameters

  • StackSizeInBytes [in, out]
    The size of the stack, in bytes. On return, this value is set to the size of the previous stack, in bytes.

    If this parameter is 0 (zero), the function succeeds and the parameter contains the size of the current stack.

    If the specified size is less than the current size, the function succeeds but ignores this request. Therefore, you cannot use this function to reduce the size of the stack.

    This value cannot be larger than the reserved stack size.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.

Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]

Header

Winbase.h (include Windows.h)

DLL

KernelBase.dll