适用于32位和64位的Ptrsafe

时间:2020-10-26 12:53:03

标签: vba 32bit-64bit

好..完全是新手,可能太老了,甚至无法理解其中的一些内容!我需要遵循才能与32bit和64bit兼容,我知道我需要使用PtrSafe并长时间更改为长ptr,但不知道我在做什么...任何帮助。

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

1 个答案:

答案 0 :(得分:2)

为x86或x64计算机动态创建特定的声明。有关上下文,请参见here。像这样:

#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
相关问题