startupinfo结构的一个问题
我想知道对startupinfo结构的hStdInput hStdOutput hStdError 赋值为socket的句柄,创建的匿名管道为cmd。那三个结构参数是怎么知道传递进来的句柄是套接字并且还能把数据传输到另一端?
底层对于管道或者socket 的操作是一样的把,可以参考msdn
http://msdn.(v=vs.85).aspx
hStdInput
If dwFlags specifies STARTF_USESTDHANDLES, this member is the standard input handle for the process. If STARTF_USESTDHANDLES is not specified, the default for standard input is the keyboard buffer.
If dwFlags specifies STARTF_USEHOTKEY, this member specifies a hotkey value that is sent as the wParam parameter of a WM_SETHOTKEY message to the first eligible top-level window created by the application that owns the process. If the window is created with the WS_POPUP window style, it is not eligible unless the WS_EX_APPWINDOW extended window style is also set. For more information, see CreateWindowEx.
Otherwise, this member is ignored.
hStdOutput
If dwFlags specifies STARTF_USESTDHANDLES, this member is the standard output handle for the process. Otherwise, this member is ignored and the default for standard output is the console window's buffer.
If a process is launched from the taskbar or jump list, the system sets hStdOutput to a handle to the monitor that contains the taskbar or jump list used to launch the process. For more information, see Remarks.
Windows 7, Windows Server 2008 R2, Windows Vista, Windows Server 2008, Windows XP, and Windows Server 2003: This behavior was introduced in Windows 8 and Windows Server 2012.
hStdError
If dwFlags specifies STARTF_USESTDHANDLES, this member is the standard error handle for the process. Otherwise, this member is ignored and the default for standard error is the console window's buffer.