//网上摘抄的例子:原示例有错误,经修改如下。// Pipe.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <stdlib.h>
void go(HWND hwnd)
{
char * ping = "IPCONFIG"; // 命令
char pbuf[1024]; // 缓存
DWORD len;
STARTUPINFO si;
PROCESS_INFORMATION pi;
HANDLE hRead1, hWrite1; // 管道读写句柄
BOOL b;
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE; // 管道句柄是可被继承的
saAttr.lpSecurityDescriptor = NULL;
// 创建匿名管道,管道句柄是可被继承的
b = CreatePipe(&hRead1, &hWrite1, &saAttr, 1024);
if (!b)
{
MessageBox(hwnd, "管道创建失败。","Information",0);
return ;
}
memset(&si, 0, sizeof(
关于匿名管道,重定向PING中的数据。
最新推荐文章于 2022-01-24 15:41:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)