Update Shared memory Structure [message #48435] |
Fri, 14 April 2006 09:57 |
mtrutledge
Messages: 4 Registered: January 2006
|
Junior Member |
|
|
I have a c++ application that is using callable IDL to start a runtime
application. I need that runtime application to send back a result code
so my c++ app can handle to result code appropriatly. I am using shared
memory to accomplish this. IDL can read the strcuture from the shared
memory that was creaetd but it cant update that structure. Here is
basically what I am doing in C++:
typedef struct _IDL_RESULT
{
int m_nResultCode;
} IDLRESULT, *LPIDLRESULT;
LPVOID FileQueueView::CreateSharedMemory()
{
// Create a file mapping of shared memory space in the paging file
this->m_hSharedMemory = CreateFileMapping((HANDLE)0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, 0x1000, "IDL_RESULTS");
// Check to see if we received a handle to the file mapping
if(this->m_hSharedMemory == NULL)
{
TRACE(_T("ERROR -- FileQueueView::CreateSharedMemory - Unable to
allocate memory. Error: %d.\n"), GetLastError());
CloseHandle(this->m_hSharedMemory);
this->m_hSharedMemory = NULL;
}
// Create a view of the shared memory so we can query it after IDL
returns
return MapViewOfFile(this->m_hSharedMemory, FILE_MAP_WRITE, 0, 0,
sizeof(IDLRESULT));
}
FileQueueView::CallIDL()
{
LPIDLRESULT results = (LPIDLRESULTS)CreateSharedMemory();
if(results)
results->m_nResultCode = -1;
IDL_ExecuteRuntime("MyApp.sav"); // This displays -1
TRACE(_T("SHARED MEMORY RESULTS: %d\n"), results->m_nResultCode); //<-
this still equals -65536
}
Here is what IDL is doing:
pro main
; Get the file name
sFileName = GETENV('IDL_TMP_DCM')
shmTemplate = {IDLRESULT, m_nResultCode:-2} ; This must mirror the
_IDL_RESULT structure in the C++ Batch Processor App
a = SHMDEBUG(1)
SHMMAP, GET_NAME=shmIdlResults, TEMPLATE=shmTemplate, TYPE=3,
OS_HANDLE='IDL_RESULTS'
IDLRESULT = SHMVAR(shmIdlResults, TEMPLATE=shmTemplate)
res = dialog_message(string(IDLRESULT.m_nResultCode)) ; This displays
-1. Which is the correct value
IDLRESULT.m_nResultCode = 0
end
Why is the result code in the shared memory not updating?
Matt
|
|
|