0
votes

I'm trying currently to test inter process communication by using filemaps. My first program, which i shall call the producer, doesn't error on the following code which createsa file map and writes to it, as follows:

if (hnewEvent == NULL) { MessageBox(NULL, TEXT("error code: 1"), TEXT("testhere"), MB_OK); _tprintf(TEXT("Could not create file mapping object (%d).\n"), GetLastError()); return 1; }

Can anyone see anything obvious i'm missing?, as it's going straight over my head.

1
Name your mapping object something unique, just in case any other software is also using named file mappings. - Ben Voigt
hah, what a silly mistake. Turns out i was ending the handle in the first process before the second process could get hold of it. CloseHandle(hEvent); I took this out of the first process and it stopped the second one erroring. - Shane.C
Also, are both programs being run by the same user? At the same isolation level? - Ben Voigt
they're both on the same computer, in different visStud projects. i think i've solved THIS issue at hand, now just to get it to read the string correctly i'm passing between the two. - Shane.C
I think it's safer to duplicate the handle than using a named object. There's no rule upon how to name a named object in windows. - BlueWanderer

1 Answers

3
votes

Like all kernel objects, file mappings are deleted when the last handle is closed. Since your first program closes the handle right away, there is nothing for the second program to find. You must keep the handle open for as long as you want the mapping to exist.