32-bit naar 64-bit macro

Status
Niet open voor verdere reacties.

ColdDeath

Gebruiker
Lid geworden
7 nov 2013
Berichten
63
Hallo,

Ik kom op het internet wel vaker macro's tegen voor het programma die ik wil gebruiken. Maar de codes zijn vaak geschreven voor een 32-bit systeem.

Is er een makkelijke manier om een 32-bit macro om te schrijven c.q. converteren naar een 64-bit macro?

Compile error:

The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with the PrtSafe attribute.

Code:
Option Explicit

Public Const SCS_32BIT_BINARY = 0
Public Const SCS_64BIT_BINARY = 6

Global Const SWP_NOMOVE As Long = 2
Global Const SWP_NOSIZE As Long = 1
Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Global Const HWND_TOPMOST As Long = -1
Global Const HWND_NOTOPMOST As Long = -2

Public Declare Function GetBinaryType Lib "kernel32" Alias "GetBinaryTypeA" (ByVal sFileName As String, ByRef BinType As Long) As Long

Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

De macro is geschreven voor SolidWorks.


Met vriendelijke groet,
Willie
 
Daarvoor dienen de functie declaraties te worden aangepast. ik kan het zo niet testen maar probeer deze maar eens. Die kan dan in zowel Office 32-bit als 64-bit werken:
Code:
Option Explicit

Public Const SCS_32BIT_BINARY = 0
Public Const SCS_64BIT_BINARY = 6

Global Const SWP_NOMOVE As Long = 2
Global Const SWP_NOSIZE As Long = 1
Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Global Const HWND_TOPMOST As Long = -1
Global Const HWND_NOTOPMOST As Long = -2

#If Win64 Then
Public Declare PtrSafe Function GetBinaryType Lib "kernel32" Alias "GetBinaryTypeA" (ByVal sFileName As String, ByRef BinType As Long) As Long
Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

#Else
Public Declare Function GetBinaryType Lib "kernel32" Alias "GetBinaryTypeA" (ByVal sFileName As String, ByRef BinType As Long) As Long

Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If
 
Laatst bewerkt:
Oké, dus om het te converteren naar 64 bit moet:

Code:
 Declare Function

Omgezet worden naar:

Code:
 Declare PtrSafe Function


That's it?
 
Grof gezegd is dat inderdaad zo maar maar het kan ook zijn dat je tevens een As Long in de parameters moet wijzigen in As LongPtr.
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan