Using a structure as shared memory
Hi:
Firstly, I apologise if thi is the wrong group, but I'm hoping someone can
help:
I am currently working on a project that needs to use a structure as a
shared memory block between processes. The structure is defined as follows:
struct SATreeviewInfo {
IAccessible* TreeviewAccessible;
VARIANT VarObject;
VARIANT VarObjectState;
HWND TreeviewWindow;
TV_ITEM CurrentItem;
LPWSTR Text[1024];
};
I have then declared a variable in a namespace (the structure is declared
inside this namespace also:
extern SATreeviewInfo TreeviewInfo;
The code for mapping this structure in to the process is as follows:
//Create the file mapping and event objects for treeviews.
HTreeviewMSAAMapFile =CreateFileMapping( INVALID_HANDLE_VALUE, NULL,
PAGE_READWRITE, 0, sizeof(SATreeviewInfo), TEXT("TreviewMapFile"));
The code tomap the structure is:
TreeviewInfo =(SATreeviewInfo)MapViewOfFile(HTreeviewMSAAMapFile, NULL, 0,
0, 0);
The error I obtain when trying to compile is:
1>c:\work\serotek\libserotek\treeview.cpp(26) : error C2440: 'type cast' :
cannot convert from 'LPVOID' to 'Treeview::SATreeviewInfo'
1> No constructor could take the source type, or constructor overload
resolution was ambiguous
Could someone tell me why the problem lies within this code, as I don't
think I am using a class--it's defined as a structure. What if any is the
fix.
Help gratefully apreciated.
Sean.