Skip to main content

creating a process to run in c++ // i need to run a process in c++

Hey I don't know why that when I compile this code that the fear.exe process is not running I am using visual studio for my coding ide choice the project is a win32 project // application method, that I am using..

I should say that I added a new item a c++ file called main.c++ and should I use the code file that Defines the entry point for the application. or does it matter.

#include "iostream"
#include "Windows.h"
#include "OVR_CAPI_D3D.h"
#include "Win32_DirectXAppUtil.h"
#include "stdio.h"
#include "string.h"
#include "Shlobj.h"
#include "Shlwapi.h"

using namespace std;

int WINAPI WinMain(HINSTANCE hinst, HINSTANCE, LPSTR, int)
{
    STARTUPINFO startinfo = { 0 };

    PROCESS_INFORMATION processinfo = { 0 };

    BOOL bsuccess = CreateProcess(TEXT("E:\SteamLibrary\steamapps\common\FEAR Ultimate Shooter Edition\FEAR.exe"), NULL, NULL, NULL, FALSE, NULL, NULL,
        NULL, &startinfo, &processinfo);

    if (bsuccess)
    {
        cout << "Process Injected" << endl
            << "Process ID:\t" << processinfo.dwProcessId << endl;

    }
    else
    {
            cout << "Error to start the injected process" << GetLastError() << endl;
        }
        cin.get();
        return(0);
    }