OpenFileMapping between C++ and Fortran

OpenFileMapping between C++ and Fortran

Hi, Im trying to get a C++ and Fortran program to send each other data. I have used the http://msdn.microsoft.com/en-us/library/windows/desktop/aa366551(v=vs.85).aspx example successfully. Right now Im trying to port the "second process" to fortran code.

I'm not very expirienced in win32 programming let alone fortran so pardon my ignorance if any.

Here's the fortran side of things:

PROGRAM secondprocess

USE KERNEL32, only: OpenFileMapping, MapViewOfFile, FILE_MAP_ALL_ACCESS

INTEGER*4 hMapFile
INTEGER*4 pBuf
INTEGER*4 temp
CHARACTER(256) szName

szName = "Global\MyFileMappingObject"

hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, .FALSE., szName)
if(hMapFile == 0) then
write(*,*) "OpenFileMapping failed"
write(*,*) GetLastError();
else
pBuf = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 256)
end if

write(*,*) pBuf
write(*,*) szName

CALL sleep(2)

END PROGRAM secondprocess

When I run the program hMapfile fails, and i get an NaN error ("Not a Number" from what i've read)

I get the feeling that pointers should be involved, eg pBuf is declared as an integer yet i think it stores the memory location of the message.

Any ideas ?

5 post / 0 nuovi
Ultimo contenuto
Per informazioni più dettagliate sulle ottimizzazioni basate su compilatore, vedere il nostro Avviso sull'ottimizzazione.