Using CreateProcess to run a game executable

1.2k Views Asked by At

I'm making a custom UI at the moment so I'm trying to launch a game from within my C++ application using CreateProcess. Here is my code so far

PROCESS_INFORMATION Processinfo;
STARTUPINFO StartupInfo;
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof(StartupInfo);
ZeroMemory(&Processinfo, sizeof(Processinfo));
if (CreateProcess(TEXT("C:\\Program Files(x86)\\Steam\\steamapps\\common\\Surgeon Simulator VR Meet The Medic\\Win32\\SurgeonVR.exe"),
    GetCommandLineA(),
    NULL,
    NULL,
    false,
    CREATE_SUSPENDED,
    NULL,
    NULL,
    &StartupInfo,
    &Processinfo))
{
    system("pause");
}

Im not quite sure where I'm going wrong as I've never used CreateProcess before, but after looking through a ton of examples I tried to mimic what everyone else was doing to no success.The process isnt being created, and the game is not being launched. Any help is greatly appreciated!

1

There are 1 best solutions below

0
On

Fixed the issue by using char* path = "C:\Program Files(x86)\Steam\steamapps\common\Surgeon Simulator VR Meet The Medic\Win32\SurgeonVR.exe"; and then using path as a parameter instead. I think the issue was a mistake in the path variable as well as using CREATE_SUSPENDED as a parameter.