I am trying to open an application from my .cpp file. I did some research and found that using CreateProcess() would be the best option. Doing this resulted in the following code:
//Below has the purpose of starting up the server: -----------------------------------------------
LPWSTR command = (LPWSTR)"C:\\Users\\CCRT\\Documents\\UPDATED\\FINALSERVER\\FINALSERVER\\Debug\\FINALSERVER.exe";
// Start the child process.
LPSTARTUPINFOA si;
PROCESS_INFORMATION pi;
if (!CreateProcess(NULL, // No module name (use command line)
command, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
)
{
printf("CreateProcess failed (%d).\n", GetLastError());
}
else {
std::cout << "Command success\n";
}
However, i get the following error when i try to build my solution:
cannot convert argument 9 from 'LPSTARTUPINFOA *' to 'LPSTARTUPINFOW'
The error is on the CreateProcess() function.
I am wondering if anybody can explain the error to me and tell me how to fix it as i am so confused about what is going wrong.