LPCSTR __FileName = "program.exe";
void ProcessRun(LPCSTR pszExeName)
{
PROCESS_INFORMATION piProcInfoGPS;
STARTUPINFO siStartupInfo;
SECURITY_ATTRIBUTES saProcess, saThread;
ZeroMemory(&siStartupInfo, sizeof(siStartupInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
saProcess.nLength = sizeof(saProcess);
saProcess.lpSecurityDescriptor = NULL;
saProcess.bInheritHandle = true;
saThread.nLength = sizeof(saThread);
saThread.lpSecurityDescriptor = NULL;
saThread.bInheritHandle = true;
CreateProcess(NULL, (LPTSTR)pszExeName, &saProcess, &saThread, false, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &siStartupInfo, &piProcInfoGPS);
__hProcess = piProcInfoGPS.hProcess;
__ProcessID = piProcInfoGPS.dwProcessId;
}
If I pass __FileName to the function the program will run. However, when I read the filename from my ini file
[Launcher]
FileName=program.exe
char INIValue[256];
GetPrivateProfileString("Launcher", "FileName", "nan.exe", INIValue, 256, ".\\BackgroundConfig.ini");
string temp(INIValue);
__FileName = temp.c_str();
And then try to pass the filename to the function, it doesn't run. What in the world is causing this? The file name is exactly the same.