Another way to achieve shared memory

zhaozj2021-02-16  51

Using: WinAPI CreateFilemapping, parameter is set to: 0 * fffffff; Description it is a shared memory instead of a file.

E.g:

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);

Second: Definition at the header file (.h): #iinclude wm_user_Message WM_USER 1

Definition: 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: // ourselves;

}

Remember to finally delete the handle (MyMapFile); CloseHandle (MyMapFile)

转载请注明原文地址:https://www.9cbs.com/read-27769.html

New Post(0)