一、基础类型

(Windows中源代码:)

typedef unsigned long      DWORD;
typedef int                 BOOL;   //TRUE、FALSE
typedef unsigned char      BYTE;
typedef unsigned short      WORD;
typedef float              FLOAT;
typedef FLOAT           *PFLOAT;
typedef BOOL near * PBOOL;
typedef BOOL far * LPBOOL;
typedef BYTE near*PBYTE;
typedef BYTE far *LPBYTE;
typedef int near*PINT;
typedef int far*LPINT;
typedef WORD near* PWORD;
typedef WORD far *LPWORD;
typedef long far *LPLONG;
typedef DWORD near*PDWORD;
typedef DWORD far*LPDWORD;
typedef void far        *LPVOID;
typedef CONST void far         *LPCVOID;
typedef int                 INT;
typedef unsigned int        UINT;
typedef unsigned int        *PUINT;

转化后:

typedef unsigned long       DWORD;
typedef int                 BOOL;//TRUE FALSE
typedef unsigned char       BYTE;
typedef unsigned short      WORD;
typedef float               FLOAT;
typedef FLOAT*               PFLOAT;
typedef BOOL*    PBOOL;
typedef BOOL*               LPBOOL;
typedef BYTE*    PBYTE;
typedef BYTE*            LPBYTE;
typedef int*            PINT;
typedef int*            LPINT;
typedef WORD*               PWORD;
typedef WORD*            LPWORD;
typedef long*            LPLONG;
typedef DWORD*            PDWORD;
typedef DWORD*            LPDWORD;
typedef void*                LPVOID;
typedef CONST void*        LPCVOID;

typedef int                 INT;
typedef unsigned int        UINT;
typedef unsigned int*       PUINT;
#define  VOID void
typedef  char CHAR;
typedef  short SHORT;
typedef  long LONG;
typedef CHAR*   PCHAR,         LPSTR; //可写的指针变量
typedef CONST CHAR *LPCSTR, *PCSTR;//只读的指针变量

2、结构体类型:POINT,SIZE,RECT


typedef  struct  tagPOINT
{
    LONG  x;
    LONG  y;
} POINT, *PPOINT, *LPPOINT;
typedef  struct  tagSIZE
{
    LONG        cx;
    LONG        cy;
} SIZE, *PSIZE, *LPSIZE;

typedef  struct  tagRECT
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECT, *PRECT,  NEAR *NPRECT, FAR *LPRECT;
typedef const RECT FAR* LPCRECT;

3、句柄类型:可以操作某一类事物的指针变量(依托),故意隐含了具体内容的一个结构体指针变量;
HWND:操作窗口的句柄
HICON:图标的句柄
HCURSOR:光标的句柄
HMENU:菜单的句柄
HDC:绘图句柄

#define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name

//拆分后

#define DECLARE_HANDLE(HWND

structHWND__{int unused;}; 

typedef structHWND__ *name

4、UNICODE与多字符集:是两种文字编码方式

a)多字符集:各国文字的编码之间有些重叠的编码(编码冲突)
const char* p = "abc221@%#$%";
p = "中国";
b)UNICODE:各国编码统一编码
const wchar_t* p = L"abcd32$";
c)wchar_t是属于双字节变量;
d)UNICODE的字符串常量必须在前面加一个大写L;
e)TCHAR类型是两种编码格式的自适应类型;




#include <iostream>
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
	const char *p="中文";//多字符集编码
	//p="abc3";
	//Unicode编码
	const wchar_t *pU=L"中文";//Unicode编码
	return 0;
}


Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐