CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: GetUserName

  1. #1
    Join Date
    Sep 1999
    Posts
    10

    GetUserName

    How can I use in MFC programming GetUserName method which is win32 command. I don't have had any luck getting username into CString.

    -Teemu


  2. #2
    Join Date
    Jul 1999
    Location
    Ahmedabad, India
    Posts
    30

    Re: GetUserName

    Hi Teemu,
    I just finish headache implementing this **** thing. GetUserName accept two parameters.Following Code will work for you:

    char userName[256];
    DWORD nameLength;

    .........


    nameLength = sizeof(userName);
    if (GetUserName(userName, nameLength) != 0) {
    // You have user name in buffer userName, Now you can move this value in CString variable.

    Good luck.
    --Sumit


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured