匿名管道(例子)

news/2024/7/4 10:01:02

 子进程源代码:



void  CProcessChildView::OnMypipeWrite()
{
    
// TODO: Add your command handler code here

    char    buf[] = "Hello, I am child process! I love my baby so much!" ;
    DWORD    dwWrite    
= 0
;

    
if (!WriteFile(m_hWrite, buf, strlen(buf) + 1&
dwWrite, NULL))
    {
        MessageBox(
"child process write failed.."
);
    }
}

void
 CProcessChildView::OnMypipeRead()
{
    
// TODO: Add your command handler code here

    char    buf[100= "

父进程源代码:


void  CProcessParentView::OnPipeCreate()
{
    
// TODO: Add your command handler code here

    SECURITY_ATTRIBUTES    sa;
    sa.bInheritHandle    
=
 TRUE;
    sa.lpSecurityDescriptor 
=
 NULL;
    sa.nLength        
= sizeof
(SECURITY_ATTRIBUTES);

    
if (!CreatePipe(&m_hRead, &m_hWrite, &sa, 0
))
    {
        MessageBox(
"Create anymouse pipe failed!"
);

        
return
;
    }

    STARTUPINFO        sui;
    PROCESS_INFORMATION    pi;

    ZeroMemory(
&sui, sizeof
(STARTUPINFO));
    sui.cb        
= sizeof
(STARTUPINFO);
    sui.dwFlags    
=
 STARTF_USESTDHANDLES;
    sui.hStdInput    
=
 m_hRead;
    sui.hStdOutput    
=
 m_hWrite;
    sui.hStdError    
=
 GetStdHandle(STD_ERROR_HANDLE);

    
if (!CreateProcess("E:/program/ProcessChild/ProcessChild/Debug/ProcessChild.exe", NULL, NULL, NULL, TRUE, 0, NULL, NULL, &sui, &
pi))
    {
        DWORD dw 
=
 GetLastError();
        
char buf[10= "

http://www.niftyadmin.cn/n/1999128.html

相关文章

centos 安装 mysql客户端_Centos7 下面安装 MySql 客户端

cd 到下载目录;执行sudo rpm -iU mysql-workbench-community-6.3.8-1.el7.x86_64.rpm如果系统依赖软件不满足,会提示,比如我的是这样的:[mslageecentos-dev Downloads]$ rpm -iU mysql-workbench-community-6.3.8-1.el7.x86_64.rp…

最值一看-------轮播图

<!DOCTYPE HTML><html><head><meta http-equiv"Content-Type" content"text/html; charsetgb2312"><title>最值衣看</title><link href"http://www.hc360.com/chat/2014/0527/css/styles.css" rel"…

邮槽使用例子

接受端源代码&#xff1a; void CMailslotSrvView::OnMailslotsrv(){ // TODO: Add your command handler code here HANDLE hMailslot NULL; char buf[100] "/0"; DWORD dwRead 0; hMailslot CreateMailslot(".//mailslot//mymailslot", 0, MAILSLOT…

深入理解 React JS 中的 setState

此文主要探讨了 React JS 中的 setState 背后的机制&#xff0c;供深入学习 React 研究之用。 在课程 React.js入门基础与案例开发 中&#xff0c;有些同学会发现 React JS 中的 setState 的表现好像有点怪异&#xff0c;和理解中的 state 更新机制不太一样&#xff0c;下面我们…

mysql和mysqla_mysql(连接查询和数据库设计)

--创建学生表create table students (id int unsigned not null auto_increment primary key,name varchar(20) default ,age tinyint unsigned default 0,high decimal(5,2),gender enum(男, 女, 中性, 保密) default 保密,cls_id int unsigned default 0,is_delete bit defau…

使用nginx作为websocket的proxy server

blog.csdn.net/zhx6044/article/details/50278765 WebSocket WebSocket协议为创建客户端和服务器端需要实时双向通讯的webapp提供了一个选择。其为HTML5的一部分&#xff0c;WebSocket相较于原来开发这类app的方法来说&#xff0c;其能使开发更加地简单。大部分现在的浏览器都支…

命名管道例子

Server: // CNamedPipeClientView 消息处理程序voidCNamedPipeClientView::OnNamedpipeConnect(){ // TODO: Add your command handler code hereif (!WaitNamedPipe("//./pipe/mypipe", NMPWAIT_WAIT_FOREVER)) { MessageBox("there is no usable…

mysql 全文索引 使用_MySql全文索引

使用索引是数据库性能优化的必备技能之一。在MySQL数据库中&#xff0c;有四种索引&#xff1a;聚集索引(主键索引)、普通索引、唯一索引以及我们这里将要介绍的全文索引(FULLTEXT INDEX)。全文索引(也称全文检索)是目前搜索引擎使用的一种关键技术。它能够利用「分词技术「等多…