MCPcopy Create free account
hub / github.com/DFHack/dfhack / findDwarfFortressProcess

Function findDwarfFortressProcess

package/launchdf.cpp:160–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158#ifdef WIN32
159
160DWORD findDwarfFortressProcess() {
161 PROCESSENTRY32W entry;
162 entry.dwSize = sizeof(PROCESSENTRY32W);
163
164 const auto snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
165
166 if (!Process32FirstW(snapshot, &entry))
167 {
168 CloseHandle(snapshot);
169 return -1;
170 }
171
172 do {
173 std::wstring executableName(entry.szExeFile);
174 if (executableName == L"Dwarf Fortress.exe")
175 {
176 CloseHandle(snapshot);
177 return entry.th32ProcessID;
178 }
179 } while (Process32NextW(snapshot, &entry));
180
181 CloseHandle(snapshot);
182 return -1;
183}
184
185bool waitForDF(bool nowait) {
186 DWORD df_pid = findDwarfFortressProcess();

Callers 1

waitForDFFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected