Commit 099796b1 by shuai.liu

fix: Lanch process success on platform WIN10

parent c66c559f
...@@ -157,7 +157,38 @@ bool FmControl::_LaunchProcess(const QString &exePath, QString& error) ...@@ -157,7 +157,38 @@ bool FmControl::_LaunchProcess(const QString &exePath, QString& error)
DestroyEnvironmentBlock(lpEnvironment); DestroyEnvironmentBlock(lpEnvironment);
} }
error = QString("CreateProcessAsUser failed [%1]").arg(QString::number(::GetLastError())); error = QString("CreateProcessAsUser failed [%1]").arg(QString::number(::GetLastError()));
return false; {
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
int size = exePath.size();
wchar_t* pwc = new wchar_t[size+1];
memset(pwc,0,(size+1)*2);
wcscpy(pwc,reinterpret_cast<const wchar_t*>(exePath.utf16()) );
if(!CreateProcess(NULL, // No module name (use command line)
pwc, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
)
{
QLOG_ERROR() << QString("launch process failed [%1]").arg(GetLastError());
delete[] pwc;
return false;
}
else
{
delete[] pwc;
return true;
}
}
} }
CloseHandle(pi.hProcess); CloseHandle(pi.hProcess);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment