I wanted to an alternate function for users with Windows earlier than XP SP1. Looked at PB command CODEPTR, but that only returns pointer to proc that it is in. Looking in the PSDK I found GetModuleHandle, which when passed a nul pointer gives handle to the module it is called from. Passing a zero gave String expected error when compiled. Passing $NUL returned a zero handle.
Looking in Win32API.inc makes problem obvious. My fix was to make another declare for GetModuleHandle without changing the Win32API.inc file (see code).
It works, I'm happy. Then got to thinking maybe the Win32API.inc was out of date and I wouldn't have to use the modified declare. I was surprised that all the file dates in Win32API.zip in PB download section are 1 Feb 2005! (though file sizes don't match)
My question Really no changes since 2005, or are file dates forced back to 1 Feb 2005? Why different file sizes if no changes?
Cheers,
Looking in Win32API.inc makes problem obvious. My fix was to make another declare for GetModuleHandle without changing the Win32API.inc file (see code).
It works, I'm happy. Then got to thinking maybe the Win32API.inc was out of date and I wouldn't have to use the modified declare. I was surprised that all the file dates in Win32API.zip in PB download section are 1 Feb 2005! (though file sizes don't match)
My question Really no changes since 2005, or are file dates forced back to 1 Feb 2005? Why different file sizes if no changes?
Code:
'from Win32API.inc dated 1 Mar 2005: 'declare function GetModuleHandle lib "KERNEL32.DLL" _ alias "GetModuleHandleA" _ ' (lpModuleName as asciiz) as dword 'Modified declare in my dot bas to avoid duplicate name error: declare function GetModuleHandleDY lib "KERNEL32.DLL" _ alias "GetModuleHandleA" _ (byval lpModuleName as asciiz pointer) as dword '----------------------------------------------------------------------- function FakeSystemTimes alias "FakeSystemTimes" (byref I as filetime, _ byref K as filetime, _ byref U as filetime) _ export as long 'will have other code to populate the 3 FileTime UDTs msgbox "Made it to Fake" end function '----------------------------------------------------------------------- function pbmain() local hLib as dword 'handle for Kernel32.dll PBFormsInitComCtls (%ICC_WIN95_CLASSES or %ICC_DATE_CLASSES or _ %ICC_INTERNET_CLASSES) hLib = LoadLibrary ("Kernel32.dll") if hLib then ' 'rem next line to force error 'gpGetSystemTimes = GetProcAddress(hLib, "GetSystemTimes") if gpGetSystemTimes = 0 then 'error, not XP SP1 or later gpGetSystemTimes = GetProcAddress(GetModuleHandleDY(0), _ "FakeSystemTimes") gpGetTickCount = GetProcAddress(hLib, "GetTickCount") 'used in fake 'msgbox str$(GetModuleHandle(0)) 'msgbox str$(gpGetSystemTimes) 'exit function end if else 'error, can't load Kernel32.dll (unlikely, but bullet proof) function = -2 exit function end if ShowDIALOG1 %HWND_DESKTOP FreeLibrary(hLib) end function
Comment