0

I need the following to be compatible with 32bit and 64bit.

I know I need to use PtrSafe and change long to long ptr but have no idea what I am doing.

Option Explicit

Public Declare Function TzSpecificLocalTimeToSystemTime _
               Lib "Kernel32.dll" (ByRef lpTimeZone As TIME_ZONE_INFORMATION, _
                                   ByRef lpLocalTime As SYSTEMTIME, _
                                   ByRef lpUniversalTime As SYSTEMTIME) _
                                   As Long

Public Type TIME_ZONE_INFORMATION
    Bias As Long
    StandardName(31) As Integer
    StandardDate As SYSTEMTIME
    StandardBias As Long
    DaylightName(31) As Integer
    DaylightDate As SYSTEMTIME
    DaylightBias As Long
End Type

Private mudtTZI As TIME_ZONE_INFORMATION


Public Function LocalTimeToUTC(utcTime As Date) As Date
    Dim localTime As Date
    Dim dteFileTime As FILETIME
    Dim dteLocalSystemTime As SYSTEMTIME
    Dim dteSystemTime As SYSTEMTIME

End Function
Community
  • 1
  • 1

1 Answers1

2

Create the specific declaration dynamically for x86 or x64 machine. Refer to here for context. Something like this:

#If VBA7 Then
Private Declare PtrSafe Function TzSpecificLocalTimeToSystemTime _
               Lib "Kernel32.dll" (ByRef lpTimeZone As TIME_ZONE_INFORMATION, _
                                   ByRef lpLocalTime As SYSTEMTIME, _
                                   ByRef lpUniversalTime As SYSTEMTIME) _
                                   As Long
#Else
Public Declare Function TzSpecificLocalTimeToSystemTime _
               Lib "Kernel32.dll" (ByRef lpTimeZone As TIME_ZONE_INFORMATION, _
                                   ByRef lpLocalTime As SYSTEMTIME, _
                                   ByRef lpUniversalTime As SYSTEMTIME) _
                                   As Long
#End If
v-c0de
  • 142
  • 1
  • 3
  • 15