---
title: "MFC基本类型"
author: "Jason5563"
date: "2010-06-04T22:50:48Z"
tags: ["Blog", "MFC", "Pascal", "Windows"]
categories: ["编程语言"]
slug: "mfc"
draft: false
lastmod: "2010-06-04T22:50:48Z"
id: 684447
url: "https://jason5563.iteye.com/blog/684447"
---

#define FALSE   0           afx.h

#define TRUE    1           afx.h

#define NULL    0           afx.h

typedef void                VOID        winnt.h

**//短整型**typedef unsigned short

typedef unsigned short      USHORT;     windef.h

typedef unsigned short      WORD;       windef.h

typedef unsigned short      wchar\_t

typedef short               SHORT;      winnt.h

**//整型**typedef  int

typedef int                 BOOL;  //取值为TRUE or FALSE windef.h

typedef int                 INT; windef.h

typedef unsigned int        UINT; //定义一个新的Win32数据类型，它会把一个参数强制转换成Windows3.x应用中的16位值 或Win32应用中的32位值windef.h

**//长整型**typedef long

typedef unsigned long       ULONG;    windef.h

typedef unsigned long       DWORD;    windef.h

typedef DWORD               COLORREF; windef.h

typedef long                LONG;     winnt.h

typedef \_\_int64             LONGLONG; winnt.h

typedef unsigned \_\_int64    ULONGLONG; winnt.h

typedef ULONGLONG           DWORDLONG; winnt.h

**//浮点型**

typedef float               FLOAT;     windef.h

typedef double              DOUBLE;    wtypes.h

**//字符类型**typedef char

typedef char                CHAR/CCHAR; winnt.h

typedef unsigned char       UCHAR;      windef.h

typedef unsigned char       BYTE;       windef.h

typedef wchar\_t             WCHAR; //声明一个16位的UNICODE字符，用来表示世界上所有已知的书写语言的符号winnt.h

**//指向字符串的指针类型LP\***

/\*以下为winnt.h的部分内容\*/

// **UNICODE (Wide Character) types** 

typedef wchar\_t WCHAR;    // wc,   16-bit UNICODE character

typedef \_\_nullterminated WCHAR \*NWPSTR, \*LPWSTR, \*PWSTR;

typedef \_\_nullterminated CONST WCHAR \*LPCWSTR, \*PCWSTR;

// **ANSI (Multi-byte Character) types**

typedef CHAR \*PCHAR, \*LPCH, \*PCH;

typedef \_\_nullterminated CHAR \*NPSTR, \*LPSTR, \*PSTR;

//指向Windows字符串(以空字符结束)的32位指针char*

typedef \_\_nullterminated CONST CHAR \*LPCSTR, \*PCSTR;

//指向Windows常字符串(以空字符结束)的32位指针const   char*

// **Neutral ANSI/UNICODE types and macros**

// tchar.h

#ifdef  \_UNICODE

typedef wchar\_t     \_TCHAR;

typedef wchar\_t     TCHAR;

#else   /* ndef \_UNICODE \*/

typedef char            \_TCHAR;

typedef char            TCHAR;

#endif 

 

typedef LPWSTR PTSTR, LPTSTR;

//指向Windows字符串(以空字符结束)的32位指针，用于移植到双字节字符集

LPTSTR   For   Unicode   platforms,it   is   LPWSTR,For   ANSI   and  DBCS   platforms,it   is   LPSTR 

typedef LPCWSTR            PCTSTR, LPCTSTR;

//指向Windows常字符串(以空字符结束)的32位指针const char* ，用于移植到双字节字符集

LPCTSTR For   Unicode   platforms,it   is   LPCWSTR,For   ANSI   and   DBCS   platforms,it   is   LPCSTR  

typedef LPWSTR LP;

/\*以上为winnt.h的部分内容\*/

#define \_\_T(x)      x        tchar.h  // ndef \_UNICODE

#define \_T(x)       \_\_T(x)     tchar.h

#define \_TEXT(x)    \_\_T(x)     tchar.h

#define \_\_TEXT(quote) L##quote winnt.h  // r\_winnt 

//以上的\_T、\_\_T、\_TEXT、\_\_TEXT、L宏使字符串会自动根据工程的版本(ANSI还是UNICODE)进行转化.   使代码不需修改自动适应ASNI和UNICODE版本

typedef WCHAR OLECHAR;                        wtypes.h

typedef /* \[wire\_marshal] \*/ OLECHAR \*BSTR;   unsigned   short*  wtypes.h

**//函数参数、返回值类型**

typedef UINT\_PTR            WPARAM; //窗口函数或callback函数的一个参数，在Win16中是16-bit，在Win32中是32-bit windef.h

typedef LONG\_PTR            LPARAM; //32位窗口函数或callback函数的一个参数windef.h

typedef LONG\_PTR            LRESULT; //32位作为窗口函数或callback函数的返回值windef.h

**//指向函数的指针类型**

typedef int (WINAPI \*PROC)();PROC //指向回调函数的指针

typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);

**//Windows函数调用类型**\_\_stdcall

#define CALLBACK    \_\_stdcall   windef.h

#define WINAPI      \_\_stdcall   windef.h

#define WINAPIV     \_\_cdecl     windef.h

#define APIENTRY    WINAPI      windef.h

#define APIPRIVATE  \_\_stdcall   windef.h

#define PASCAL      \_\_stdcall   windef.h

// 关于调用宏参考[http://blog.163.com/xiang\_163\_ok/blog/static/6171684520082161551829/](http://blog.163.com/xiang_163_ok/blog/static/6171684520082161551829/)

typedef void far            \*LPVOID;  指向任意类型的指针windef.h