利用:winapi CreateFileMapping,参数设为:0*FFFFFFFF;说明它是共享内存而不是文件。
例如:
myMapFile=CreateFileMapping((HANDLE) (0*FFFFFFFF),NULL,PAGE_READWRITE,0,9999,"recherFile");
if(myMapFile!=NULL) myMapFile=(char *)MapViewofFile(myMapFile,FILE_MAP_ALL_ACCESS,0,0,0);
else ShowMessage("myMapFile==NULL");
其次:在头文件(.h)定义:#Iinclude WM_USER_MESSAGE WM_USER+1
定义:MESSAGE void WMUSER(TMessage msg);
BEGIN_MESSAGE_MAP
MAESSAGE_HANDLER(WM_USER,TMEessage,WmUser);
END_MESSAGE_MAP (TForm);
message void TForm1::WmUser(TMessage Msg)
{
file://自己的函数;
}
切记到最后要删除句柄哦(UnmapviewofFile(myMapFile);CloseHandle(myMapFile)
本文地址:http://com.8s8s.com/it/it29806.htm