MCPcopy Create free account
hub / github.com/clechasseur/pathcopycopy / Launch

Method Launch

PathCopyCopy/src/PathCopyCopySettingsApp.cpp:45–88  ·  view source on GitHub ↗

Launches the settings application using the given command. @param p_Options Program options. See header for default values.

Source from the content-addressed store, hash-verified

43 // @param p_Options Program options. See header for default values.
44 //
45 void SettingsApp::Launch(const Options& p_Options /*= Options()*/)
46 {
47 // Get path to our module using the ImageBase trick.
48 // See http://www.codeproject.com/KB/DLL/DLLModuleFileName.aspx
49 std::wstring dllPath(MAX_PATH + 1, L'\0');
50#pragma warning(suppress: 26490) // Dirty trick is dirty
51 const DWORD siz = ::GetModuleFileNameW(reinterpret_cast<HINSTANCE>(&__ImageBase),
52 dllPath.data(), gsl::narrow<DWORD>(dllPath.size()));
53 if (siz > 0) {
54 // Remove the filename and replace it with the name of the settings app.
55 std::wstring path(dllPath.c_str());
56 const auto delimPos = path.find_last_of(L"/\\");
57 if (delimPos != std::wstring::npos) {
58 path.erase(delimPos);
59 }
60 ATL::CStringW settingsAppName(MAKEINTRESOURCEW(IDS_SETTINGS_APP_FILE_NAME));
61 path += L"\\";
62 path += (LPCWSTR) settingsAppName;
63
64 // Build parameters.
65 std::wstring params = L"/frompcc";
66#ifndef _WIN64
67 params += L" /bitness:x86";
68#else
69 params += L" /bitness:x64";
70#endif
71 if (p_Options.m_UpdateCheck) {
72 params += L" /updatecheck";
73 }
74
75 // Launch the settings app and don't wait for the result.
76#pragma warning(suppress: 26476) // Something about this type doesn't fit, but I can't change the Win32 API
77 SHELLEXECUTEINFOW execInfo{0};
78 execInfo.cbSize = sizeof(execInfo);
79 execInfo.fMask = 0;
80 execInfo.hwnd = nullptr;
81 execInfo.lpVerb = nullptr;
82 execInfo.lpFile = path.c_str();
83 execInfo.lpParameters = params.c_str();
84 execInfo.lpDirectory = nullptr;
85 execInfo.nShow = SW_SHOWNORMAL;
86 ::ShellExecuteExW(&execInfo);
87 }
88 }
89
90 //
91 // Constructor.

Callers 2

InvokeCommandMethod · 0.80
CheckForUpdatesMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected