winmain是怎么回事?

difkg1 2014-05-28 11:08:19
winmain(hinstance,hprevinstance,lpcmdline,ncmdshow)的四个参数,怎么赋值,winmain怎么调用?ncmdshow是什么?
...全文
86 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2014-05-29
  • 打赏
  • 举报
回复
查MSDN是Windows程序员必须掌握的技能之一。 WinMain The WinMain function is called by the system as the initial entry point for a Win32-based application. int WINAPI WinMain( HINSTANCE hInstance, // handle to current instance HINSTANCE hPrevInstance, // handle to previous instance LPSTR lpCmdLine, // pointer to command line int nCmdShow // show state of window ); Parameters hInstance Handle to the current instance of the application. hPrevInstance Handle to the previous instance of the application. For a Win32-based application, this parameter is always NULL. If you need to detect whether another instance already exists, create a uniquely named mutex using theCreateMutex function. CreateMutex will succeed even if the mutex already exists, but theGetLastError function will return ERROR_ALREADY_EXISTS. This indicates that another instance of your application exists, because it created the mutex first. lpCmdLine Pointer to a null-terminated string specifying the command line for the application, excluding the program name. To retrieve the entire command line, use theGetCommandLine function. nCmdShow Specifies how the window is to be shown. This parameter can be one of the following values: Value Meaning SW_HIDE Hides the window and activates another window. SW_MINIMIZE Minimizes the specified window and activates the top-level window in the system's list. SW_RESTORE Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position (same as SW_SHOWNORMAL). SW_SHOW Activates a window and displays it in its current size and position. SW_SHOWMAXIMIZED Activates a window and displays it as a maximized window. SW_SHOWMINIMIZED Activates a window and displays it as an icon. SW_SHOWMINNOACTIVE Displays a window as an icon. The active window remains active. SW_SHOWNA Displays a window in its current state. The active window remains active. SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active. SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position (same as SW_RESTORE). Return Values 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 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. The reason that WinMain cannot return Unicode 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 it uses the LPTSTR data type. Windows CE: Windows CE does not support the following values for the nCmdShow parameter: SW_MINIMIZE SW_RESTORE SW_SHOWMAXIMIZED SW_SHOWMINIMIZED SW_SHOWMINNOACTIVE QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. Import Library: User-defined. See Also Windows Overview, Window Functions,CreateMutex, DispatchMessage,GetCommandLine, GetMessage, PostQuitMessage, TranslateMessage
xiaohuh421 2014-05-29
  • 打赏
  • 举报
回复
winmain 这是程序入口函数, 是系统调用的.
图灵狗 2014-05-29
  • 打赏
  • 举报
回复
参考 http://blog.sina.com.cn/s/blog_67bc5aa60101aasg.html 参考 http://blog.itpub.net/27660822/viewspace-776208
super_admi 2014-05-28
  • 打赏
  • 举报
回复
找本《Windows 程序设计》瞅两眼。

65,209

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧