WinMain参数求助

Cym_cd10x 2021-02-04 10:40:48
刚刚学WinMain,求hInstance即“当前实例句柄”到底是什么意思
...全文
109 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
突触 2021-02-06
  • 打赏
  • 举报
回复
如果你没有其它知识做铺垫的话这个理解起来比较困难,这里的hInstance 是程序被系统加载到内存空间的首地址。
ooolinux 2021-02-06
  • 打赏
  • 举报
回复
程序和进程的概念。
赵4老师 2021-02-05
  • 打赏
  • 举报
回复
比如你执行同一个程序两次,两者的hInstance的值不一样,用来区分两者。 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
qybao 2021-02-04
  • 打赏
  • 举报
回复
说白了就是指针,指向当前实例
我将带领大家来系统学习Windows的窗口编程,包括消息、窗口、GDI绘图、游戏开发等。本课程比较基础,非常适合初学者入门,读者可以边学习边实践。具体的章节目录和课程内容如下所示:---------------------------------------------Windows游戏编程系列之1:GUI界面编程及游戏入门实战1、Windows创建第一个窗口 WinMain入口函数 5进行Windows编程的调试手法 6窗口从哪里来? 7窗口编程的步骤 7窗口编程需要的主要结构 8窗口编程需要的主要API 92、Windows的窗口过程与消息机制 如何留住窗口? 121)Windows的消息与消息循环 142)消息处理函数与常用消息 17)Windows的窗口过程函数 19 3、GDI编程之设备上下文 1)GDI的通用编程框架 222)GDI的绘图步骤 253)GDI获取设备句柄 254、GDI编程之绘制几何图形 画点、线 28颜色COLORREF 29矩形 29画圆、饼图、弦图 305、GDI编程之自定义画笔画刷画笔简介 32画刷简介 33画笔案例 33画刷案例 346、GDI编程之绘制文字 DrawText函数 35TextOut 函数 (wingdi.h) 36CreateFont函数 37绘制文本案例 377、GDI编程之绘制位图 位图简介 381)在资源中添加位图资源 392)从资源中加载位图: LoadBitmap 393)创建一个与当前DC相匹配的DC(内存DC) 394)将bitmap放入匹配的DC中:SelectObject 405)成像(1:1 比例 ) 406)取出位图 407)释放位图 418)释放匹配的DC 41绘制位图案例 41   8、Windows鼠标键盘消息 一、键盘消息 421、键盘消息 422、消息参数: 423、消息的使用: 424、键盘消息的案例代码 43二、鼠标消息 441、基本鼠标消息 442、双击消息 443、滚轮消息 454、不响应双击消息 45 9、Windows定时器消息 定时器消息介绍 47创建定时器 47关闭定时器 47定时器消息案例代码 4810、GDI游戏之跳舞动画 11、GDI游戏之走路动画 12、GDI贪吃蛇游戏实战  

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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