windows 6 管道、进程遍历
管道命名管道
匿名管道-父子进程之间的数据传输
创建:CreatePipe
读:ReadFile
写:WriteFile
获取句柄:GetStdHandle
查看管道是否有数据可读:PeekNamedPipe
新建两个MFC应用程序
ParentDlg.h
123456789101112131415161718192021222324252627282930313233343536373839// ParentDlg.h: 头文件//#pragma once// CParentDlg 对话框class CParentDlg : public CDialogEx{// 构造public: CParentDlg(CWnd* pParent = nullptr); // 标准构造函数// 对话框数据#ifdef AFX_DESIGN_TIME enum { IDD = IDD_PARENT_DIALOG };#endif protected: virtual void DoDataExchange(CDataExchange* ...
windows 5 进程间通信
进程间通信发送消息一般是自定义消息,使用SendMessage发送
新建项目
123456#define MS_TEST WM_USER+1 //自定义消息void CA1Dlg::OnBnClickedButton1(){ HWND hWndB = ::FindWindow(NULL, "B1"); ::SendMessage(hWndB, MS_TEST, 0x12456789, 0x98745612);}
添加自定义消息,确定后点击编辑代码
1234567afx_msg LRESULT CB1Dlg::OnMsTest(WPARAM wParam, LPARAM lParam){ CString strFmt; strFmt.Format("w:%08x,l:%08x", wParam, lParam); AfxMessageBox(strFmt); return 0;}
在头文件处要添加定义
在B1初始化处要给窗口添加名字
123456789101112 ...
windows 4 跨进程使用句柄、操作内存
跨进程使用句柄
A进程拿到句柄,把值给B进程,B进程能不能直接使用?
继承方式创建MFC应用
新建按钮
使用多字节字符集
新建编辑框,修改ID
1234567891011121314151617181920212223242526272829303132333435void CADlg::OnBnClickedButton1(){ // TODO: 在此添加控件通知处理程序代码 STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); SECURITY_ATTRIBUTES sa = {}; sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE;//进程句柄允许被继承 //Start the child process. if (!CreateProcess(NULL, "B. ...
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick StartCreate a new post1$ hexo new "My New Post"
More info: Writing
Run server1$ hexo server
More info: Server
Generate static files1$ hexo generate
More info: Generating
Deploy to remote sites1$ hexo deploy
More info: Deployment