VBA 32 / 64 bit, long / longptr
Mario Nestelberger
Gesendet: 13.03.23 15:07
Betreff: VBA 32 / 64 bit, long / longptr


Member

Beiträge: 41
25
Hallo,

ich habe mich in die Thematik schon länger eingelesen (aber bin nicht schlau geworden), da ich heute eine neue Funktion umschreiben sollte (OemToCharA) stellt sich mir wieder die Frage (Ja, ich habe von APIs zu wenig Ahnung):

Warum einmal LongPtr und dann doch wieder Long wie bei 32 bit - 2 Beispiele:


#If Win64 Then
Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nshowcmd As Long) As LongPtr
#Else
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nshowcmd As Long) As Long

#End If


bzw. funktioniert nur als Long in 64 bit:

#If Win64 Then
Public Declare PtrSafe Function GetActiveWindow Lib "user32" () As Long
#Else
Public Declare Function GetActiveWindow Lib "user32" () As Long
#End If

lg
Mario
Top of the page Bottom of the page