MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / wWinMain

Function wWinMain

src/StubExecutable/StubExecutable.cpp:88–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
89 _In_opt_ HINSTANCE hPrevInstance,
90 _In_ LPWSTR lpCmdLine,
91 _In_ int nCmdShow)
92{
93 std::wstring appName;
94 appName.assign(FindOwnExecutableName());
95
96 std::wstring workingDir(FindLatestAppDir());
97 std::wstring fullPath(workingDir + L"\\" + appName);
98
99 STARTUPINFO si = { 0 };
100 PROCESS_INFORMATION pi = { 0 };
101
102 si.cb = sizeof(si);
103 si.dwFlags = STARTF_USESHOWWINDOW;
104 si.wShowWindow = nCmdShow;
105
106 std::wstring cmdLine(L"\"");
107 cmdLine += fullPath;
108 cmdLine += L"\" ";
109 cmdLine += lpCmdLine;
110
111 wchar_t* lpCommandLine = _wcsdup(cmdLine.c_str());
112 wchar_t* lpCurrentDirectory = _wcsdup(workingDir.c_str());
113 if (!CreateProcess(NULL, lpCommandLine, NULL, NULL, true, 0, NULL, lpCurrentDirectory, &si, &pi)) {
114 return -1;
115 }
116
117 AllowSetForegroundWindow(pi.dwProcessId);
118 WaitForInputIdle(pi.hProcess, 5 * 1000);
119 return 0;
120}

Callers

nothing calls this directly

Calls 2

FindOwnExecutableNameFunction · 0.85
FindLatestAppDirFunction · 0.85

Tested by

no test coverage detected