Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Visual Basic 2003 and Later _ Lock Workstation In 64-bit Access

Posted by: USMCdBA Dec 23 2017, 02:13 PM

Hello All,
Just got upgraded to 64-Bit Access 2016 and have been converting all my functions to PtrSafe. Great help found at http://www.UtterAccess.com/forum/index.php?showtopic=2045872&hl=PtrSafe+Access+2016 Dated 10/16/2017 from bowlesj (THANKS!). I have one function left that refuses to compile under 64-Bit. It is a lock work station function I have used for years with a form button On Click event.



Private Declare Function LockWorkStation Lib "C:\Windows\System32_user32.dll" ()As Long


Private Sub cmdLock_Click()

LockWorkStation

End Sub




This all works as intended in 32-Bit: Click the button and your workstation is locked --just like hitting Ctrl+L .
Not so much in 64-Bit. .

Private Declare PtrSafe Function LockWorkStation Lib "C:\Windows\System32_user32.dll" () As Long


Just inserting the PtrSafe keyword does not make it work -- so there must be an equivalent 64-Bit function somewhere...but by what name and in what dll file?

I also found this one that doesn't like 64-Bit environments.
SendMessage hwndActiveControl, WM_VSCROLL, IIf(Count < 0, SB_LINEUP, SB_LINEDOWN), 0&


Any ideas would be appreciated. Advanced thanks for considerations!

KDP.

Posted by: DanielPineault Dec 23 2017, 03:18 PM

This works fine for me

CODE
#If VBA7 Then
    'x64 Declarations
    Private Declare PtrSafe Function LockWorkStation Lib "user32.dll" () As Long
#Else
    'x32 Declaration
    Private Declare Function LockWorkStation Lib "user32.dll" ()As Long
#End If

Public Sub LockStation()
    LockWorkStation
End Sub


I notice you use and underscore in System32_user32.dll, shouldn't that be a \ ? FWIW, I never hard code the path.