Getting Windows user name

There is not much to write about it. Short code to get Windows user name. Quite interesting is declaration for 32bit and 64bit systems. Unfortunately I’ve forgot source of code.

'  Declaration for 32bit and 64bit systems
#If VBA7 Then
    Declare PtrSafe Function Get_User_Name Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, _
    nSize As Long) As LongPtr
#Else
    Declare Function Get_User_Name Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, _
    nSize As Long) As Long
#End If

Sub UserName()
' Run this macro first

MsgBox GetUserName
End Sub

Function GetUserName() As String
' This is used by GetUserName() to find the current user's
' name from the API

Dim lpBuff As String * 25

Get_User_Name lpBuff, 25
GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function

32 thoughts on “Getting Windows user name

  1. Pingback: hydroxychloroquine clinical trial results

  2. Pingback: what is hydroxychloroquine medicine

  3. Pingback: where to buy hydroxychloroquine walmart

  4. Pingback: lancet retracts hydroxychloroquine study

  5. Pingback: keto pasta

  6. Pingback: ivermectil samples for physicians office

  7. Pingback: ivermectin capsule 12mg

  8. Pingback: dapoxetine tablets us

  9. Pingback: anti mosquito infestations

  10. Pingback: capsule stromectol 6

  11. Pingback: deltasone for cold sores

  12. Pingback: stromectol gum infection

  13. Pingback: buy cialis online safely

  14. Pingback: can cialis pills be split in half

  15. Pingback: order cialis

  16. Pingback: cialis for sale in the philippines

  17. Pingback: cheapest way buy cialis

  18. Pingback: im dating a feminine gay man

  19. Pingback: 875 875 ivermectin ivermectin mg mg

  20. Pingback: ivermectin alcohol

  21. Pingback: ivermectin for parakeet mites

  22. Pingback: generic cialis pharmatize

  23. Pingback: generic viagra

  24. Pingback: best over the counter ed meds

  25. Pingback: buy viagra much

  26. Pingback: can order levitra online

  27. Pingback: cialis and viagra for sale

  28. Pingback: online casino beste online

  29. Pingback: otc sildenafil 100 mg tablets

Leave a Reply

Your email address will not be published. Required fields are marked *