Click here to Skip to main content
15,895,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi folks,

I am trying to implement GetUserName function in an MFC app but was given an error that "GetUserNameA' : function does not take 2 arguments".

Below is the snippet.

#define INFO_BUFFER_SIZE 32767
TCHAR  infoBuf[INFO_BUFFER_SIZE];
DWORD  bufCharCount = INFO_BUFFER_SIZE;
GetUserName(infoBuf, &bufCharCount);


Thanks.
Posted
Updated 14-Aug-10 23:57pm
v2
Comments
Dalek Dave 15-Aug-10 5:58am    
Minor Edit for Presentation.

Well, it's calling the ansi version of the function, and you're using a buffer of type TCHAR. Try changing it to a char type ans see if that works...
 
Share this answer
 
According to MSDN[^] it does; are you sure it has not been redefined somewhere?
 
Share this answer
 
Hi John,

Have tried your suggestion, but still doesn't resolve the error. And Richard, have not redefined it anywhere else.

Any other possible solution please.

Thanks.
 
Share this answer
 
Comments
#realJSOP 15-Aug-10 15:08pm    
Are you absolutely sure you don't have it re-implemented in your app? Just to make sure, precede the method name with it's namespace and see if it works then...
Try to place your mouse cursor at the function in your code,
then click by the right mouse button and select "Go to definition" -
to see the declaration :)

As the second step -
you could try to find the "GetUserName" string
by the MS VS tool "Find in files" (that is nearly the Linux' grep) -
through the files of your Windows 7 SDK directory -
to see the declaration :)
 
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