MFC:关于Windows SDK和API的理解以及常用的Windows数据类型

1、Windows SDK和API

Windows SDK

每出现一套新的Windows系统,就会推出一个SDK(软件开发工具包Software Development Kit)。

SDK可以理解成Windows系统提供的软件开发工具的集合,除了大量的Windows函数、定义还包括相关的说明文档、辅助工具、实例等。

Windows APIWindows API是Windows为应用程序提供的接口,应用程序可以借助API调用系统提供的函数等,而这些被调用的函数包括API函数本身都是SDK的一部分。可以说API就是SDK为程序员提供可以直接访问、使用的函数。

2、Windows API 用到的都是Windows数据类型

本质上Windows数据类型和C++本身提供的数据类型没有本质的区别,只是Windows系统针对C++的数据类型提供了自己的命名方式(用typedef重命名)。

Windows常见的数据类型如下表所示

类型名称(大写,但好像Windows数据类型不区分大小)类型说明
WORD16位无符号整型
DWORD32位无符号整型
DWORD6464位无符号整型
INT32位有符号整型(在32位机)
INT3232位符号整型
INT6464位符号整型
UINT无符号INT,在32位机上与DWORD一样
LONG32位有符号整型,在32位机上与INT一样
LONGLONG64位有符号整型
ULONG无符号LONG
INT_PTR指向INT数据类型的指针类型
LPSTR字符指针,也就是字符串变量
LPCSTR字符串常量
LPDWORD 指向DWORD类型数据的指针
WCHAR 16位Unicode字符,可以对应汉字
HWND窗口句柄
HANDLE对象句柄

 

 

使用C++代码封装的win32操作类, 与MFC相似,对于学习SDK与C++是巨好的参考 Tutorials Menu of tutorials Tutorial 1: The Simplest Window Tutorial 2: Using Classes and Inheritance Tutorial 3: Using Messages to Create a Scribble Window Tutorial 4: Repainting the Window Tutorial 5: Wrapping a Frame around our Scribble Window Tutorial 6: Customising Window Creation Tutorial 7: Customising the Toolbar Tutorial 8: Loading and Saving Files Tutorial 9: Printing Tutorial 10: Finishing Touches Tutorial 1: The Simplest Window The following code uses Win32++ to create a window. This is all the code you need (in combination with Win32++) to create and display a simple window. Note that in order to add the Win32++ code to our program, we use an #include statement as shown below. #include "../Win32++/Wincore.h" INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { //Start Win32++ CWinApp MyApp; //Create a CWnd object CWnd MyWindow; //Create (and display) the window MyWindow.Create(); //Run the application return MyApp.Run(); } This program has four key steps: Start Win32++. We do this here by creating a CWinApp object called MyApp. Create a CWnd object called MyWindow. Create a default window by calling the Create function. Start the message loop, by calling the Run function. If you compile and run this program, you'll find that the application doesn't end when the window is closed. This is behaviour is normal. An illustration of how to use messages to control the windows behaviour (including closing the application) will be left until tutorial 3.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值