daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. std::wstring s2ws(const std::string& s)
  2. {
  3.     int len;
  4.     int slength = (int)s.length() + 1;
  5.     len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
  6.     wchar_t* buf = new wchar_t[len];
  7.     MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
  8.     std::wstring r(buf);
  9.     delete[] buf;
  10.     return r;
  11. }
  12.  
  13. std::wstring stemp = s2ws(myString);
  14. LPCWSTR result = stemp.c_str();
  15.    
  16. std::wstring stemp = std::wstring(s.begin(), s.end());
  17. LPCWSTR sw = stemp.c_str();
  18.    
  19. #include <atlbase.h>
  20. #include <atlconv.h>
  21.  
  22. . . .
  23.  
  24. string myStr("My string");
  25. CA2W unicodeStr(myStr);
  26.    
  27. #include <windows.h>
  28. LPTSTR example = TEXT("example");
  29.    
  30. string s = "Hello World";
  31. std::wstring stemp = std::wstring(s.begin(), s.end());
  32. LPCWSTR  title =(LPCWSTR) stemp.c_str();
  33.  
  34. LPCWSTR  wname =(LPCWSTR) "Window";
  35.  
  36.  
  37. HINSTANCE hInst = GetModuleHandle(0);
  38. WNDCLASS cls = { CS_HREDRAW|CS_VREDRAW, WndProc, 0, 0, hInst, LoadIcon(hInst,MAKEINTRESOURCE(IDI_APPLICATION)),
  39.     LoadCursor(hInst,MAKEINTRESOURCE(IDC_ARROW)), GetSysColorBrush(COLOR_WINDOW),0,wname };
  40. RegisterClass( &cls );
  41. HWND window = CreateWindow(wname,title,WS_OVERLAPPEDWINDOW|WS_VISIBLE,64,64,640,480,0,0,hInst,0);
  42.  
  43. MSG Msg;
  44. while(GetMessage(&Msg,0,0,0))
  45. {
  46.     TranslateMessage(&Msg);
  47.     DispatchMessage(&Msg);
  48. }
  49. return Msg.wParam;
RAW Paste Data
Top