Kommunikazion 2er Programme
-
Hallo Nochmal!
Ich weis schon genau, wie ich eine Kommunikation aufbauen kann.
Ich habe nur noch 1 Problem:
Bei CreateProcess(.....) wird eine STARTUPINFO Struktur übergeben.
Diese Struktur ist folgendermasen aufgebaut:typedef struct _STARTUPINFO { // si DWORD cb; LPTSTR lpReserved; LPTSTR lpDesktop; LPTSTR lpTitle; DWORD dwX; DWORD dwY; DWORD dwXSize; DWORD dwYSize; DWORD dwXCountChars; DWORD dwYCountChars; DWORD dwFillAttribute; DWORD dwFlags; WORD wShowWindow; WORD cbReserved2; LPBYTE lpReserved2; HANDLE hStdInput; HANDLE hStdOutput; HANDLE hStdError; } STARTUPINFO, *LPSTARTUPINFO;
Die letzten 3 Variablen sind für mich jetzt von eintscheidender Bedeutung, denn CreateProcess lenkt bei einem STRTF_USESTDHANDLES gesetzt Flag bei dwFlags die stdin, stdout und stderr des erzeugten Processes auf die HANDLES um, die ich hier angebe!
Meine Frage: Wie erzeuge ich nun einen neuen Input, Output, Error, dessen Handles ich dann hier übergebe?
Danke.
-
GetStdHandle
The GetStdHandle function returns a handle for the standard input, standard output, or standard error device.HANDLE GetStdHandle(
DWORD nStdHandle // input, output, or error device
);Parameters
nStdHandle
Specifies the device for which to return the handle. This parameter can have one of the following values: Value Meaning
STD_INPUT_HANDLE Standard input handle
STD_OUTPUT_HANDLE Standard output handle
STD_ERROR_HANDLE Standard error handleMfG
-
Liefert mir GetStdHandle nicht ein Handle auf die schon existierendem stdin, stdout, .. zurueck?
Ich brauche namlich völlig neue in-outputs, die nichts mit stdin, stdout, .. von meinem eigenen Process zu tun haben.
-
Hmm, dann sucht du wohl das:
CreatePipe
The CreatePipe function creates an anonymous pipe, and returns handles to the read and write ends of the pipe.BOOL CreatePipe(
PHANDLE hReadPipe, // pointer to read handle
PHANDLE hWritePipe, // pointer to write handle
LPSECURITY_ATTRIBUTES lpPipeAttributes, // pointer to security attributes
DWORD nSize // pipe size
);Parameters
hReadPipe
Pointer to the variable that receives the read handle for the pipe.hWritePipe
Pointer to the variable that receives the write handle for the pipe.lpPipeAttributes
Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpPipeAttributes is NULL, the handle cannot be inherited.
Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new pipe. If lpPipeAttributes is NULL, the pipe gets a default security descriptor.nSize
Specifies the buffer size for the pipe. The size is only a suggestion; the system uses the value to calculate an appropriate buffering mechanism. If this parameter is zero, the system uses the default buffer size.MfG