网站首页  词典首页

请输入您要查询的函数:

 

术语 netconnectionenum
释义 NetConnectionEnum
语法:
C++
NET_API_STATUS NetConnectionEnum(
__in LMSTR servername,
__in LMSTR qualifier,
__in DWORD level,
__out LPBYTE *bufptr,
__in DWORD prefmaxlen,
__out LPDWORD entriesread,
__out LPDWORD totalentries,
__inout LPDWORD resume_handle
);
NetConnectionEnum功能
列出了上的一个服务器或特定计算机的所有连接建立的共享资源的所有连接。如果有多个用户使用此连接,然后就可以得到一个以上的相同的连接结构,但使用不同的用户名。
参数
服务器名 [in]
指针指向一个字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
这个字符串是Unicode或FORCE_UNICODE如果_WIN32_WINNT定义。
预选赛 [in]
指针指向一个字符串,用于指定连接感兴趣的一个共享名或计算机名。如果它是一个共享名称,然后作出所有连接到该共享的名称列出。如果它是一个(例如计算机名称,它开始的两个反斜杠字符),然后NetConnectionEnum列出了从该计算机的所有连接到服务器的指定。
这个字符串是Unicode或FORCE_UNICODE如果_WIN32_WINNT定义。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
0Return连接标识符。该bufptr参数是一个CONNECTION_INFO_0结构的数组指针。
1Return连接标识符和连接信息。该bufptr参数是一个CONNECTION_INFO_1结构的数组指针。
bufptr [out]
指向的缓冲区,接收信息的地址。这一数据格式取决于Level的参数值。
此缓冲区分配制度,必须使用NetApiBufferFree释放功能。请注意,您必须释放缓冲区,即使函数ERROR_MORE_DATA失败。
prefmaxlen [in]
指定返回数据的首选的最大字节长度。如果您指定MAX_PREFERRED_LENGTH,功能分配用于数据所需的内存量。如果指定这个参数在另一个值,它可以限制的字节数函数返回。如果缓冲区大小不足以容纳所有作品,该函数返回ERROR_MORE_DATA。有关更多信息,请参阅网络管理功能,缓冲器和网络管理功能缓冲区长度。
entriesread [out]
指针的值,它接收元素计数实际列举。
totalentries [out]
指针的值,它接收了本来可以列举参赛总人数从目前的恢复情况。请注意,应用程序应考虑仅作为提示此值。
resume_handle [ in , out ]
指针的值,它包含简历处理,用于继续现有的连接搜索。手柄应在第一次调用零,离开后续调用不变。如果该参数为NULL,则没有恢复处理存储。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值是一个系统错误代码。对于一个错误代码的列表,请参见系统错误代码。
备注
管理员,服务器或打印操作,或高级用户组成员必须成功地执行NetConnectionEnum功能。
实例
下面的代码示例演示如何列表,以函数调用的NetConnectionEnum到共享资源的连接。该范例调用NetConnectionEnum,指定信息化Level1(CONNECTION_INFO_1)。如果有项返回,它打印的coni1_username和coni1_netname成员的值。如果没有项返回,样本打印一个适当的信息。最后,代码示例释放的信息缓冲区分配的内存。
#define UNICODE
#include
#include
#include
#pragma comment(lib, "Netapi32.lib");
void wmain(int argc, wchar_t *argv[ ])
{
DWORD res, i, er = 0, tr = 0, resume = 0;
PCONNECTION_INFO_1 p,b;
LPTSTR lpszServer = NULL, lpszShare = NULL;
if(argc<2)
wprintf(L"Syntax: %s [ServerName] ShareName | \\\\\\\\ComputerName\\n", argv[0]);
else
{
//
// The server is not the default local computer.
//
if(argc>2)
lpszServer=argv[1];
//
// ShareName is always the last argument.
//
lpszShare=argv[argc - 1];
//
// Call the NetConnectionEnum function,
// specifying information level 1.
//
res=NetConnectionEnum(lpszServer, lpszShare, 1, (LPBYTE *) &p, -1, &er, &tr, &resume);
//
// If no error occurred,
//
if(res == 0)
{
//
// If there were any results,
//
if(er>0)
{
b=p;
//
// Loop through the entries; print username and netname.
//
for(i=0;i {
printf("%S\\t%S\\n", b->coni1_username,b->coni1_netname);
b++;
}
// Free the allocated buffer.
//
NetApiBufferFree(p);
}
// Otherwise, print a message depending on whether
// the qualifier parameter was a computer (\\\\ComputerName)
// or a share (ShareName).
//
else
{
if(lpszShare[0]=='\\\\')
printf("No connection to %S from %S\\n",
(lpszServer == NULL)?TEXT("LocalMachine"):lpszServer, lpszShare);
else
printf("No one connected to %S\\\\%S\\n",
(lpszServer == NULL)?TEXT("\\\\\\\\LocalMachine"):lpszServer,lpszShare);
}
}
//
// Otherwise, print the error.
//
else
printf("Error: %d\\n",res);
}
return;
}

要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmshare.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
网络共享功能
CONNECTION_INFO_0
CONNECTION_INFO_1
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==NetConnectionEnum Function
Lists all connections made to a shared resource on the server or all connections established from a particular computer. If there is more than one user using this connection, then it is possible to get more than one structure for the same connection, but with a different user name.
Syntax
C++
NET_API_STATUS NetConnectionEnum(
__in LMSTR servername,
__in LMSTR qualifier,
__in DWORD level,
__out LPBYTE *bufptr,
__in DWORD prefmaxlen,
__out LPDWORD entriesread,
__out LPDWORD totalentries,
__inout LPDWORD resume_handle
);
Parameters
servername [in]
Pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.
This string is Unicode if _WIN32_WINNT or FORCE_UNICODE is defined.
qualifier [in]
Pointer to a string that specifies a share name or computer name for the connections of interest. If it is a share name, then all the connections made to that share name are listed. If it is a computer name (for example, it starts with two backslash characters), then NetConnectionEnum lists all connections made from that computer to the server specified.
This string is Unicode if _WIN32_WINNT or FORCE_UNICODE is defined.
level [in]
Specifies the information level of the data. This parameter can be one of the following values.
ValueMeaning
0Return connection identifiers. The bufptr parameter is a pointer to an array of CONNECTION_INFO_0 structures.
1Return connection identifiers and connection information. The bufptr parameter is a pointer to an array of CONNECTION_INFO_1 structures.

bufptr [out]
Pointer to the address of the buffer that receives the information. The format of this data depends on the value of the level parameter.
This buffer is allocated by the system and must be freed using the NetApiBufferFree function. Note that you must free the buffer even if the function fails with ERROR_MORE_DATA.
prefmaxlen [in]
Specifies the preferred maximum length of returned data, in bytes. If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the data. If you specify another value in this parameter, it can restrict the number of bytes that the function returns. If the buffer size is insufficient to hold all entries, the function returns ERROR_MORE_DATA. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths .
entriesread [out]
Pointer to a value that receives the count of elements actually enumerated.
totalentries [out]
Pointer to a value that receives the total number of entries that could have been enumerated from the current resume position. Note that applications should consider this value only as a hint.
resume_handle [in, out]
Pointer to a value that contains a resume handle which is used to continue an existing connection search. The handle should be zero on the first call and left unchanged for subsequent calls. If this parameter is NULL, then no resume handle is stored.
Return Value
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes .
Remarks
Administrator, Server or Print Operator, or Power User group membership is required to successfully execute the NetConnectionEnum function.
Examples
The following code sample demonstrates how to list the connections made to a shared resource with a call to the NetConnectionEnum function. The sample calls NetConnectionEnum, specifying information level 1 ( CONNECTION_INFO_1 ). If there are entries to return, it prints the values of the coni1_username and coni1_netname members. If there are no entries to return, the sample prints an appropriate message. Finally, the code sample frees the memory allocated for the information buffer.
#define UNICODE
#include
#include
#include
#pragma comment(lib, "Netapi32.lib");
void wmain(int argc, wchar_t *argv[ ])
{
DWORD res, i, er = 0, tr = 0, resume = 0;
PCONNECTION_INFO_1 p,b;
LPTSTR lpszServer = NULL, lpszShare = NULL;
if(argc<2)
wprintf(L"Syntax: %s [ServerName] ShareName | \\\\\\\\ComputerName\\n", argv[0]);
else
{
//
// The server is not the default local computer.
//
if(argc>2)
lpszServer=argv[1];
//
// ShareName is always the last argument.
//
lpszShare=argv[argc - 1];
//
// Call the NetConnectionEnum function,
// specifying information level 1.
//
res=NetConnectionEnum(lpszServer, lpszShare, 1, (LPBYTE *) &p, -1, &er, &tr, &resume);
//
// If no error occurred,
//
if(res == 0)
{
//
// If there were any results,
//
if(er>0)
{
b=p;
//
// Loop through the entries; print username and netname.
//
for(i=0;i {
printf("%S\\t%S\\n", b->coni1_username,b->coni1_netname);
b++;
}
// Free the allocated buffer.
//
NetApiBufferFree(p);
}
// Otherwise, print a message depending on whether
// the qualifier parameter was a computer (\\\\ComputerName)
// or a share (ShareName).
//
else
{
if(lpszShare[0]=='\\\\')
printf("No connection to %S from %S\\n",
(lpszServer == NULL)?TEXT("LocalMachine"):lpszServer, lpszShare);
else
printf("No one connected to %S\\\\%S\\n",
(lpszServer == NULL)?TEXT("\\\\\\\\LocalMachine"):lpszServer,lpszShare);
}
}
//
// Otherwise, print the error.
//
else
printf("Error: %d\\n",res);
}
return;
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmshare.h (include Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
See Also
Network Management Overview
Network Management Functions
Network Share Functions
CONNECTION_INFO_0
CONNECTION_INFO_1
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/bb525376(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 13:24:02