windows数据类型

来源:互联网 发布:淘宝有没有岛国动作片 编辑:程序博客网 时间:2024/06/05 14:40
 

#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

typedef WCHAR               TCHAR, *PTCHAR; 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

#ifdef  UNICODE                     // r_winnt

#ifndef _TCHAR_DEFINED

typedef WCHAR TCHAR, *PTCHAR;

typedef WCHAR TBYTE , *PTBYTE ;

#define _TCHAR_DEFINED

#endif /* !_TCHAR_DEFINED */

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);