[Israel.pm] GPF when running GetModuleFileName()

Nahum Cohen nahum.cohen at gmail.com
Tue Sep 20 22:10:52 PDT 2005


Hi,
 
 I'm using Win32::API::Prototype to run GetModuleFileName().
 Does anyone knows why I get a GPF when running this code:
 
 ApiLink( 'kernel32.dll', 'DWORD GetModuleFileName (HMODULE hModule,
LPTSTR lpFilename, DWORD nSize)' ) || die;
 $nSize = 256;
 $lpFilename = NewString ($nSize);
 GetModuleFileName (NULL, $lpFilename, $nSize);
 print "The module file name is: \"$lpFilename\"\n";
 
 while this example (from Win32::API::Prototype documentation) works fine:
 
 ApiLink( 'kernel32.dll', 'DWORD GetCurrentDirectory (DWORD
nBufferLength, LPTSTR lpBuffer)' ) || die;
 $nBufferLength = 256;
 $lpBuffer = NewString ($nBufferLength);
 GetCurrentDirectory ($nBufferLength, $lpBuffer );
 print "The current directory is: \"$lpBuffer\"\n";
 
 Thanks,
 Nahum




More information about the Perl mailing list