术语 | winmain |
释义 | WinMain 语法: int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ); WinMain函数 WinMain函数是传统的用户名,提供了一个Microsoft Windows入口点的应用程序。 参数 hInstance [in]句柄应用程序的当前实例。 hPrevInstance [in]句柄上的应用实例。这个参数总是空。如果您需要另一个实例检测是否已经存在,创建一个唯一命名的互斥使用CreateMutex函数。 CreateMutex将接替互斥即使已经存在,但该函数将返回ERROR_ALREADY_EXISTS。这表明您的应用程序的另一个实例存在,因为它创造了互斥第一。但是,恶意用户可以创建此互斥量在此之前,防止启动您的应用程序。为了防止这种情况下,创建一个随机命名的互斥和存储名称,以便它只能由授权用户获得的。此外,还可以用于此目的的文件。为了限制您的应用程序每个用户实例,创建一个用户配置文件目录锁定的文件。 lpCmdLine [in]指向一个空结束的字符串指定应用程序的命令行,不包括程序的名称。要检索整个命令行,使用GetCommandLine函数。 nCmdShow [in]指定窗口如何才能显现。此参数可以是下列值之一。 SW_HIDE 隐藏窗口并激活另一个窗口。 SW_MAXIMIZE 最大化指定的窗口。 SW_MINIMIZE 最小化指定的窗口和激活下一个顶部在Z顺序窗口。 SW_RESTORE 激活并显示窗口。如果窗口是最小化或最大化,该系统将其还原到原来的大小和位置。应用程序应指定此标志时,还原最小化窗口。 SW_SHOW 激活窗口,并显示在当前的大小和位置。 SW_SHOWMAXIMIZED 激活窗口,并显示为最大化窗口。 SW_SHOWMINIMIZED 激活窗口,并显示为最小化窗口。 SW_SHOWMINNOACTIVE 窗口中显示最小化窗口。此值类似于SW_SHOWMINIMIZED除了窗口,未激活。 SW_SHOWNA 在当前的大小和位置显示窗口。此值类似于SW_SHOW除了窗口,未激活。 SW_SHOWNOACTIVATE 显示在其最近的大小和位置窗口。此值类似于SW_SHOWNORMAL除了窗口,不激活。 SW_SHOWNORMAL 激活并显示一个窗口。如果窗口是最小化或最大化,该系统将其还原到原来的大小和位置。应用程序应指定此标志时,显示第一次窗口。 返回值 如果函数成功,终止时,它收到一个WM_QUIT消息,它应该返回的出口值在该消息的wParam参数中。如果函数在进入消息循环终止,它应该返回零。 备注 WinMain的名称所使用的公约很多编程框架。根据不同的方案框架,到WinMain函数调用可之前和特定于该框架内的其他活动所遵循。 您的WinMain应该初始化应用程序,显示它的主窗口,并输入信息检索导调循环,是最高层次的应用程序的执行剩余的控制结构。消息循环终止时,收到一个WM_QUIT消息。在这一点上,您的WinMain应该退出该应用程序,返回在WM_QUIT消息的wParam参数传递的值。如果WM_QUIT是作为调用PostQuitMessage而收到的wParam值是PostQuitMessage函数的nExitCode参数值。有关更多信息,请参阅创建消息循环。 应用程序可以使用的ANSI的WinMain函数lpCmdLine参数来访问命令行字符串,不包括程序的名称。请注意,lpCmdLine使用LPSTR数据类型,而不是LPTSTR数据类型。这意味着WinMain不能由Unicode程序的手段。该GetCommandLineW函数可用于获取一个Unicode字符串命令行。一些编程框架提供了另一种可能的切入点,提供了Unicode的命令行。例如,微软的Visual Studio的C + +编译器使用的Unicode入口点的名称wWinMain。 功能信息 在Winbase.h HeaderDeclared,头文件:winuser.h import libraryNone 最低操作系统Windows 95,Windows NT 3.1 参见 视窗概述,CreateMutex,DispatchMessage,GetCommandLine,GetMessage,PostQuitMessage,TranslateMessage ==英文原文==WinMain Function The WinMain function is the conventional name for the user-provided entry point for a Microsoft Windows-based application. Syntax int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ); Parameters hInstance [in] 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 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. However, a malicious user can create this mutex before you do and prevent your application from starting. To prevent this situation, create a randomly named mutex and store the name so that it can only be obtained by an authorized user. Alternatively, you can use a file for this purpose. To limit your application to one instance per user, create a locked file in the user's profile directory. 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 GetCommandLine function. nCmdShow [in] Specifies how the window is to be shown. This parameter can be one of the following values. SW_HIDE Hides the window and activates another window. SW_MAXIMIZE Maximizes the specified window. SW_MINIMIZE Minimizes the specified window and activates 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 recent size and position. This value is similar to SW_SHOWNORMAL, except the window is not actived. 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 WM_QUIT message, it should return the exit value contained in that message's wParam parameter. If the function terminates before entering the message loop, it should return zero. Remarks The name WinMain is used by convention by many programming frameworks. Depending on the programming framework, the call to the WinMain function can be preceded and followed by additional activities specific to that framework. 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 PostQuitMessage , the value of wParam is the value of the PostQuitMessage function's nExitCode parameter. For more information, see 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. Note that lpCmdLine uses the LPSTR data type instead of the LPTSTR data type. This means that WinMain cannot be used by Unicode programs. The GetCommandLineW function can be used to obtain the command line as a Unicode string. Some programming frameworks might provide an alternative entry point that provides a Unicode command line. For example, the Microsoft Visual Studio C++ complier uses the name wWinMain for the Unicode entry point. Function Information HeaderDeclared in Winbase.h, include Windows.h Import libraryNone Minimum operating systemsWindows 95, Windows NT 3.1 See Also Windows Overview , CreateMutex , DispatchMessage , GetCommandLine , GetMessage , PostQuitMessage , TranslateMessage ==原始网址==http://msdn.microsoft.com/en-us/library/ms633559(VS.85).aspx\n |
随便看 |
|
windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。