Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Windows useraccount
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MIdas0036




PostPosted: Fri Jan 11, 2008 4:58 pm   Post subject: Windows useraccount

is there a way i can get VB to call windows useraccounts to get the username and display it in a program (Or Game)
Sponsor
Sponsor
Sponsor
sponsor
OneOffDriveByPoster




PostPosted: Fri Jan 11, 2008 8:13 pm   Post subject: Re: Windows useraccount

Not sure if this is what you are looking for:
http://vbcity.com/page.asp?f=howto&p=system_username
MIdas0036




PostPosted: Sun Jan 13, 2008 11:42 am   Post subject: Re: Windows useraccount

i went to that link did not work for me what i am trying to do is get VB 6 to go into the computer and get the name of the user and display it in a program Very Happy
OneOffDriveByPoster




PostPosted: Sun Jan 13, 2008 12:06 pm   Post subject: Re: Windows useraccount

MIdas0036 @ Sun Jan 13, 2008 11:42 am wrote:
i went to that link did not work for me what i am trying to do is get VB 6 to go into the computer and get the name of the user and display it in a program Very Happy
How did it not work? Compile error? Did not get a name back? Crash? Gibberish?
MIdas0036




PostPosted: Wed Jan 16, 2008 12:51 pm   Post subject: Re: Windows useraccount

No Name was returned if you can get the code to work that would help me alot. BooHoo
OneOffDriveByPoster




PostPosted: Wed Jan 16, 2008 5:47 pm   Post subject: Re: Windows useraccount

MIdas0036 @ Wed Jan 16, 2008 12:51 pm wrote:
No Name was returned if you can get the code to work that would help me alot. BooHoo
This is what I got...
VisualBASIC:
    Declare Function GetUserNameA Lib "advapi32.dll" Alias _
        "GetUserNameA" (ByVal lpBuffer As String, _
        ByRef nSize As Integer) As Integer

    Public Function GetUserName() As String
        Dim retval As Integer
        Dim username As String
        Dim size As Integer
        username = Space$(255)
        size = 255  'Gets us usernames up to 254 characters long
        retval = GetUserNameA(username, size)
        If retval <> 0 Then
            GetUserName = Left$(username, size - 1)
        Else
            GetUserName = "<unknown>"
        End If
    End Function
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: