Solved

How to get user log-in name? - for jhance

Posted on 1998-12-22
4
233 Views
Last Modified: 2010-08-05
hi,
in relation to the previous qn i asked,
can u pls guide me on how to return the user name in a char buffer? I need to pass this data to other functions and
I am facing difficulties converting it to char buffer.

char* GetLogin()
{
    NET_API_STATUS netStatus;
    WKSTA_USER_INFO_0 *buf;
   
    netStatus = NetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&buf);
    //wprintf(_T("Username is %s\n"), buf->wkui0_username);
    //NetApiBufferFree(buf);
    return buf->wkui0_username;
}


int main(int argc, TCHAR* argv[])
{
      char* buf = GetLogin();
      cout<<buf<<endl;
        return 0;
}


Thanks.
Andrea
0
Comment
Question by:tanmh
  • 3
4 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 0 total points
ID: 1180820
static char buff[256];
LPWKSTA_USER_INFO_0 pBuff = NULL;
NetWkstaUserGetInfo(NULL, 0, (LPBYTE*)&pBuff);
WideCharToMultiByte(CP_ACP, 0, (LPWSTR)pBuff->wkui0_username, -1, buff, sizeof buff, NULL, NULL);
return buff;
0
 
LVL 11

Expert Comment

by:alexo
ID: 1180821
OOps, sorry.  Didn't notice the "for jhance" part.  You can reject it if you want jhance to get the points (although the answer is correct...)
0
 

Author Comment

by:tanmh
ID: 1180822
hi alexo,
although it was for jhance but he didn't take up this question
and your answer is correct so it is only right that
I give you the marks.

Thanks.
Andrea
0
 
LVL 11

Expert Comment

by:alexo
ID: 1180823
Actually I see no reason in restricting questions to a single expert (unless, of course, if those are "dummy" questions to award points).
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question