anderen Programm starten in C++
-
Hallo,
ich möchte ein Programm (mit CreateProcess) in eine Codefragment starten. Allerdings das zu startende Programm braucht ein Paramater Zum Beispiel: simple.exe <dev>.
hier ist der code Fragment#include <windows.h>
int main(void)
{
char szPath[] = "D:\\Simple\\Debug\\simple.exe";
char var[] = "dev";
PROCESS_INFORMATION pif; //Gives info on the thread and..
//..process for the new process
STARTUPINFO si; //Defines how to start the programZeroMemory(&si,sizeof(si)); //Zero the STARTUPINFO struct
si.cb = sizeof(si); //Must set size of structureBOOL bRet = CreateProcess(
szPath, //Path to executable file
var, //Command string
NULL, //Process handle not inherited
NULL, //Thread handle not inherited
FALSE, //No inheritance of handles
0, //No special flags
NULL, //Same environment block as this prog
NULL, //Current directory - no separate path
&si, //Pointer to STARTUPINFO
&pif); //Pointer to PROCESS_INFORMATIONif(bRet == FALSE)
{
MessageBox(HWND_DESKTOP,"Unable to start program","",MB_OK);
return 1;
}CloseHandle(pif.hProcess); //Close handle to process
CloseHandle(pif.hThread); //Close handle to threadreturn 0;
}beim Compilieren und Linken ergibt keine Fehler! das Programm starte zwar er braucht der Parameter!
Mfg
-
müssen erst lernen schreiben und lesen in deutsches sprache sprechen, isse nicht einfach zu verwendet das codetags