Windows 10, 64 bit upgrade, crashing my code

dkkirk2000

Registered User.
Local time
Today, 06:12
Joined
Jan 27, 2017
Messages
16
Hello everyone,
The company decided to "upgrade" to windows 10/64 bit and now the below code gets stuck at the :confused: line. Can you help me?

thank you!


Option Compare Database
Option Explicit
Private Type WKSTA_USER_INFO_1
wkui1_username As LongPtr 'name of the user currently logged on to the workstation.
wkui1_logon_domain As LongPtr 'the domain name of the user account of the user currently logged on
End Type

Private Declare PtrSafe Function apiWkStationUser Lib "Netapi32" _
Alias "NetWkstaUserGetInfo" (ByVal reserved As LongPtr, ByVal Level As LongPtr, bufptr As LongPtr) As LongPtr

Private Declare PtrSafe Function apiStrLenFromPtr Lib "kernel32" _
Alias "lstrlenW" (ByVal lpString As LongPtr) As LongPtr
Private Declare PtrSafe Sub sapiCopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As LongPtr)
Public Function fNTUsername() As String
'*******************************************
'** NT ONLY Function **
'Purpose: Find NT Username or Domain name of current user
'Calls: NetWkstaUserGetInfo, RTLMoveMemory
'Inputs: None
'Returns: NT Username or Domain Name of Current User
'*******************************************
On Error GoTo ErrHandler
Dim lngRet As LongPtr
Dim lngPtr As LongPtr
Dim tNTInfo As WKSTA_USER_INFO_1

lngRet = apiWkStationUser(0&, 1&, lngPtr)
If lngRet = 0 Then
Call sapiCopyMemory(tNTInfo, ByVal lngPtr, LenB(tNTInfo))
If Not lngPtr = 0 Then
With tNTInfo
fNTUsername = fStringFromPtr(.wkui1_username)
End With
End If
End If
ExitHere:
Exit Function

ErrHandler:
fNTUsername = vbNullString
Resume ExitHere
End Function
Private Function fStringFromPtr(lngPtr As LongPtr) As String
Dim lngLen As LongPtr
Dim abytStr() As Byte
lngLen = apiStrLenFromPtr(lngPtr) * 2
If lngLen > 0 Then
:confused: ReDim abytStr(0 To lngLen - 1):confused:
Call sapiCopyMemory(abytStr(0), ByVal lngPtr, lngLen)
fStringFromPtr = abytStr()
End If
End Function ' End of modified code originally written by Dev Ashish
 
Would I be correct in assuming you are using a 64 bit Access?
 
that is correct!
 
We'll have to wait for someone with 64 bit Access then. I can't test it as I have 32 bit Access. Sorry.
 
I asked the Mods for assistance on this so they may know someone with 64 bit Access.
 

Users who are viewing this thread

Back
Top Bottom