一.Win32数据类型
Win32的api对c/c++的基本数据类型重新进行了命名,本来是好事,但实在是太多了.不过多熟悉就知道了
MSDN参考:http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx
参考文章:http://www.cnblogs.com/beyond-code/archive/2009/03/24/1420138.html
编码参考
#include "stdafx.h"
#include <string>
#include <iostream>
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
using namespace std;
//BOOL
BOOL result;
PBOOL pbool=&result;
result=TRUE;
result=FALSE;
if(result)
result=0;
else
result=1;
if(result)
result=0;
else
result=1;
//END BOOL
//BYTE
BYTE byteDemo=255;
PBYTE pbyte=&byteDemo;
//same as BYTE
BOOLEAN boolDemo=1;
PBOOLEAN pboolean=&boolDemo;
UCHAR ucharDemo=255;
//CHAR
CHAR charDemo='a';
CHAR charArr[]="hello";
//Point To CHAR
LPSTR pchar=&charDemo;
//WCHAR
WCHAR wcharDemo1='O';
WCHAR wcharDemo2[]=L"我a";
//Point To WCHAR
LPWSTR pwchar=&wcharDemo1;
LPTSTR generalChar=&wcharDemo1;
LPVOID pvoid=&wcharDemo1;
//CONST
CONST int number1=1;
//INT
INT number3=100;
LPINT pint=&number3;
UINT number4=100;
PUINT puint=&number4;
//error LPUINT pint=&number3;
//DWORD unsigned long
DWORD number2=200;
LPDWORD pdword=&number2;
//WORD
WORD number7=200;
LPWORD pword=&number7;
//LONG
LONG number5=100;
PLONG plong=&number5;
//SHORT
SHORT number6=100;
return 0;
}
二.字符串
参考:
http://www.vckbase.com/document/viewdoc/?id=1082
http://www.codeproject.com/KB/string/cppstringguide1.aspx
http://www.codeproject.com/KB/string/cppstringguide2.aspx
http://www.cnblogs.com/beyond-code/archive/2009/03/24/1420103.html
char为8为ANSI,wchar_t为16位Unicode
char char1='a';
char chararr[]="hello";
wchar_t wchar1=L'好';
wchar_t wchar[]=L"你好";
加L表示为Unicode编码,Win32定义为CHAR和WCHAR.
使用TEXT宏能使用CHAR和WCHAR(系统自动判别)
TCHAR c=TEXT('A');
TCHAR cc[]=TEXT("Asss");
TEXT宏与_T类型,如_T("Asss");
三.数据类型转换总结
参考:
http://www.shenmiguo.com/archives/2009/275_cplus-type-cast.html
代码说明了应用了
四.Rectangle Functions
部分Win32API,实现对RECT进行操作
Test
RECT rcClient1={};
RECT rcClient2={};
OffsetRect(&rcClient1,22,0);
IsRectEmpty(&rcClient1);
EqualRect(&rcClient1,&rcClient2);
五.__uuidof
是c++的一个关键字,取GUID用的.
参考:http://www.cppblog.com/woaidongmao/archive/2008/11/09/66391.html
这样就可以直接认类和接口,而不用去找GUID的常量了
六.结构体初始化,按顺序
这个属于基础的,只是我不知道而已
struct point {
int x;
int y;
} spot = { 20, 40 };
point p1={0,0};
point p2={0};
用花括号按顺序初始化值,如果初值表未满则为初始值.
point p3={};不同于point p3;,point p3={};会进行数据初始化