comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Update Shared memory Structure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Update Shared memory Structure [message #48435] Fri, 14 April 2006 09:57
mtrutledge is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Map Projection Woes
Next Topic: Re: Finding a value in a array efficiently

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:04:26 PDT 2025

Total time taken to generate the page: 0.00504 seconds