fix: Cannot start application when code page is 65001. Closes #814.

This commit may cause breaking change: changing working directory to the directory where the executable locates in.
This commit is contained in:
huanghongxun
2021-05-30 02:25:31 +08:00
parent 228695d511
commit 258a6628e4
6 changed files with 28 additions and 14 deletions

View File

@@ -52,7 +52,7 @@ LSTATUS MyGetEnvironmentVariable(LPCWSTR name, std::wstring & out)
}
}
bool MyCreateProcess(const std::wstring &command)
bool MyCreateProcess(const std::wstring &command, const std::wstring &workdir)
{
wstring writable_command = command;
STARTUPINFO si;
@@ -61,7 +61,12 @@ bool MyCreateProcess(const std::wstring &command)
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
return (CreateProcess(NULL, &writable_command[0], NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi));
if (workdir.empty()) {
return CreateProcess(NULL, &writable_command[0], NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
}
else {
return CreateProcess(NULL, &writable_command[0], NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, workdir.c_str(), &si, &pi);
}
}
bool FindFirstFileExists(LPCWSTR lpPath, DWORD dwFilter)