Ms access fOSUserName x64 ve x86 çalıştırma

fOSUserName() office X64 AND X86 versionda çalıştırma

 

Option Compare Database

Option Explicit

‘Private Declare Function apiGetUserName Lib “advapi32.dll” Alias “GetUserNameA” (ByVal lpBuffer As String, nSize As Long) As Long

#If VBA7 Then

Private Declare PtrSafe Function apiGetUserName Lib “advapi32.dll” Alias _

“GetUserNameA” (ByVal lpBuffer As String, nSize As Long) As Long

#Else

Private Declare Function apiGetUserName Lib “advapi32.dll” Alias _

“GetUserNameA” (ByVal lpBuffer As String, nSize As Long) As Long

#End If

 

Function fOSUserName() As String

On Error GoTo fOSUserName_Err

Dim lngLen As Long, lngX As Long

Dim strUserName As String

strUserName = String$(254, 0)

lngLen = 255

lngX = apiGetUserName(strUserName, lngLen)

If lngX <> 0 Then

fOSUserName = Left$(strUserName, lngLen – 1)

Else

fOSUserName = “”

End If

fOSUserName_Exit:

Exit Function

fOSUserName_Err:

MsgBox Error$

Resume fOSUserName_Exit

End Function

1 Görüntülendi.

Bunları da sevebilirsiniz