Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
1.00/5 (12 votes)
See more:
C++
CString user,str;
	gethostname(host,201);
	str=host;
	TCHAR acUserName[100];
	DWORD nUserName = sizeof(acUserName);
         GetUserName(acUserName, &nUserName);
	user=acUserName;

Regards
N.GokulNath
Posted
Updated 2-Jan-11 23:39pm
v3
Comments
Abhinav S 3-Jan-11 0:41am    
Is this a problem or a solution?
If this is a solution, post it in the tips section.
Sandeep Mewara 3-Jan-11 0:55am    
Sounds like you missed the question out here!
Sergey Alexandrovich Kryukov 3-Jan-11 1:33am    
Well, no. Don't post it in Tips yet, improve first. Why hard-coded port, hard-code array size and fixed-size character array (you already use string class), what is GetUserName? Maybe, this is indeed a question in such a form? Get user name from what?
Sunasara Imdadhusen 5-Jan-11 1:49am    
Note clear!!

1 solution

DWORD nUserName = sizeof(acUserName);


Here must be;

DWORD nUserName = sizeof(acUserName) / sizeof(TCHAR);


:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900