2023年8月1日发(作者:)
Windows游戏开发学习⼀——WinMain函数WinMain每个Windows程序都包含⼀个名为WinMain或wWinMain的⼊⼝点函数。注意两者中第三个参数是不⼀样的int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
PWSTR pCmdLine, INT nCmdShow);{ return 0;}INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine,
INT nCmdShow){ return 0;}函数类型INT后的WINAPI其实是可以省略的,但是省略之后将会有警告warning C4007: “WinMain”: 必须是“__stdcall”。转到宏定义会发现#define CALLBACK __stdcall#define WINAPI __stdcallCALLBACK和WINAPI都定义为了__stdcall,__stdcall表⽰⼀种调⽤约定,让编译器知道应当以Windows兼容的⽅式来产⽣机器指令(__stdcall官⽅解释)。⾸先科普⼀下句柄,在Windows编程的基础中,⼀个句柄是指使⽤的⼀个唯⼀的整数值,即⼀个4字节(64位程序中为8字节)长的数值,来标识应⽤程序中的不同对象和同类中的不同的实例,诸如,⼀个窗⼝,按钮,图标,滚动条,输出设备,控件或者⽂件等。HINSTANCE类型的hInstance,表⽰“实例句柄”或“模块句柄”(h代表参数为handle),他唯⼀对应⼀个运⾏中的实例,只有运⾏中的程序实例,才有资格分配到实例句柄。⼀个应⽤程序可以运⾏多个实例,每运⾏⼀个实例,系统都会给该实例分配⼀个句柄值,并且通过hInstance传⼊WinMain中。HINSTANCE的hPrevInstance,表⽰当前实例的前⼀个实例句柄。在Win32环境下,没有任何意义。它⽤于16位Windows,但现在总是为零。只是在进⾏WinMain函数书写时需要传⼊⼀个参数。pCmdLine,包含命令⾏参数作为Unicode字符串,p表⽰指针,CmdLine表⽰命令⾏。nCmdShow,是⼀个标志,指⽰主应⽤程序窗⼝是否将被最⼩化,最⼤化或正常显⽰。参数SW_FORCEMINIMIZESW_HIDESW_MAXIMIZE值1103描述Minimizes a window, even if the thread that owns the window is not responding. This flagshould only be used when minimizing windows from a different the window and activates another zes the specified _MINI参数MIZESW_RESTORESW_SHOWSW_SHOWDEFAULTSW_SHOWMAXIMIZEDSW_SHOWMINIMIZEDSW_SHOWMINNOACTIVESW_SHOWNASW_SHOWNOACTIVATESW_SHOWNORMAL6值Minimizes the specified window and activates the next top-level window in the Z order.描述Activates and displays the window. If the window is minimized or maximized, the systemrestores it to its original size and position. An application should specify this flag whenrestoring a minimized tes the window and displays it in its current size and position.9510Sets the show state based on the SW_ value specified in the STARTUPINFO structure passedto the CreateProcess function by the program that started the application.3Activates the window and displays it as a maximized window.2Activates the window and displays it as a minimized window.7Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED,except the window is not ys the window in its current size and position. This value is similar to SW_SHOW, exceptthat the window is not ys a window in its most recent size and position. This value is similar toSW_SHOWNORMAL, except that the window is not tes and displays a window. If the window is minimized or maximized, the systemrestores it to its original size and position. An application should specify this flag whendisplaying the window for the first time.841我就懒得翻译了,⼤概应该看得懂
发布者:admin,转转请注明出处:http://www.yc00.com/web/1690874227a452248.html
评论列表(0条)