在开发软件的过程中,经常会遇到在进程之间共享数据的需求。 例如,a进程生成计算数据,b进程生成显示数据的图形。 这种开发方式可以将一个大程序分成独立的小程序,提高软件的成功率,适合与团队一起开发,加快软件的开发速度。 使用文件映射共享数据吧。 首先,使用函数CreateFileMapping创建要共享的文件数据句柄,然后使用MapViewOfFile获取共享内存地址,然后使用OpenFileMapping函数在其他进程中打开共享文件的名称函数CreateFileMapping、MapViewOfFile声明如下: winbaseapi _ _ outhandlewinapicreatefilemappinga (_ inhandlehfile,_ in _ optlpsecurity _ attributeslpfilemappingatringatritrion __in DWORD dwMaximumSizeHigh,_ _ in dword dwmaximumsizehigh winbaseapi _ outhandlewinapicreatefilemappingw (_ inhandlehfehfiler _ in _ optlpsecurity _ attributeslpfilemappinng _ _ in dword dwmaximumsizehigh,__in DWORD dwMaximumSizeLow,_ _ in _ # ifdef unicode # definecreatefilemappingcreatefilemappingw # else # definecreatefilemappingcreatefilemappinga # endif /! unicodewinbaseapi _ _ outlpvoidwinapimapviewoffile (_ inhandlehfilemappingobject,__in DWORD dwDesiredAccess,___ ) __in DWORD dwFileOffsetLow,__in SIZE_T dwNumberOfBytesToMap;hFile是用于创建共享文件的句柄。lpFileMappingAttributes是文件共享的属性。flProtect是在文件映射时读写文件的属性。dwMaximumSizeHigh是文件共享的高位字节。dwMaximumSizeLow是文件共享的低位字节。lpName是共享文件对象名称。hFileMappingObject是共享文件对象。dwDesiredAccess是文件共享属性。dwFileOffsetHigh是文件共享区域的偏移地址。dwFileOffsetLow是文件共享区域的偏移地址。dwNumberOfBytesToMap是共享数据长度。 函数的调用示例是#001//文件共享。 #002//打开发夹萝莉2007/10/27 QQ:9073204深圳#003voidfilemapping(#004 ) #002//共享文件对象。 显示3358 www.Sina.com/http://www.Sina.com/# 008 if (m _ hmap file ) ) #009 { #010 //共享文件数据。 3358 www.Sina.com/http://www.Sina.com/# 013 outputdebugstring (lpmapaddr ); # 014 } # 015创建else # 016 { # 017//共享文件。 将数据复制到3358 www.Sina.com/http://www.Sina.com/# 020 # 021//共享文件中。 #022 LPTSTR lpMapAddr=(LPTSTR ) mapviewoffile(m_hmapfile,FILE_MAP_ALL_ACCESS,# 0230,0,0 ); # 024 STD :3360 wstring strtest (_ t ) ' testfilemap ' ); #025wcscpy(lpmapaddr,strTest.c_str ) ); # 026 # 027 flushviewoffile (lpmapaddr,strtest.length((1) ); #028 } #029}
1 .使用wix安装工具http://edu.csdn.net/course/detail/5207
2 .俄罗斯方块游戏开发
3358 edu.csdn.net/course/detail/5110
3.boost库入门基础
3358 edu.csdn.net/course/detail/5029
4.Arduino入门基础
3358 edu.csdn.net/course/detail/4931
5.Unity5.x游戏基础入门
3358 edu.csdn.net/course/detail/4810
6.tensor流API攻略
3358 edu.csdn.net/course/detail/4495
7.TensorFlow入门基本教程
3358 edu.csdn.net/course/detail/4369
8. C标准模板库入门到精通
3358 edu.csdn.net/course/detail/3324
9 .与资深初学者学习C
3358 edu.csdn.net/course/detail/2901
10 .从私人生活中学习python
3358 edu.csdn.net/course/detail/2592
11 .在VC 2015上学习使用tinyxml库
3358 edu.csdn.net/course/detail/2590
12.windows上的SVN版本控制和实战
3358 edu.csdn.net/course/detail/2579
13.Visual Studio 2015开发c程序的基本使用
3358 edu.csdn.net/course/detail/2570
14 .在VC 2015上使用protobuf协议
3358 edu.csdn.net/course/detail/2582
15 .在VC 2015上学习使用MySQL数据库
3358 edu.csdn.net/course/detail/2672
再分享一下我老师大神的人工智能教程吧。 我的零度基点! 容易理解! 幽默感! 也有黄色的段子! 我希望你也加入我们的人工智能团队! https://blog.csdn.net/jiangjun show