C,C++
[C/C++/UWP] UWP 현재 실행되는 경로 구하기 ( Platform::String <-> WCHAR / wstring )
덜지
2016. 7. 22. 03:39
Platform::String to WCHAR / wstring
1 2 3 4 5 6 7 8 9 10 | DWORD dwTest = MAX_PATH; WCHAR wzTest[MAX_PATH] = { 0, }; GetCurrentDirectoryW(dwTest, wzTest); // WCHAR -> Platform::String String^ strTemp1 = ref new String(wzTest); // WCHAR -> WString -> Platform::String std::wstring wstrTemp(wzTest); String^ strTemp2 = ref new String(wstrTemp.c_str()); | cs |
wstring to Platform::String
1 2 3 4 5 6 7 | // Platform::String -> WString // and Replacing String^ str = "AAAA"; std::wstring wstr(str->Data()); std::wstring replacement(L"BBB"); wstr = wstr.replace(1, 3, replacement); str = ref new String(wstr.c_str()); | cs |