I'm trying to port some simple C++ code over to PB. It uses file-mapping, and according to POFFS2, nobody has used the OpenEvent() API call before!
Here is the code - very simple:
I was able to port it over, but the call to OpenEvent() from PB keeps returning %NULL - 0
Does anybody know why? Here is my port:
Is the win32api.inc declaration ok? -
Here is MS VC6's declaration:
Im using NT4 and Win2K so I have a feeling I should be calling the Unicode version of OpenEvent (which isn't defined)
Any help is much appreciated!
------------------
Here is the code - very simple:
Code:
HANDLE hEventGuard = OpenEvent(EVENT_ALL_ACCESS, FALSE, PB_EVENT_NAME); HANDLE hFileMapping = OpenFileMapping(FILE_MAP_READ, FALSE, PB_NAME); if(hEventGuard == NULL | | hFileMapping == NULL) { printf("Error: \n"); CloseHandle(hEventGuard); CloseHandle(hFileMapping); return; }
Does anybody know why? Here is my port:
Code:
%EVENT_ALL_ACCESS = &H001F0003 hEventGuard = OpenEvent(%EVENT_ALL_ACCESS, %FALSE, PB_EVENT_NAME) hFileMapping = OpenFileMapping(%FILE_MAP_READ, %FALSE, PB_NAME) STDOUT "hEventGuard=" & STR$(hEventGuard) 'always returns 0 STDOUT "hFileMapping=" & STR$(hFileMapping) 'also returns 0 because the call to OpenEvent failed CloseHandle hEventGuard CloseHandle hFileMapping
Code:
DECLARE FUNCTION OpenEvent LIB "KERNEL32.DLL" ALIAS "OpenEventA" (BYVAL dwDesiredAccess AS LONG, BYVAL bInheritHandle AS LONG, lpName AS ASCIIZ) AS LONG
Code:
WINBASEAPI HANDLE WINAPI OpenEventA( DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName ); WINBASEAPI HANDLE WINAPI OpenEventW( DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName ); #ifdef UNICODE #define OpenEvent OpenEventW #else #define OpenEvent OpenEventA #endif // !UNICODE
Any help is much appreciated!
------------------
Comment