I have two C application that can communicate via win32 IPC APIs (CreateFileMapping() etc.)
I have to replace client application with a Python application.
I have tried the following libraries on Python side.
import win32file, win32api
But this libraries does not have CreateFileMapping() functions.
I have tried also mmap.mmap() function but I could not observe any communication.
import mmap
sharedMemory = mmap.mmap(0, 512, "Local\SharedBuffer")
sharedMemory.write("AB")
I have also tried "GlobalSharedBuffer" and "SharedBuffer" as shared Memory names both two side.
#define SHARED_BUFFER_NAME ((LPCSTR)L"Local\SharedBuffer")
HANDLE bufferHandle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 512, SHARED_BUFFER_NAME);
// Create a map for accessing Shared Buffer
sharedBuffer = (char*)MapViewOfFile(bufferHandle, FILE_MAP_ALL_ACCESS, 0, 0, SHARED_BUFFER_SIZE);
memset(sharedBuffer, 0, SHARED_BUFFER_SIZE);
while (sharedBuffer[0] == 0);
while (1);
win32 APIs are not mandatory for me. I need only simple shared buffer between C and python application on Windows Machine.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…