11 HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
16 PROCESSENTRY32 process_entry;
17 process_entry.dwSize =
sizeof(PROCESSENTRY32);
19 if (!Process32First(hSnapShot, &process_entry)) {
20 CloseHandle(hSnapShot);
25 DWORD our_pid = GetCurrentProcessId();
26 DWORD parent_pid = -1;
29 if (process_entry.th32ProcessID == our_pid) {
30 parent_pid = process_entry.th32ParentProcessID;
33 }
while (Process32Next(hSnapShot, &process_entry));
35 if (parent_pid == -1 || !Process32First(hSnapShot, &process_entry)) {
36 CloseHandle(hSnapShot);
44 if (process_entry.th32ProcessID == parent_pid) {
45 if (_wcsicmp(process_entry.szExeFile,
L"steam.exe") == 0) {
50 }
while (Process32Next(hSnapShot, &process_entry));
52 CloseHandle(hSnapShot);
56 int WINAPI
wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine,
int nCmdShow)
58 STARTUPINFO siStartInfo = {0};
59 PROCESS_INFORMATION procInfo;
60 wchar_t path[MAX_PATH];
62 siStartInfo.wShowWindow = SW_HIDE;
63 siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
67 DWORD nSize = GetModuleFileName(
NULL, path, MAX_PATH);
77 if (GetLastError() == ERROR_SUCCESS && nSize == MAX_PATH) {
82 if (PathCchRemoveFileSpec(path, MAX_PATH) != S_OK) {
87 if (PathCchCombine(path, MAX_PATH, path,
L"blender.exe") != S_OK) {
91 int required_size_chars = lstrlenW(path) +
95 size_t required_size_bytes = required_size_chars *
sizeof(wchar_t);
96 wchar_t *
buffer = (
wchar_t *)malloc(required_size_bytes);
101 if (StringCbPrintfEx(
buffer,
105 STRSAFE_NULL_ON_FAILURE,
113 BOOL success = CreateProcess(
116 DWORD returnValue = success ? 0 : -1;
123 LPWSTR *argv = CommandLineToArgvW(pCmdLine, &argc);
124 for (
int i = 0; i < argc; i++) {
125 if ((wcscmp(argv[i],
L"-b") == 0) || (wcscmp(argv[i],
L"--background") == 0)) {
132 WaitForSingleObject(procInfo.hProcess, INFINITE);
133 GetExitCodeProcess(procInfo.hProcess, &returnValue);
139 CloseHandle(procInfo.hThread);
140 CloseHandle(procInfo.hProcess);
void BLI_kdtree_nd_() free(KDTree *tree)
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
ccl_global float * buffer