Good morning.
I'm calling an API to get the execution path of my application (see code below).
Unfortunately, the result is not desired.
Ideas?
Ecosystem: Window10 64b + PB2019r2 + run in IDE
// code
Messaegbox('', go_prg.get_executionpath())
//Api
FUNCTION int GetModuleFileNameA(ulong hinstModule, REF string lpszPath, ulong cchPath) LIBRARY "kernel32"
//[Powerscript]
string ls_Path
unsignedlong lul_handle
ls_Path = space(1024)
lul_handle = Handle(GetApplication())
GetModuleFilenameA(lul_handle, ls_Path, 1024)
return ls_Path
Proper "External Function" declaration should be ....
FUNCTION uLong GetModuleFileName ( uLong lhModule, ref string sFileName, Integer inSize ) LIBRARY "KERNEL32.dll" ALIAS FOR "GetModuleFileNameW"
Also ... FYI: http://chrispollach.blogspot.com/2020/05/techtip.html
HTH Regards ... Chris
how about
FUNCTION uLong GetModuleFileName ( uLong lhModule, ref string sFileName, ulong inSize ) LIBRARY "KERNEL32.dll" ALIAS FOR "GetModuleFileNameW" ?
https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamew
Yes, the last parm can be either but technically your definition is better. PB just places the INT value in the lower bits of the Double Word. So the end result is the same for the size (length).
Regards ... Chris