Finding User names.....

This is a discussion on Finding User names..... within the C++ Programming forums, part of the General Programming Boards category; Hi, I was wondering if there is a way in c++ to find the user name of of someone who ...

  1. #1
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262

    Finding User names.....

    Hi, I was wondering if there is a way in c++ to find the user name of of someone who has logged onto a computer. I'm basically wondering if it is stored as a text document somewhere on the local drive, user drive or on the main hard disk.... I'm using windows XP pro if that helps. Cheers, twomers

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    If you're talking about the username (like the one ontop of the Start Menu on XP) then yes there is a way to get that. The function is most likely in windows.h, I don't know it off the top of my head.
    Sent from my iPadŽ

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    If you want to know the username of the current windows user, call GetUserName.

    Code:
    DWORD dwLength = 500;
    TCHAR tszName[500];
    
    GetUserName( tszName, &dwLength );
    
    printf( "%s", tszName );
    You will need to include "Windows.h" and maybe link to the lib specified in the link.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pass error before char
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-26-2006, 11:00 AM
  2. Replies: 5
    Last Post: 01-18-2006, 10:02 PM
  3. ~ User Input script help~
    By indy in forum C Programming
    Replies: 4
    Last Post: 12-02-2003, 05:01 AM
  4. Stopping a user from typeing.
    By knave in forum C++ Programming
    Replies: 4
    Last Post: 09-10-2001, 12:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21