Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

how to use CreateProcess in c++

$
0
0
hey
I try to start a program (ContentWriter.exe) with my program.
but it just gives me error code 3 ("The system cannot find the path specified.")

I suspect it may have to do with my address contains spaces , and I would like to start (ContentWriter.exe) with arguments.

thanks for the help in advance !

STARTUPINFO info;
PROCESS_INFORMATION processInfo;
ZeroMemory(&info, sizeof(STARTUPINFO));
ZeroMemory(&processInfo, sizeof(PROCESS_INFORMATION));

string temp =  ExePath() + "\\ContentWriter\\ContentWriter.exe";
//temp = "C:\\Dropbox\\prog\\c++\\Parallel game engine2\\Debug\\ContentWriter\\ContentWriter.exe"

if (CreateProcess(temp.c_str(), NULL, NULL, NULL, FALSE, 0, 0, NULL, &info, &processInfo))
{
::WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
return 0;
}
DWORD WINAPI error = GetLastError();

string ExePath() {
char buffer[MAX_PATH];
GetModuleFileName( NULL, buffer, MAX_PATH );
string::size_type pos = string( buffer ).find_last_of( "\\/" );
return string( buffer ).substr( 0, pos);
}


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>