网站首页  词典首页

请输入您要查询的函数:

 

术语 netshareenum
释义 NetShareEnum
语法:
C++
NET_API_STATUS NetShareEnum(
__in LPWSTR servername,
__in DWORD level,
__out LPBYTE *bufptr,
__in DWORD prefmaxlen,
__out LPDWORD entriesread,
__out LPDWORD totalentries,
__inout LPDWORD resume_handle
);
NetShareEnum功能
信息检索上的每个服务器上的共享资源。
您还可以使用WNetEnumResource函数来检索资源信息。然而,WNetEnumResource不枚举隐藏共享或连接到共享的用户。
参数
服务器名 [in]
指针指向一个字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
0Return共享名称。在bufptr参数指向一个SHARE_INFO_0结构的数组。
1Return信息共享资源,包括名称和资源的类型,以及与资源相关评论。在bufptr参数指向一个SHARE_INFO_1结构的数组。
2Return信息共享资源,包括资源,类型和权限,密码,姓名和连接数。在bufptr参数指向一个SHARE_INFO_2结构的数组。
502Return信息共享资源,包括资源,类型和权限,名称的连接的数量,以及其他有关资料。在bufptr参数指向一个SHARE_INFO_502结构的数组。从不同范围的股价不返回。欲了解更多有关范围的信息,看到的NetServerTransportAddEx函数文档注释部分。
503Return信息共享资源,包括资源,类型和权限,名称的连接的数量,以及其他有关资料。在bufptr参数指向一个SHARE_INFO_503结构的数组。所有范围的股价产生。如果这个结构shi503_servername成员是“*”,并没有配置的服务器的名称和NetShareEnum功能列举了所有unscoped名称股份。
Windows Server 2003中,Windows XP和Windows 2000 Server和Windows 2000专业版:此信息Level不支持。
bufptr [out]
指针的缓冲区,接收数据。这一数据格式取决于Level的参数值。
此缓冲区分配制度,必须使用NetApiBufferFree释放功能。请注意,您必须释放缓冲区,即使函数ERROR_MORE_DATA失败。
prefmaxlen [in]
指定返回数据的首选的最大字节长度。如果您指定MAX_PREFERRED_LENGTH,功能分配用于数据所需的内存量。如果指定这个参数在另一个值,它可以限制的字节数函数返回。如果缓冲区大小不足以容纳所有作品,该函数返回ERROR_MORE_DATA。有关更多信息,请参阅网络管理功能,缓冲器和网络管理功能缓冲区长度。
entriesread [out]
指针的值,它接收元素计数实际列举。
totalentries [out]
指针的值,它接收了本来可以列举的项目总数。请注意,应用程序应考虑仅作为提示此值。
resume_handle [ in , out ]
指针的值,它包含简历处理,用于继续现有的共享搜索。手柄应在第一次调用零,离开后续调用不变。如果resume_handle为NULL,则没有恢复处理存储。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值是一个系统错误代码。对于一个错误代码的列表,请参见系统错误代码。
备注
此功能仅适用于服务器消息块(SMB)的股票。对于其他类型的股票,如分布式文件系统(DFS)或WebDAV共享,使用Windows网络(WNet)功能,它支持所有类型的股份。
对于(谁是用户在本地登录到机器交互式用户),没有特别小组的成员必须执行NetShareEnum功能。对于非交互式用户,管理员,高级用户,打印操作,或服务器操作员组成员必须在各级成功执行2,502 NetShareEnum功能和503。没有特殊组成员,是需要0级或1级要求。
Windows Server 2003中,Windows XP和Windows 2000 Server和Windows 2000 Professional的:对于所有用户,管理员,高级用户,打印操作,或服务器操作员组成员必须在各级成功执行2和502 NetShareEnum功能。
To retrieve a value that indicates whether a share is the root volume in a DFS tree structure, you must call the NetShareGetInfo function and specify information level 1005.
如果您是Active Directory的程序,您可以调用某些Active Directory服务接口(ADSI)的方法来达到同样的功能,您可以通过调用实现网络管理共享功能。有关更多信息,请参阅IADsFileShare。
Server 2003和Windows XP中:如果您拨打信息第2级或域控制器上运行Active Directory 502此功能,允许访问或拒绝关于在安全对象的ACL的视窗。要启用匿名访问,用户必须是匿名的Windows 2000以前版本兼容访问组成员。这是因为匿名令牌不包括Everyone组默认的SID。如果您拨打信息第2级或成员服务器或工作站,所有的身份验证的用户可以查看信息502此功能。匿名访问也是允许的,如果everyoneincludesanonymous的策略设置允许匿名访问。如需有关限制匿名访问的信息,请参阅的网络管理功能的安全要求。欲了解更多有关的ACL,ACE的,和访问令牌信息,请访问控制模型。
Windows 2000 Server和Windows 2000 Professional的:如果您调用信息第2级或域控制器上运行Active Directory 502此功能,允许访问或拒绝的访问控制列表的安全对象(ACL)的基础。默认的ACL允许所有经过身份验证的用户和Windows 2000以前版本兼容访问组,查看资料。默认情况下,Windows 2000以前版本兼容访问组群包括每个人作为成员。这使得匿名访问的信息如果系统允许匿名访问。如果您拨打信息第2级或成员服务器或工作站,所有的身份验证的用户可以查看信息502此功能。匿名访问也是允许的,如果RestrictAnonymous的策略设置允许匿名访问。有关更多信息,请允许匿名访问。
实例
下面的代码示例演示了如何检索有关每一个使用调用NetShareEnum功能服务器共享资源信息。该范例调用NetShareEnum,指定信息化Level502(SHARE_INFO_502)。如果调用成功,通过项目和打印有关每个共享信息代码循环。该示例还调用IsValidSecurityDescriptor函数来验证shi502_security_descriptor成员。最后,代码示例释放的信息缓冲区分配的内存。
#define UNICODE
#include
#include
#include
#pragma comment(lib, "Netapi32.lib")
void wmain( int argc, TCHAR *lpszArgv[ ])
{
PSHARE_INFO_502 BufPtr,p;
NET_API_STATUS res;
LPTSTR lpszServer = NULL;
DWORD er=0,tr=0,resume=0, i;
switch(argc)
{
case 2:
lpszServer = lpszArgv[1];
break;
default:
printf("Usage: NetShareEnum \\n");
return;
}
//
// Print a report header.
//
printf("Share: Local Path: Uses: Descriptor:\\n");
printf("---------------------------------------------------------------------\\n");
//
// Call the NetShareEnum function; specify level 502.
//
do // begin do
{
res = NetShareEnum (lpszServer, 502, (LPBYTE *) &BufPtr, -1, &er, &tr, &resume);
//
// If the call succeeds,
//
if(res == ERROR_SUCCESS || res == ERROR_MORE_DATA)
{
p=BufPtr;
//
// Loop through the entries;
// print retrieved data.
//
for(i=1;i<=er;i++)
{
printf("%-20S%-30S%-8u",p->shi502_netname, p->shi502_path, p->shi502_current_uses);
//
// Validate the value of the
// shi502_security_descriptor member.
//
if (IsValidSecurityDescriptor(p->shi502_security_descriptor))
printf("Yes\\n");
else
printf("No\\n");
p++;
}
//
// Free the allocated buffer.
//
NetApiBufferFree(BufPtr);
}
else
printf("Error: %ld\\n",res);
}
// Continue to call NetShareEnum while
// there are more entries.
//
while (res==ERROR_MORE_DATA); // end do
return;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmshare.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
网络共享功能
SHARE_INFO_0
SHARE_INFO_1
SHARE_INFO_2
SHARE_INFO_502
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年4月9日
==英文原文==NetShareEnum Function
Retrieves information about each shared resource on a server.
You can also use the WNetEnumResource function to retrieve resource information. However, WNetEnumResource does not enumerate hidden shares or users connected to a share.
Syntax
C++
NET_API_STATUS NetShareEnum(
__in LPWSTR servername,
__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.
level [in]
Specifies the information level of the data. This parameter can be one of the following values.
ValueMeaning
0Return share names. The bufptr parameter points to an array of SHARE_INFO_0 structures.
1Return information about shared resources, including the name and type of the resource, and a comment associated with the resource. The bufptr parameter points to an array of SHARE_INFO_1 structures.
2Return information about shared resources, including name of the resource, type and permissions, password, and number of connections. The bufptr parameter points to an array of SHARE_INFO_2 structures.
502Return information about shared resources, including name of the resource, type and permissions, number of connections, and other pertinent information. The bufptr parameter points to an array of SHARE_INFO_502 structures. Shares from different scopes are not returned. For more information about scoping, see the Remarks section of the documentation for the NetServerTransportAddEx function.
503Return information about shared resources, including the name of the resource, type and permissions, number of connections, and other pertinent information. The bufptr parameter points to an array of SHARE_INFO_503 structures. Shares from all scopes are returned. If the shi503_servername member of this structure is "*", there is no configured server name and the NetShareEnum function enumerates shares for all the unscoped names.
Windows Server 2003, Windows XP, Windows 2000 Server, and Windows 2000 Professional: This information level is not supported.

bufptr [out]
Pointer to the buffer that receives the data. 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. 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 share search. The handle should be zero on the first call and left unchanged for subsequent calls. If resume_handle 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
This function applies only to Server Message Block (SMB) shares. For other types of shares, such as Distributed File System (DFS) or WebDAV shares, use Windows Networking (WNet) functions , which support all types of shares.
For interactive users (users who are logged on locally to the machine), no special group membership is required to execute the NetShareEnum function. For non-interactive users, Administrator, Power User, Print Operator, or Server Operator group membership is required to successfully execute the NetShareEnum function at levels 2, 502, and 503. No special group membership is required for level 0 or level 1 calls.
Windows Server 2003, Windows XP, Windows 2000 Server, and Windows 2000 Professional: For all users, Administrator, Power User, Print Operator, or Server Operator group membership is required to successfully execute the NetShareEnum function at levels 2 and 502.
To retrieve a value that indicates whether a share is the root volume in a DFS tree structure, you must call the NetShareGetInfo function and specify information level 1005.
If you are programming for Active Directory, you may be able to call certain Active Directory Service Interface (ADSI) methods to achieve the same functionality you can achieve by calling the network management share functions. For more information, see IADsFileShare .
Windows Server 2003 and Windows XP: If you call this function at information level 2 or 502 on a domain controller that is running Active Directory, access is allowed or denied based on the ACL for the securable object. To enable anonymous access, the user Anonymous must be a member of the Pre-Windows 2000-Compatible Access Group. This is because anonymous tokens do not include the Everyone group SID by default. If you call this function at information level 2 or 502 on a member server or workstation, all authenticated users can view the information. Anonymous access is also permitted if the EveryoneIncludesAnonymous policy setting allows anonymous access. For more information about restricting anonymous access, see Security Requirements for the Network Management Functions . For more information on ACLs, ACEs, and access tokens, see Access Control Model .
Windows 2000 Server and Windows 2000 Professional: If you call this function at information level 2 or 502 on a domain controller that is running Active Directory, access is allowed or denied based on the access control list (ACL) for the securable object. The default ACL permits all authenticated users and members of the Pre-Windows 2000-Compatible Access Group to view the information. By default, the Pre-Windows 2000-Compatible Access Group group includes Everyone as a member. This enables anonymous access to the information if the system allows anonymous access. If you call this function at information level 2 or 502 on a member server or workstation, all authenticated users can view the information. Anonymous access is also permitted if the RestrictAnonymous policy setting allows anonymous access. For more information, see Allowing Anonymous Access .
Examples
The following code sample demonstrates how to retrieve information about each shared resource on a server using a call to the NetShareEnum function. The sample calls NetShareEnum, specifying information level 502 ( SHARE_INFO_502 ). If the call succeeds, the code loops through the entries and prints information about each share. The sample also calls the IsValidSecurityDescriptor function to validate the shi502_security_descriptor member. 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, TCHAR *lpszArgv[ ])
{
PSHARE_INFO_502 BufPtr,p;
NET_API_STATUS res;
LPTSTR lpszServer = NULL;
DWORD er=0,tr=0,resume=0, i;
switch(argc)
{
case 2:
lpszServer = lpszArgv[1];
break;
default:
printf("Usage: NetShareEnum \\n");
return;
}
//
// Print a report header.
//
printf("Share: Local Path: Uses: Descriptor:\\n");
printf("---------------------------------------------------------------------\\n");
//
// Call the NetShareEnum function; specify level 502.
//
do // begin do
{
res = NetShareEnum (lpszServer, 502, (LPBYTE *) &BufPtr, -1, &er, &tr, &resume);
//
// If the call succeeds,
//
if(res == ERROR_SUCCESS || res == ERROR_MORE_DATA)
{
p=BufPtr;
//
// Loop through the entries;
// print retrieved data.
//
for(i=1;i<=er;i++)
{
printf("%-20S%-30S%-8u",p->shi502_netname, p->shi502_path, p->shi502_current_uses);
//
// Validate the value of the
// shi502_security_descriptor member.
//
if (IsValidSecurityDescriptor(p->shi502_security_descriptor))
printf("Yes\\n");
else
printf("No\\n");
p++;
}
//
// Free the allocated buffer.
//
NetApiBufferFree(BufPtr);
}
else
printf("Error: %ld\\n",res);
}
// Continue to call NetShareEnum while
// there are more entries.
//
while (res==ERROR_MORE_DATA); // end do
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
SHARE_INFO_0
SHARE_INFO_1
SHARE_INFO_2
SHARE_INFO_502
Send comments about this topic to Microsoft
Build date: 4/9/2009
==原始网址==http://msdn.microsoft.com/en-us/library/bb525387(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 更新时间:2025/1/23 7:47:46