I've just encountered another case that makes a perfect example of such API functions with UDT parameters. Many WinRT methods use a DateTime structure which is defined as Int64. At first I thought that is compatible with VB6's Date type but that quickly turned up not to be the case so I had to use Currency instead. That needs to go through a bunch of conversions to make a usable Date out of it:
Declaring everything As Any is very handy here.Code:Private Declare PtrSafe Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As Any, lpSystemTime As Any) As BOOL Private Declare PtrSafe Function SystemTimeToTzSpecificLocalTimeEx Lib "kernel32" (lpTimeZoneInformation As Any, lpUniversalTime As Any, lpLocalTime As Any) As BOOL Private Declare PtrSafe Function SystemTimeToVariantTime Lib "oleaut32" Alias "#184" (lpUniversalTime As Any, pvVariantTime As Any) As BOOL Private Function ToDate(cDate As Currency) As Date Dim SysTime As SYSTEMTIME If FileTimeToSystemTime(cDate, SysTime) Then If SystemTimeToTzSpecificLocalTimeEx(ByVal vbNullPtr, SysTime, SysTime) Then SystemTimeToVariantTime SysTime, ToDate End Function
P.S. I've written another lengthy reply on the previous page (at the bottom)!





Reply With Quote