CryptoSys API Library Manual

VBA in 64-bit versions of Office

Note: As of version 6.20 all the required 32- and 64-bit declarations are included in the one file module basCryptoSys.bas.

To use the VBA functions in this API with a 64-bit version of Microsoft Office you need to use the "PtrSafe" attribute in a declaration statement as in this example:

Public Declare Function API_Version Lib "diCryptoSys.dll" () As Long   ' Original 32-BIT
Public Declare PtrSafe Function API_Version Lib "diCryptoSys.dll" () As Long   ' New 64-BIT

That is, add the keyword PtrSafe between Public Declare and Function. There are no other changes to make.

You can use the VBA7 conditional compilation constant, if you wish. For example.

#If VBA7 Then 
  Public Declare PtrSafe Function API_Version Lib "diCryptoSys.dll" () As Long
#Else 
  Public Declare Function API_Version Lib "diCryptoSys.dll" () As Long
#End If	

This is what we now do. In some IDEs, like the old VB6, one set may appear red. It's unsightly, but does not prevent compilation.

AFAWK there is no need to use the Win64 constant. You do not change any types to LongLong or LongPtr.

For more information, see the Microsoft Developer Network page Compatibility Between the 32-bit and 64-bit Versions of Office 2010.

[Contents] [Index]

[PREV: Visual Basic or Visual Basic: VB6 vs VB.NET...]   [Contents]   [Index]   
   [NEXT: General Programming Issues...]

Copyright © 2001-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-01-07T07:42:00Z.