CreateProcess mit eMbedded Visual C++
-
hallo allerseits.
ich arbeite mit eMbedded Visual C++ auf einer ARMV4I plattform (XMAX400-PC) unter Windows CE 4.20.
nun möchte ich mit CreateProcess(...) einen neuen prozess starten. das schaut bei mir im moment so aus:
PROCESS_INFORMATION piProcessInfo; char *ex = "cmd.exe"; memset(&piProcessInfo, 0, sizeof(piProcessInfo)); ::CreateProcess(ex, NULL, NULL, NULL, false, 0, NULL, NULL, NULL, &piProcessInfo);
allerdings beschwert sich VC++ mit der Fehlermeldung **error C2664: 'CreateProcessW' : cannot convert parameter 1 from 'char ' to 'const unsigned short '
laut der msdn gilt ja für parameter 1: LPCTSTR lpApplicationName - Pointer to a null-terminated string that specifies the module to execute.
is ex kein zeiger auf einen string?... und was bitte ist LPCTSTR ? in der online hilfe vom VC++ ist da nirgends was zu finden
auch ein cast mit (unsigned short)ex* scheint nichts zu helfen...hat vielleicht jemand eine idee wie hier weiterzukommen ist?
danke schon jetzt
root2
-
Der erste Parameter muss eine NULL sein, beim zweiten Parameter musst du den Pfad zur EXE angeben :
CreateProcess ( NULL, (char*)(const char*) "C:\\...\*.exe", NULL, NULL, FALSE, 0, NULL, NULL, NULL, &piProcessInfo);
Gruß
:: NoName ::
-
hi und danke,
aber...
laut msdn gilt:
BOOL CreateProcess( LPCTSTR lpApplicationName, // pointer to name of executable module LPTSTR lpCommandLine, // pointer to command line string LPSECURITY_ATTRIBUTES lpProcessAttributes, // process security attributes LPSECURITY_ATTRIBUTES lpThreadAttributes, // thread security attributes BOOL bInheritHandles, // handle inheritance flag DWORD dwCreationFlags, // creation flags LPVOID lpEnvironment, // pointer to new environment block LPCTSTR lpCurrentDirectory, // pointer to current directory name LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION );
Remarks:
Windows CE: The name of the module to execute must be specified by the lpApplicationName parameter. Windows CE does not support passing NULL for lpApplicationName. The execution module cannot be specified in the command line string.selbst wenn ich es nach deinem muster versuche mosert der VC++ den parameter 2 genauso an wie bei mir den parameter 1: **error C2664: 'CreateProcessW' : cannot convert parameter 2 from 'char ' to 'const unsigned short '
root2
-
Das liegt vielleicht daran, dass es unter deinem(allen?) CEs nur Unicode gibt. Probier mal den string mit L"Pfad.zur.exe" zu deklarieren.
-
Windows CE ist grundsätzlich wide-character. Setz ein L vor die String- und Zeichenliterale.
-
fein
danke euch beiden. ihr hattet recht. mit einem L davor klappt alles so wie es soll.
einen schönen abend noch.
root2
-
hallo nochmal,
eine frage hätte ich dann doch noch:
wenn ich anstelle eines festen strings z.b. L"cmd.exe" einen variablen string ausführen möchte, z.b. so:
char *command = "cmd.exe"; CreateProcess(command, ...);
wie funktioniert das dann?
ein CreateProcess(L(char)(const char)command, ...)** geht wohl nicht...root2