/* VoiceChanger.exe: 같은 폴더의 env\Scripts\pythonw.exe 로 app\voice_changer.py 를 띄우는 실행기. 빌드: x86_64-w64-mingw32-gcc -O2 -municode -mwindows launcher.c -o VoiceChanger.exe */ #include #include int WINAPI wWinMain(HINSTANCE h, HINSTANCE p, PWSTR cmd, int show) { wchar_t dir[MAX_PATH], py[MAX_PATH], script[MAX_PATH], line[3 * MAX_PATH]; DWORD n = GetModuleFileNameW(NULL, dir, MAX_PATH); if (n == 0 || n >= MAX_PATH) return 1; wchar_t *slash = wcsrchr(dir, L'\\'); if (slash) *slash = 0; _snwprintf(py, MAX_PATH, L"%ls\\env\\Scripts\\pythonw.exe", dir); _snwprintf(script, MAX_PATH, L"%ls\\app\\voice_changer.py", dir); if (GetFileAttributesW(py) == INVALID_FILE_ATTRIBUTES) { MessageBoxW(NULL, L"아직 설치되지 않았습니다.\n같은 폴더의 install.bat 을 먼저 실행해 주세요.", L"음성 변환기", MB_ICONWARNING); return 1; } _snwprintf(line, 3 * MAX_PATH, L"\"%ls\" \"%ls\"", py, script); SetEnvironmentVariableW(L"PYTHONUTF8", L"1"); STARTUPINFOW si = {sizeof(si)}; PROCESS_INFORMATION pi; if (!CreateProcessW(py, line, NULL, NULL, FALSE, 0, NULL, dir, &si, &pi)) { MessageBoxW(NULL, L"음성 변환기를 시작하지 못했습니다. install.bat 을 다시 실행해 주세요.", L"음성 변환기", MB_ICONERROR); return 1; } CloseHandle(pi.hThread); CloseHandle(pi.hProcess); return 0; }