CreateProcess 创建进程,但游戏不工作
CreateProcess creating process, but game is not working
我对 createProcess
功能有疑问。进程已创建,但游戏无法运行,游戏不在“应用程序”选项卡中。没有错误。我的代码:
if(!CreateProcessA("D:\GTASA\GTASA\gta_sa.exe", GetCommandLineA(), NULL,
NULL, false, CREATE_SUSPENDED, NULL, NULL, &si, &pi))
{
printf( "Could not create process. (%ld)", GetLastError() );
return 0;
}
// tutaj mozna sie wczepic w gta
ResumeThread ( pi.hThread );
// tutaj juz nie
if(!pi.hThread){
outputToConsole("Gra nie uruchomila się poprawnie.");
}
outputToConsole("Gra zostala uruchomiona!");
WaitForSingleObject( pi.hProcess, INFINITE );
outputToConsole("Proces gry zostal wylaczony.");
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
感谢您的帮助。
您应该像这样在它自己的目录中启动游戏:
string strDir = game_path.substr(0, game_path.find_last_of("/\")); //Get the process dir name
//STart the process in its dir
if (!CreateProcess(game_path.c_str(), NULL, NULL, NULL, FALSE,
CREATE_SUSPENDED, NULL, strDir.c_str(), &siLoadee, &m_piLoadee))
我对 createProcess
功能有疑问。进程已创建,但游戏无法运行,游戏不在“应用程序”选项卡中。没有错误。我的代码:
if(!CreateProcessA("D:\GTASA\GTASA\gta_sa.exe", GetCommandLineA(), NULL,
NULL, false, CREATE_SUSPENDED, NULL, NULL, &si, &pi))
{
printf( "Could not create process. (%ld)", GetLastError() );
return 0;
}
// tutaj mozna sie wczepic w gta
ResumeThread ( pi.hThread );
// tutaj juz nie
if(!pi.hThread){
outputToConsole("Gra nie uruchomila się poprawnie.");
}
outputToConsole("Gra zostala uruchomiona!");
WaitForSingleObject( pi.hProcess, INFINITE );
outputToConsole("Proces gry zostal wylaczony.");
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
感谢您的帮助。
您应该像这样在它自己的目录中启动游戏:
string strDir = game_path.substr(0, game_path.find_last_of("/\")); //Get the process dir name
//STart the process in its dir
if (!CreateProcess(game_path.c_str(), NULL, NULL, NULL, FALSE,
CREATE_SUSPENDED, NULL, strDir.c_str(), &siLoadee, &m_piLoadee))