Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    API - GetUserName, odd error message (XP/ O2003)

    Hi,

    Want to retrieve current users ID, the [username].

    Normally using the GetusernameA API call, but gets a cryptic error message, can someone please explain/suggest what to do?

    Run-time error 453, Can't find DLL entry point GetUsernameA in advapi32.dll

    I'm using this:
    Declare Function Getusername Lib "advapi32.dll" Alias "GetusernameA" (ByVal lpbuffer As String, nSize As Long) As Long

    Public Function System_GetCurrentUserName() As String
    Dim strName As String
    Dim lngCharacters As Long
    Dim lngReturn As Long

    strName = Space(255)
    lngCharacters = 255
    lngReturn = Getusername(strName, lngCharacters - 1)
    If lngReturn = 0 Then
    System_GetCurrentUserName = "Unable to retrieve current user name."
    Else
    System_GetCurrentUserName = Left(strName, lngCharacters)
    End If

    End Function
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: API - GetUserName, odd error message (XP/ O2003)

    The internal function names are case sensitive. You MUST use

    ... Alias "GetUserNameA" ...

    instead of

    ... Alias "GetusernameA" ...

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: API - GetUserName, odd error message (XP/ O2003)

    Oooops - Thanks Hans, guess that's the risk, when doing to much copy/paste... (big grin)
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •