mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-26 17:16:20 +00:00
Changed: Use CreateProcess instead of WinExec (deprecated) to launch an executable
This commit is contained in:
parent
476ac53605
commit
9c7c4d59db
1 changed files with 23 additions and 20 deletions
|
@ -1450,37 +1450,40 @@ static bool openDocWithExtension (const std::string &document, const std::string
|
||||||
{
|
{
|
||||||
lstrcatW(key, L"\\shell\\open\\command");
|
lstrcatW(key, L"\\shell\\open\\command");
|
||||||
|
|
||||||
|
// get the command used to open a file with this extension
|
||||||
if (GetRegKey(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS)
|
if (GetRegKey(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
char *pos = strstr(key, "\"%1\"");
|
std::string program = wideToUtf8(key);
|
||||||
|
|
||||||
if (pos == NULL)
|
// empty program
|
||||||
|
if (program.empty()) return false;
|
||||||
|
|
||||||
|
if (program[0] == '"')
|
||||||
{
|
{
|
||||||
// No quotes found
|
// program is quoted
|
||||||
// Check for %1, without quotes
|
std::string::size_type pos = program.find('"', 1);
|
||||||
pos = strstr(key, "%1");
|
|
||||||
|
if (pos != std::string::npos)
|
||||||
if (pos == NULL)
|
|
||||||
{
|
{
|
||||||
// No parameter at all...
|
// take part before next quote
|
||||||
pos = key+lstrlenA(key)-1;
|
program = program.substr(1, pos - 1);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Remove the parameter
|
|
||||||
*pos = '\0';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Remove the parameter
|
// program has a parameter
|
||||||
*pos = '\0';
|
std::string::size_type pos = program.find(' ', 1);
|
||||||
|
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
// take part before first space
|
||||||
|
program = program.substr(0, pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lstrcatA(pos, " ");
|
// create process
|
||||||
lstrcatA(pos, document);
|
PROCESS_INFORMATION pi;
|
||||||
int res = WinExec(key, SW_SHOWDEFAULT);
|
return createProcess(program, document, false, pi);
|
||||||
return (res>31);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue