PDA

View Full Version : sharing Memory between process (visual c++ application and Qt application )



hassenman
6th January 2010, 11:09
Hi all,

I was wondering if memory could be easily shared between application created within visual c++ environment and Qt ?
i'm already sharing memory between two visual c++ applications using CreateFileMapping and want to use Qt to get data from that shared memory.

In few words, i need to send data from a console c++ application (visual c++) to a Qt application ... whats is the fastest way to achieve that

Best Regards,
Hassenman

zuck
6th January 2010, 12:54
QSharedMemory ;)

hassenman
6th January 2010, 14:32
QSharedMemory ;)

Thanks zuck, i successfully used QSharedMemory between two Qt applications. what i'm looking for is trasferring data from a visual c++ application to a Qt application ...
More explicitly, how to attach the two memory segments ...

In the visual c++ side i'm implementing shared memory using :

m_hSharedMemoryFile = CreateFileMapping((HANDLE)0xFFFFFFFF,
NULL,
PAGE_READWRITE,
0/*dwMaximumSizeHigh*/,
dwNumberOfBytesToMap/*dwMaximumSizeLow*/,
csName.GetBuffer(0));

And in the Qt side i'm using QSharedMemory. Both methods are working alone. (i.e. data trasfer from visual c++ to visual c++ and from Qt to Qt ) but not from visual c++ to Qt or from Qt to visual c++

I think i'm not using the same mechanism in the 2 sides. (Using FileMapping from visual c++ and semaphre from Qt)

Any ideas ?


Rgards,
Hassen

wysota
6th January 2010, 16:55
See how QSharedMemory is implemented and use the same mechanism in your visual c++ code.