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 __stdcall
CALLBACK
和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_FORCEMINIMIZE | 11 | Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread. |
SW_HIDE | 0 | Hides the window and activates another window. |
SW_MAXIMIZE | 3 | Maximizes the specified window. |
SW_MINIMIZE | 6 | Minimizes the specified window and activates the next top-level window in the Z order. |
SW_RESTORE | 9 | 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 | 5 | Activates the window and displays it in its current size and position. |
SW_SHOWDEFAULT | 10 | Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. |
SW_SHOWMAXIMIZED | 3 | Activates the window and displays it as a maximized window. |
SW_SHOWMINIMIZED | 2 | Activates the window and displays it as a minimized window. |
SW_SHOWMINNOACTIVE | 7 | Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated. |
SW_SHOWNA | 8 | Displays the window in its current size and position. This value is similar to SW_SHOW, except that the window is not activated. |
SW_SHOWNOACTIVATE | 4 | Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated. |
SW_SHOWNORMAL | 1 | 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. |
我就懒得翻译了,大概应该看得懂
Windows游戏开发学习一 —— WinMain函数相关推荐
- [置顶] 【Visual C++】游戏开发笔记之一——API函数、DirectX的关键系统...
本系列文章由zhmxy555(毛星云)编写,转载请注明出处. http://blog.csdn.net/zhmxy555/article/details/7318264 作者:毛星云 邮箱: h ...
- Windows游戏开发感想一个完整的Windows窗口程序
现在的互联网行业从事Windows游戏开发的人实在是太少了.一是因为门槛较高,游戏行业本来就是互联网行业最尖端的领域,要想从事游戏开发,不仅要掌握一门过硬的语言,尤其是对C++的精通,还要对算法非常精 ...
- 【Visual C++】游戏开发笔记之一——API函数、DirectX的关键系统
本系列文章由@浅墨_毛星云 出品,转载请注明出处. 文章链接: http://blog.csdn.net/poem_qianmo/article/details/7318264 作者:毛星云(浅墨) ...
- Windows驱动开发学习笔记(七)—— 多核同步内核重载
Windows驱动开发学习笔记(七)-- 多核同步 基础知识 并发与同步 分析 InterlockedIncrement 原子操作相关API 内核文件 多核同步 临界区 示例一:错误的临界区 示例二: ...
- Windows驱动开发学习笔记(六)—— Inline HOOK
Windows驱动开发学习笔记(六)-- Inline HOOK SSDT HOOK Inline Hook 挂钩 执行流程 脱钩 实验一:3环 Inline Hook 实验二:0环 Inline H ...
- Windows驱动开发学习笔记(五)—— SSDT HOOK
Windows驱动开发学习笔记(五)-- SSDT HOOK 系统服务表 系统服务描述符表 实验一:通过代码获取SSDT表地址 通过页表基址修改页属性 方法1:修改页属性 方法2:修改CR0寄存器 实 ...
- Windows驱动开发学习笔记(四)—— 3环与0环通信(常规方式)
Windows驱动开发学习笔记(四)-- 3环与0环通信(常规方式) 设备对象 创建设备对象 设置数据交互方式 创建符号链接 IRP与派遣函数 IRP的类型 其它类型的IRP 派遣函数 派遣函数注册位 ...
- Windows驱动开发学习笔记(三)—— 内核空间内核模块
Windows驱动开发学习笔记(三)-- 内核空间&内核模块 内核空间 实验 第一步:编译如下代码 第二步:将 .sys 文件拷贝到虚拟机中 第三步:部署 .sys 文件并运行 第四步:创建一 ...
- Windows驱动开发学习笔记(二)—— 驱动调试内核编程基础
Windows驱动开发学习笔记(二)-- 驱动调试&内核编程基础 基础知识 驱动调试 PDB(Program Debug Database) WinDbg 加载 PDB 实验:调试 .sys ...
最新文章
- 【Android 安装包优化】WebP 图片格式兼容与性能 ( Android 中的 WebP 图片格式兼容问题 | Android 中的 WebP 图片格式性能 )
- 一般线性模型和混合线性模型_线性混合模型如何工作
- Mod, Or and Everything HDU - 6950
- 我跳槽是因为他们的显示器更大
- [转载] Python里面numpy库中zeros()的一些问题
- 相似图片搜索的原理(二)(转)
- XILINX FPGA数字信号处理——4、CORDIC算法原理及实现
- 用计算机处理文字,计算机文字 计算机文字与信息处理
- layui编辑器上传图片
- 从嵌入式系统到无线模组 周立功单片机欲站在物联网的风口
- [历朝通俗演义-蔡东藩-前汉]第002回 诛假父纳言迎母 称皇帝立法愚民
- ios 渐变透明背景_2019 - 渐变梯度
- C语言 定时器的原理,单片机定时器作用原理及学习应用详解
- 利用手机距离感应器来切换是用扬声器听音乐还是听筒听音乐
- SqlServer——正则表达式
- 6.5 发散思维能力
- 扒皮下音悦台的“返回顶部”图标效果
- 什么耳机对而伤害最小,传闻不伤耳的骨传导耳机是真的吗?
- 按揭贷款买房流程及注意事项详解 你准备好买房了吗
- FreeRTOS消息队列