Thread: Finding User names.....

  1. #1
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005

    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
    Out of scope
    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
    Hannover, Germany
    If you want to know the username of the current windows user, call GetUserName.

    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.

    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, 12:00 PM
  2. Replies: 5
    Last Post: 01-18-2006, 11:02 PM
  3. ~ User Input script help~
    By indy in forum C Programming
    Replies: 4
    Last Post: 12-02-2003, 06:01 AM
  4. Stopping a user from typeing.
    By knave in forum C++ Programming
    Replies: 4
    Last Post: 09-10-2001, 12:21 PM