Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::wstring s2ws(const std::string& s)
- {
- int len;
- int slength = (int)s.length() + 1;
- len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
- wchar_t* buf = new wchar_t[len];
- MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
- std::wstring r(buf);
- delete[] buf;
- return r;
- }
- std::wstring stemp = s2ws(myString);
- LPCWSTR result = stemp.c_str();
- std::wstring stemp = std::wstring(s.begin(), s.end());
- LPCWSTR sw = stemp.c_str();
- #include <atlbase.h>
- #include <atlconv.h>
- . . .
- string myStr("My string");
- CA2W unicodeStr(myStr);
- #include <windows.h>
- LPTSTR example = TEXT("example");
- string s = "Hello World";
- std::wstring stemp = std::wstring(s.begin(), s.end());
- LPCWSTR title =(LPCWSTR) stemp.c_str();
- LPCWSTR wname =(LPCWSTR) "Window";
- HINSTANCE hInst = GetModuleHandle(0);
- WNDCLASS cls = { CS_HREDRAW|CS_VREDRAW, WndProc, 0, 0, hInst, LoadIcon(hInst,MAKEINTRESOURCE(IDI_APPLICATION)),
- LoadCursor(hInst,MAKEINTRESOURCE(IDC_ARROW)), GetSysColorBrush(COLOR_WINDOW),0,wname };
- RegisterClass( &cls );
- HWND window = CreateWindow(wname,title,WS_OVERLAPPEDWINDOW|WS_VISIBLE,64,64,640,480,0,0,hInst,0);
- MSG Msg;
- while(GetMessage(&Msg,0,0,0))
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- return Msg.wParam;
Add Comment
Please, Sign In to add comment