MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / showFolderDialog

Function showFolderDialog

apps/tools/Studio/main.cpp:35–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33#include <shobjidl.h>
34
35static std::string showFolderDialog()
36{
37 std::string result;
38 CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
39 IFileDialog* dlg = nullptr;
40 if (SUCCEEDED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_ALL, IID_IFileDialog, (void**)&dlg)))
41 {
42 DWORD opts;
43 dlg->GetOptions(&opts);
44 dlg->SetOptions(opts | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM);
45 dlg->SetTitle(L"Select Game Content Directory");
46 if (SUCCEEDED(dlg->Show(nullptr)))
47 {
48 IShellItem* item = nullptr;
49 if (SUCCEEDED(dlg->GetResult(&item)))
50 {
51 PWSTR wpath = nullptr;
52 if (SUCCEEDED(item->GetDisplayName(SIGDN_FILESYSPATH, &wpath)))
53 {
54 int len = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, nullptr, 0, nullptr, nullptr);
55 result.resize(len - 1);
56 WideCharToMultiByte(CP_UTF8, 0, wpath, -1, result.data(), len, nullptr, nullptr);
57 CoTaskMemFree(wpath);
58 }
59 item->Release();
60 }
61 }
62 dlg->Release();
63 }
64 CoUninitialize();
65 return result;
66}
67#endif
68
69static ImFont* monoFont = nullptr;

Callers 1

mainFunction · 0.85

Calls 7

GetOptionsMethod · 0.80
SetTitleMethod · 0.80
ShowMethod · 0.80
GetResultMethod · 0.45
GetDisplayNameMethod · 0.45
resizeMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected