*
Hi ich möchte gerne über Pipes mit Telnet kommunizieren:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <stdio.h>
using namespace std;
HANDLE hChildStdinRd, hChildStdinWr,
hChildStdoutRd, hChildStdoutWr;
int main(int argc, char *argv[])
{
char IpApplicationName[1000];
STARTUPINFO StartInfo;
PROCESS_INFORMATION ProcessInfo;
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
strcpy(IpApplicationName, "c:\\windows\\system32\\telnet.exe");
ZeroMemory(&StartInfo, sizeof(StartInfo));
ZeroMemory( &ProcessInfo, sizeof(PROCESS_INFORMATION) );
StartInfo.cb = sizeof(StartInfo);
StartInfo.cb = sizeof(STARTUPINFO);
StartInfo.hStdError = hChildStdoutWr;
StartInfo.hStdOutput = hChildStdoutWr;
StartInfo.hStdInput = hChildStdinRd;
//StartInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
//StartInfo.wShowWindow = SW_SHOW;
if (! CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
printf("Stdout pipe creation failed\n");
if (! CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
printf("Stdin pipe creation failed\n");
if (!CreateProcess(IpApplicationName, NULL, NULL, NULL, TRUE, HIGH_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, NULL, &StartInfo, &ProcessInfo))
CloseHandle(&ProcessInfo.hThread);
CloseHandle(&ProcessInfo.hProcess);
system("PAUSE");
return EXIT_SUCCESS;
}
Sobald ich jedoch Telnet mit dem Flag STARTF_USESTDHANDLES starte, schliesst sich Telnet automatisch. Weshalb?
MfG Joe