User32 Functions

< Previous Next >

PostQuitMessage Function

The PostQuitMessage function posts a quit message to a message queue and terminates message processing for the current thread.

Syntax

VOID PostQuitMessage(
  <span style="color: #c7254e;">int</span> ExitCode
);

Parameters

ExitCode

The application's exit code. This value is used as the parameter for the WM_QUIT message.

Return value

This function does not return a value.

Remarks

This function is typically called by an application's message loop when it processes the WM_DESTROY message for a window. The WM_QUIT message terminates the message loop, allowing the application to exit.

When PostQuitMessage is called, the system posts a WM_QUIT message to the calling thread's message queue. The ExitCode parameter is used as the wParam parameter of the WM_QUIT message.

The message loop typically retrieves the WM_QUIT message using the GetMessage function. If GetMessage returns -1 (indicating an error) or 0 (indicating that PostQuitMessage has been called), the application should terminate.

Requirements

Header: Winuser.h (include Windows.h)

Library: User32.lib

DLL: User32.dll

See also