[C++] socket -9[匿名管道]

::怎么弄都不能读取信息....先把代码放着....

 #include<windows.h>
#include<stdio.h>
int main()
{
HANDLE read=NULL,write=NULL;
SECURITY_ATTRIBUTES ss;
STARTUPINFO sa={};
PROCESS_INFORMATION pp={};
char text[]="匿名管道程序测试!";
DWORD writetext;
ss.nLength=sizeof(ss);
ss.lpSecurityDescriptor=NULL;
ss.bInheritHandle=TRUE;
if(CreatePipe(&read,&write,&ss,))
{
printf("创建匿名管道成功!\r\n");
sa.cb=sizeof(sa);
sa.dwFlags=STARTF_USESHOWWINDOW;
sa.hStdInput=read;
sa.hStdOutput=write;
sa.hStdError=GetStdHandle(STD_ERROR_HANDLE);
if(::CreateProcess(NULL,"子进程.exe",NULL,NULL,TRUE,,NULL,NULL,&sa,
&pp))
{
printf("创建子进程成功\r\n");
WriteFile(write,text,sizeof(text),&writetext,NULL);
printf("通过匿名管道写入数据成功\r\n");
}
else
{
printf("创建子程失败\r\n");
}
}
//::Sleep(50000);
return ;
}
 #include<windows.h>
#include<stdio.h>
int main()
{
HANDLE read=NULL;
char text[]={};
DWORD readtext;
read=GetStdHandle(STD_INPUT_HANDLE);
if(ReadFile(read,text,,&readtext,NULL))
{
printf("从匿名管道读取的数据是: %s\r\n",text);
}
else
{
printf("读取失败!\r\n");
}
::Sleep();
return ;
}
上一篇:重启Zabbix Server


下一篇:R语言常用操作