苏州大学操作系统概念第三章剖析.ppt
文本预览下载声明
例子-主程序 #include stdafx.h #include windows.h #include stdio.h #include conio.h #include tchar.h #define BUF_SIZE 256 TCHAR szName[]=TEXT(MyFileMappingObject111); TCHAR szMsg[]=TEXT(Message from first process.); int _tmain() { HANDLE hMapFile; LPCTSTR pBuf; hMapFile = CreateFileMapping( INVALID_HANDLE_VALUE, // use paging file NULL, // default security PAGE_READWRITE, // read/write access 0, // maximum object size (high-order DWORD) BUF_SIZE, // maximum object size (low-order DWORD) szName); // name of mapping object 例子-主程序 pBuf = (LPTSTR) MapViewOfFile(hMapFile, // handle to map object FILE_MAP_ALL_ACCESS, // read/write permission 0, 0, BUF_SIZE); CopyMemory((PVOID)pBuf, szMsg, (_tcslen(szMsg) * sizeof(TCHAR))); _getch(); UnmapViewOfFile(pBuf); CloseHandle(hMapFile); return 0; } 例子-子程序 #include stdafx.h #include windows.h #include stdio.h #include conio.h #include tchar.h #pragma comment(lib, user32.lib) #define BUF_SIZE 256 TCHAR szName[]=TEXT(MyFileMappingObject111); int _tmain() { HANDLE hMapFile; LPCTSTR pBuf; hMapFile = OpenFileMapping( FILE_MAP_ALL_ACCESS, // read/write access FALSE, // do not inherit the name szName); // name of mapping object 例子-子程序 pBuf = (LPTSTR) MapViewOfFile(hMapFile, // handle to map object FILE_MAP_ALL_ACCESS, // read/write permission 0, 0, BUF_SIZE); MessageBox(NULL, pBuf, TEXT(Process2), MB_OK); UnmapViewOfFile(pBuf); CloseHandle(hMapFile); return 0; } * 剪帖板(Clipboard) 当进程间的复杂信息交流需要约定交流信息的格式。剪帖板就是Windows 提供的一种信息交流方式,可增强进程的信息交流能力。 Windows 提供了一组相关的API来完成应用进程与剪帖板间的格式化信息交流。 当执行复制操作时,应用程序将选中的数据以标准的格式或者应用程序定义的格式放到剪贴板中,然后其他的应用程序可以
显示全部