Carlos Galhano
Carlos Galhano

Reputation: 9

Office 32 to 64 VBA conversion

i'm trying to port code from VBA 32 (Excel) that doesn't work in Excel 2013 64bit. I need to read a HASP key and usually use a hasvb32.dll.

' The main hasp API function
Private Declare Sub hasp Lib "haspvb32.dll" (ByVal Service, ByVal seed, ByVal lpt, ByVal pass1, ByVal pass2, retcode1, retcode2, retcode3, retcode4 As Any)

' WriteHaspBlock function prepares memory for the WriteBlock service
Private Declare Sub WriteHaspBlock Lib "haspvb32.dll" (ByVal Service, Buff As Any, ByVal Length)

' ReadHaspBlock function prepares memory for the WriteBlock service
Private Declare Sub ReadHaspBlock Lib "haspvb32.dll" (ByVal Service, Buff As Any, ByVal Length)

have made the changes to:
' The main hasp API function
Private Declare PtrSafe Sub hasp Lib "haspvb32.dll" (ByVal Service, ByVal seed, ByVal lpt, ByVal pass1, ByVal pass2, retcode1, retcode2, retcode3, retcode4 As Any)

' WriteHaspBlock function prepares memory for the WriteBlock service
Private Declare PtrSafe Sub WriteHaspBlock Lib "haspvb32.dll" (ByVal Service, Buff As Any, ByVal Length)

' ReadHaspBlock function prepares memory for the WriteBlock service
Private Declare PtrSafe Sub ReadHaspBlock Lib "haspvb32.dll" (ByVal Service, Buff As Any, ByVal Length)

with no success. any idea? thanks

Upvotes: 1

Views: 428

Answers (1)

hnk
hnk

Reputation: 2214

If it's a 32-bit DLL (which it most likely is), there isn't much you can do to make it run in Office 64-bit.

If you've written it, you may recompile it using instructions given in this example. It'll give you a better sense of the parameters to be declared such as your code being Pointer-Safe, etc.

Excellent example and reference by Jonathan Lhost

https://sites.google.com/site/jrlhost/links/excelcdll

Upvotes: 1

Related Questions