为什么我用GetUserName(char*,unsigned long*),返回值总是0?
解决方案 »
- 如何去除连接的时候的Automatically linking with XTP9601Libd.dll
- 请问在dll中如何捕捉WM_DEVICECHANGE消息
- 求助:关于音频压缩软件程序设计
- 如何用鼠标精确定位插入符的位置!重写edit控件
- 书上的一个添加ie工具栏按钮的例子,觉得不妥,各位给点意见
- 求算法练习~~
- striking兄弟请进来
- 如何用MSCOMM控件发送、接收不可显示的数据(如0xAA),并以十六进制的形式显示出来?
- VC如何访问Foxpro数据库
- 如何在一个dialog上指定的IDC_IMAGE上显示所选择的图片?????
- 请问如何把文本格式(.txt)转换为传真图形格式(.tif)
- 100分!江湖告急不过还加,但要快!
你就这样肯定是不行的啦!先从TOKEN开始研究吧!
The GetUserName function retrieves the user name of the current thread. This is the name of the user currently logged onto the system. BOOL GetUserName(
LPTSTR lpBuffer, // address of name buffer
LPDWORD nSize // address of size of name buffer
);
Parameters
lpBuffer
Pointer to the buffer to receive the null-terminated string containing the user's logon name. If this buffer is not large enough to contain the entire user name, the function fails. A buffer size of (UNLEN + 1) characters will hold the maximum length user name including the terminating null character. UNLEN is defined in LMCONS.H.
nSize
Pointer to a DWORD variable that, on input, specifies the maximum size, in characters, of the buffer specified by the lpBuffer parameter. If the function succeeds, the variable receives the number of characters copied to the buffer. If the buffer is not large enough, the function fails and the variable receives the required buffer size, in characters, including the terminating null character.
Return Values
If the function succeeds, the return value is nonzero, and the variable pointed to by nSize contains the number of characters copied to the buffer specified by lpBuffer, including the terminating null character. If the function fails, the return value is zero. To get extended error information, callGetLastError. Res
If the current thread is impersonating another client, the GetUserName function returns the user name of the client that the thread is impersonating. QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use advapi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.See Also
System Information Overview, System Information Functions,LookupAccountName