#include <windows.h>
#include <tchar.h>
#include <sstream>
using namespace std;
#ifdef UNICODE
typedef wstring Astring;
typedef wostringstream OStringstream;
#else
typedef string Astring;
typedef ostringstream OStringstream;
#endif
int WINAPI _tWinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PTSTR lpCmdLine,
int nCmdShow)
{
PTSTR str = TEXT("你好");
PTSTR message = TEXT("hello");
int a = lstrlen(str);
OStringstream out_str;
out_str << "this is " << a << endl;
Astring s = out_str.str();
PCTSTR p = s.c_str();
MessageBox( NULL, p, str, MB_OK );
return 0;
}
博客展示了一段 Windows API 编程的代码。代码包含多个头文件,根据是否为 UNICODE 定义不同类型别名,主函数中定义字符串,计算长度并输出,最后使用 MessageBox 显示信息。
1555





