Results 1 to 3 of 3
  1. #1
    Jaik is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Aug 2016
    Posts
    33

    MouseHook 32bit to 64 bit conversion


    Code:
    Option Compare Database
    Option Explicit
    
    
    #If VBA7 Then
    Private Declare PtrSafe Function LoadLibrary Lib "kernel32" _
    Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
    #Else
    Private Declare Function LoadLibrary Lib "kernel32" _
    Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
    #End If
    
    
    #If VBA7 Then
    Private Declare PtrSafe Function FreeLibrary Lib "kernel32" _
    (ByVal hLibModule As Long) As Long
    #Else
    Private Declare Function FreeLibrary Lib "kernel32" _
    (ByVal hLibModule As Long) As Long
    #End If
    
    
    #If VBA7 Then
    Private Declare PtrSafe Function StopMouseWheel Lib "MouseHook" _
    (ByVal hwnd As Long, ByVal AccessThreadID As Long, _
    Optional ByVal bNoSubformScroll As Boolean = False, Optional ByVal blIsGlobal As Boolean = False) As Boolean
    #Else
    Private Declare Function StopMouseWheel Lib "MouseHook" _
    (ByVal hwnd As Long, ByVal AccessThreadID As Long, _
    Optional ByVal bNoSubformScroll As Boolean = False, Optional ByVal blIsGlobal As Boolean = False) As Boolean
    #End If
    
    
    #If VBA7 Then
    Private Declare PtrSafe Function StartMouseWheel Lib "MouseHook" _
    (ByVal hwnd As Long) As Boolean
    #Else
    Private Declare Function StartMouseWheel Lib "MouseHook" _
    (ByVal hwnd As Long) As Boolean
    #End If
    
    
    #If VBA7 Then
    Private Declare PtrSafe Function GetCurrentThreadId Lib "kernel32" () As Long
    #Else
    Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
    #End If
    ' Instance returned from LoadLibrary call
    Private hLib As Long
    I am trying to convert 32bit code to 64bit code, but I do not know if I wrote wrong code, or if dll file is not correct.
    If this code looks right, where can I download the dll file for 64 bit?

    Thank you!

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    both use the same dll - the difference is in what is returned or in the parameters - 32bit has longs, 64bit has longlong, whilst longptr will convert to long or longlong as necessary. See this link for a more detailed explanation. In particular take note of using the Win64 constant as well/instead which may be a requirement for you.

    https://msdn.microsoft.com/en-us/lib...ffice.14).aspx

    included in the above is this link for troubleshooting compatibility issues

    https://technet.microsoft.com/en-us/...ffice.14).aspx



    hwnd's are pointers so you should change these.

    So far as I am aware you cannot write something in 32bit office and compile to .accde as 64bit code to run on 64bit office/access runtime, you need 64bit access full version to do the compilation.

    Not all longs need to be converted to longlongs for 64 bit, so it is always a good idea to lookup the function you are using and understand the parameters and value returned to decide whether or not to convert it to longlong.

  3. #3
    Jaik is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Aug 2016
    Posts
    33
    Sorry for the late reply. Thanks a lot!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Running VBA code as 32bit in acces 2013 x64
    By vinaximus in forum Programming
    Replies: 4
    Last Post: 09-01-2015, 04:22 PM
  2. 32bit 64bit / vba vba7 (which am I running?)
    By markjkubicki in forum Programming
    Replies: 1
    Last Post: 04-08-2014, 10:50 PM
  3. Replies: 1
    Last Post: 12-31-2012, 12:43 PM
  4. Connect 64bit To 32bit Through ODBC, SQL Server 2008
    By 54.69.6d.20 in forum SQL Server
    Replies: 6
    Last Post: 10-08-2012, 06:14 AM
  5. mousehook.dll again eh?
    By niak32 in forum Forms
    Replies: 0
    Last Post: 12-17-2009, 09:23 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums