网站首页  词典首页

请输入您要查询的函数:

 

术语 netwkstausergetinfo
释义 NetWkstaUserGetInfo
语法:
C++
NET_API_STATUS NetWkstaUserGetInfo(
LPWSTR reserved,
__in DWORD level,
__out LPBYTE *bufptr
);
NetWkstaUserGetInfo功能
该NetWkstaUserGetInfo函数返回有关当前登录的用户。此函数必须调用的上下文中登录的用户。
参数
保留
此参数必须设置为NULL。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
0Return的用户名当前登录到该工作站。在bufptr参数指向WKSTA_USER_INFO_0结构。
1Return信息工作站,包括当前用户名和工作站所访问的域名。在bufptr参数指向WKSTA_USER_INFO_1结构。
在工作站浏览1101Return域。在bufptr参数指向WKSTA_USER_INFO_1101结构。
bufptr [out]
指针的缓冲区,接收数据。这些数据的格式取决于该bufptr参数的值。此缓冲区分配制度,必须使用NetApiBufferFree释放功能。有关更多信息,请参阅网络管理功能,缓冲器和网络管理功能缓冲区长度。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_NOT_ENOUGH_MEMORYThe系统运行内存不足的资源。无论是网络管理员配置不正确,或程序正在运行的系统内存不足。
ERROR_INVALID_LEVELTheLevel参数无效。
函数的参数ERROR_INVALID_PARAMETEROne是无效的。
备注
该NetWkstaUserGetInfo功能只能在本地。
实例
下面的代码示例演示如何检索有关当前登录的用户使用调用NetWkstaUserGetInfo功能。该范例调用NetWkstaUserGetInfo,指定信息化Level1(WKSTA_USER_INFO_1)。如果调用成功,样本打印资料的登录用户。最后,该示例释放的信息缓冲区分配的内存。
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
int wmain(void)
{
DWORD dwLevel = 1;
LPWKSTA_USER_INFO_1 pBuf = NULL;
NET_API_STATUS nStatus;
//
// Call the NetWkstaUserGetInfo function;
// specify level 1.
//
nStatus = NetWkstaUserGetInfo(NULL,
dwLevel,
(LPBYTE *)&pBuf);
//
// If the call succeeds, print the information
// about the logged-on user.
//
if (nStatus == NERR_Success)
{
if (pBuf != NULL)
{
wprintf(L"\\n\\tUser: %s\\n", pBuf->wkui1_username);
wprintf(L"\\tDomain: %s\\n", pBuf->wkui1_logon_domain);
wprintf(L"\\tOther Domains: %s\\n", pBuf->wkui1_oth_domains);
wprintf(L"\\tLogon Server: %s\\n", pBuf->wkui1_logon_server);
}
}
// Otherwise, print the system error.
//
else
fprintf(stderr, "A system error has occurred: %d\\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
return 0;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmwksta.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
工作站和工作站用户功能
NetWkstaSetInfo
WKSTA_USER_INFO_0
WKSTA_USER_INFO_1
WKSTA_USER_INFO_1101
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetWkstaUserGetInfo Function
The NetWkstaUserGetInfo function returns information about the currently logged-on user. This function must be called in the context of the logged-on user.
Syntax
C++
NET_API_STATUS NetWkstaUserGetInfo(
LPWSTR reserved,
__in DWORD level,
__out LPBYTE *bufptr
);
Parameters
reserved
This parameter must be set to NULL.
level [in]
Specifies the information level of the data. This parameter can be one of the following values.
ValueMeaning
0Return the name of the user currently logged on to the workstation. The bufptr parameter points to a WKSTA_USER_INFO_0 structure.
1Return information about the workstation, including the name of the current user and the domains accessed by the workstation. The bufptr parameter points to a WKSTA_USER_INFO_1 structure.
1101Return domains browsed by the workstation. The bufptr parameter points to a WKSTA_USER_INFO_1101 structure.

bufptr [out]
Pointer to the buffer that receives the data. The format of this data depends on the value of the bufptr parameter. This buffer is allocated by the system and must be freed using the NetApiBufferFree function. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths .
Return Value
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value can be one of the following error codes.
Return codeDescription
ERROR_NOT_ENOUGH_MEMORYThe system ran out of memory resources. Either the network manager configuration is incorrect, or the program is running on a system with insufficient memory.
ERROR_INVALID_LEVELThe level parameter is invalid.
ERROR_INVALID_PARAMETEROne of the function parameters is invalid.

Remarks
The NetWkstaUserGetInfo function only works locally.
Examples
The following code sample demonstrates how to retrieve information about the currently logged-on user using a call to the NetWkstaUserGetInfo function. The sample calls NetWkstaUserGetInfo, specifying information level 1 ( WKSTA_USER_INFO_1 ). If the call succeeds, the sample prints information about the logged-on user. Finally, the sample frees the memory allocated for the information buffer.
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
int wmain(void)
{
DWORD dwLevel = 1;
LPWKSTA_USER_INFO_1 pBuf = NULL;
NET_API_STATUS nStatus;
//
// Call the NetWkstaUserGetInfo function;
// specify level 1.
//
nStatus = NetWkstaUserGetInfo(NULL,
dwLevel,
(LPBYTE *)&pBuf);
//
// If the call succeeds, print the information
// about the logged-on user.
//
if (nStatus == NERR_Success)
{
if (pBuf != NULL)
{
wprintf(L"\\n\\tUser: %s\\n", pBuf->wkui1_username);
wprintf(L"\\tDomain: %s\\n", pBuf->wkui1_logon_domain);
wprintf(L"\\tOther Domains: %s\\n", pBuf->wkui1_oth_domains);
wprintf(L"\\tLogon Server: %s\\n", pBuf->wkui1_logon_server);
}
}
// Otherwise, print the system error.
//
else
fprintf(stderr, "A system error has occurred: %d\\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
return 0;
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmwksta.h (include Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
See Also
Network Management Overview
Network Management Functions
Workstation and Workstation User Functions
NetWkstaSetInfo
WKSTA_USER_INFO_0
WKSTA_USER_INFO_1
WKSTA_USER_INFO_1101
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370670(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:31:42