#include <windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE PrevInstance, LPSTR lpCmdLine, int nCmdShow) { HANDLE hFile; DWORD dwWritten; TCHAR szSystemDir[MAX_PATH]; GetSystemDirectory(szSystemDir,MAX_PATH); hFile = CreateFile(TEXT("systemroot.txt"), GENERIC_WRITE, 0,NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { if (!WriteFile(hFile,szSystemDir,lstrlen(szSystemDir),&dwWritten,NULL)) { return GetLastError(); } } CloseHandle(hFile); return 0; }
#include <windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE PrevInstance, LPSTR lpCmdLine, int nCmdShow) { LPWSTR szUnicode = L"This is a Unicode String;"; LPSTR szMutliByte = "This is not a Unicode String;"; LPTSTR szString = TEXT("This string is Unicode or not depends on the option."); MessageBoxW(NULL,szUnicode,L"<字符编码1>",MB_OK); MessageBoxA(NULL,szMutliByte,"<字符编码2>",MB_OK); MessageBox(NULL,szString,TEXT("<字符编码3>"),MB_OK); return 0; } 0; }