Description of WinMain in MSDN

xiaoxiao2021-03-06  40

WinMain function

The Winmain Function is Called by The System As The Initial Entry Point for A Windows-based Application.

Syntax

Int Winmain (Hinstance Hinstance,

Hinstance Hprevinstance,

LPSTR LPCMDLINE,

Int ncmdshow

);

Parameters

Hinstance

Handle to The Current Instance of the Application.

HPREVINSTANCE

[In] Handle to the previous instance of the application This parameter is always NULL If you need to detect whether another instance already exists, create a uniquely named mutex using the tabindex = "0" keywords = "_ win32_CreateMutex" xmlns:.. Mshelp = "http://msdn.microsoft.com/mshelp"createmutex function.

CreateMutex will succeed even if the mutex already exists, but the function will return ERROR_ALREADY_EXISTS. This indicates that another instance of your application exists, because it created the mutex first.

LPCMDLINE

[In] Pointer to a null-terminated string specifying the command line for the application, excluding the program name To retrieve the entire command line, use the tabindex = "0" keywords = "_ win32_GetCommandLine" xmlns:. Mshelp = "http: / /msdn.microsoft.com/mshelp" %getCommandline function.

NCMDSHOW

.................. ..

SW_HIDE

HIDES The Window and Activates Another Window.

SW_MAXIMIZE

Maximizes the specified window.

SW_MINIMIZE

MINIMIZES The NEXT TOP-Level Window In the z Order.

SW_RESTORE

Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.SW_SHOW

Activates the window and displays it in its current size and position.

SW_SHOWMAXIMIZED

Activates the window and displays it as a maximized window.

SW_SHOWMINIMIZED

Activates the window and displays it as a minimized window.

SW_SHOWMINNOACTIVE

Displays the window as a minimized window. This value is similar to sw_showminimized, Except the window is not activated.

SW_SHOWNA

Displays the window in its current size and position. This value is similar to sw_show, except the window is not activated.

SW_SHOWNOACTIVATE

Displays a window in its most the value is similar to sw_shownormal, except the window is not activid.

SW_SHOWNORMAL

Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.

Return Value

If the function succeeds, terminating when it receives a tabindex = "0" keywords = "_ win32_WM_QUIT_cpp" xmlns: mshelp = "http://msdn.microsoft.com/mshelp" /> WM_QUIT message, it should return the exit value contained in ....................

Remarks

Your WinMain should initialize the application, display its main window, and enter a message retrieval-and-dispatch loop that is the top-level control structure for the remainder of the application's execution. Terminate the message loop when it receives a WM_QUIT message. At that point, your WinMain should exit the application, returning the value passed in the WM_QUIT message's wParam parameter If WM_QUIT was received as a result of calling tabindex = "0" keywords = "_ win32_PostQuitMessage_cpp" xmlns:. mshelp = "http: // msdn .microsoft.com / mshelp "/> PostQuitMessage, the value of wParam is the value of the PostQuitMessage function's nExitCode parameter For more information, see tabindex =." 0 "keywords =" _ win32_Using_Messages_and_Message_Queues_cpp "xmlns: mshelp =" http: // msdn .microsoft.com / mshelp "/> Creating a Message Loop.ANSI applications can use the lpCmdLine parameter of the WinMain function to access the command-line string, excluding the program name. The reason that WinMain can not return Unic Ode Strings Is That Lpcmdline Uses The LPSTR DATA TYPE, NOT The LPTSTR DATA TYPE. The getcommandline function can be used to access Unicode Strings in the Command Line, Because.

Function Information

HeaderDeclared in WinBase.h, Include Windows.himport LibraryNoneMinimum Operating SystemsWindows 95, Windows NT 3.1

See Also

tabindex = "0" keywords = "_ win32_Windows_cpp" xmlns: mshelp = "http://msdn.microsoft.com/mshelp" /> Windows Overview, tabindex = "0" keywords = "_ win32_CreateMutex" xmlns: mshelp = "http: / /msdn.microsoft.com/mshelp"/>CreateMutex, tabindex = "0" keywords = "_ win32_DispatchMessage_cpp" xmlns: mshelp = "http://msdn.microsoft.com/mshelp" /> DispatchMessage, tabindex = "0" keywords = "_ win32_GetCommandLine" xmlns: mshelp = "http://msdn.microsoft.com/mshelp" /> GetCommandLine, tabindex = "0" keywords = "_ win32_GetMessage_cpp" xmlns: mshelp = "http://msdn.microsoft.com/ mshelp "/> GetMessage, tabindex =" 0 "keywords =" _ win32_PostQuitMessage_cpp "xmlns: mshelp =" http://msdn.microsoft.com/mshelp "/> PostQuitMessage, tabindex =" 0 "keywords =" _ win32_TranslateMessage_cpp "xmlns: mshelp = "http://msdn.microsoft.com/mshelp" /> translateMsSageTabindex = "0" keywords = "msdn_copyright" xmlns: mshelp = "http://msdn.microsoft.com/mshelp" /> © 2003 Microsoft Corporation. All rights reserved.

转载请注明原文地址:https://www.9cbs.com/read-52126.html

New Post(0)