网站首页  词典首页

请输入您要查询的函数:

 

术语 wnetopenenum
释义 WNetOpenEnum
语法:
C++
DWORD WNetOpenEnum(
__in DWORD dwScope,
__in DWORD dwType,
__in DWORD dwUsage,
__in LPNETRESOURCE lpNetResource,
__out LPHANDLE lphEnum
);
WNetOpenEnum函数
在WNetOpenEnum函数开始的网络资源或现有的连接枚举。您可以继续通过调用WNetEnumResource函数枚举。
参数
dwScope [in]
枚举的范围。此参数可以是下列值之一。
ValueMeaning
RESOURCE_CONNECTEDEnumerate当前连接的所有资源。函数忽略dwUsage参数。有关详细信息,请参阅下面的备注部分。
在调用网络范围内RESOURCE_CONTEXTEnumerate的资源。指定的网上邻居查看此值。函数忽略dwUsage参数。
RESOURCE_GLOBALNETEnumerate全部网络上的资源。
RESOURCE_REMEMBEREDEnumerate都记得(持久)连接。函数忽略dwUsage参数。
dwType [in]
资源种类枚举。此参数可以是下列值的组合。
ValueMeaning
RESOURCETYPE_ANYAll资源。此值不能结合RESOURCETYPE_DISK或RESOURCETYPE_PRINT。
RESOURCETYPE_DISKAll磁盘资源。
RESOURCETYPE_PRINTAll印刷资源。
如果一个网络提供商不能区分打印和磁盘资源,它可以枚举所有的资源。
dwUsage [in]
资源使用情况要枚举类型。此参数可以是下列值的组合。
ValueMeaning
0All资源。
RESOURCEUSAGE_CONNECTABLEAll可连接的资源。
RESOURCEUSAGE_CONTAINERAll集装箱资源。
RESOURCEUSAGE_ATTACHEDSetting此值势力WNetOpenEnum失败如果用户没有通过认证。函数失败,即使在网络允许枚举无需验证。
RESOURCEUSAGE_ALLSetting此值相当于设置RESOURCEUSAGE_CONNECTABLE,RESOURCEUSAGE_CONTAINER和RESOURCEUSAGE_ATTACHED。
此参数被忽略,除非dwScope参数等于RESOURCE_GLOBALNET。有关详细信息,请参阅下面的备注部分。
lpNetResource [in]
指针NETRESOURCE结构,指定容器枚举。如果dwScope参数没有RESOURCE_GLOBALNET,此参数必须为NULL。
如果该参数为NULL,网络的根本假设。 (系统组织作为一个层次网络;的根是在网络最顶层容器。)
如果这个参数不为NULL,它必须指向一个NETRESOURCE结构。这种结构可以填写的申请,也可以通过向WNetEnumResource函数调用返回。该NETRESOURCE结构必须指定一个容器资源;,即RESOURCEUSAGE_CONTAINER值必须在dwUsage参数中指定。
枚举所有的网络资源,应用程序就可以开始通过调用设置为NULL的lpNetResource参数WNetOpenEnum枚举,然后使用返回的句柄调用WNetEnumResource枚举资源。如果在NETRESOURCE数组中的资源之一,由WNetEnumResource函数返回的是一个容器资源,您可以调用WNetOpenEnum打开进一步枚举资源。
lphEnum [out]
枚举指针处理,可在随后的调用WNetEnumResource使用。
返回值
如果函数成功,返回值为NO_ERROR。
如果函数失败,返回值是一个系统错误代码,如下列值之一。
返回codeDescription
ERROR_NOT_CONTAINERThe lpNetResource参数不指向一个容器。
ERROR_INVALID_PARAMETEREither的dwScope或却提示参数无效,或有一个无效的参数组合。
ERROR_NO_NETWORKThe网络不可用。
ERROR_EXTENDED_ERRORA网络特定的错误。要获取该错误的描述,调用WNetGetLastError功能。
ERROR_INVALID_ADDRESSA远程网络资源的名称解析为一个无效的网络地址NETRESOURCE结构提供的。
备注
如果dwScope参数等于RESOURCE_CONNECTED,使网络连接使用Microsoft LAN Manager的网络省略枚举如果连接是由在不同的登录会话中运行的应用程序比调用WNetOpenEnum函数的应用进展。这是因为连接了使用Microsoft LAN管理器只能显示于应用相同的登录会话中运行的应用程序建立的连接。 (要包括在枚举方面,它是不是足够的应用程序运行在用户帐户创建连接。)
在RESOURCE_CONTEXT在dwScope参数确切的解释取决于安装在机器上的网络。
在WNetOpenEnum函数用于开始一个容器资源枚举。下面的例子显示了一个Microsoft LAN Manager网络的层次结构和Novell NetWare网络,并确定容器。
LanMan (container, in this case the provider)
ACCOUNTING (container, in this case the domain)
\\\\ACCTSPAY (container, in this case the server)
PAYFILES (disk)
LASERJET (print)

NetWare (container, in this case the provider)
MARKETING (container, in this case the server)
SYS (disk, first one on any NetWare server)
ANOTHERVOLUME (disk)
LASERJET (print)
实例
有关代码示例,演示应用程序定义的函数枚举所有网络上的资源,请列举网络资源。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode和ANSI namesWNetOpenEnumW(Unicode)和WNetOpenEnumA(ANSI)的
参见
Windows网络(WNet)概述
Windows网络函数
NETRESOURCE
WNetCloseEnum
WNetEnumResource
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月6日
==英文原文==WNetOpenEnum Function
The WNetOpenEnum function starts an enumeration of network resources or existing connections. You can continue the enumeration by calling the WNetEnumResource function.
Syntax
C++
DWORD WNetOpenEnum(
__in DWORD dwScope,
__in DWORD dwType,
__in DWORD dwUsage,
__in LPNETRESOURCE lpNetResource,
__out LPHANDLE lphEnum
);
Parameters
dwScope [in]
Scope of the enumeration. This parameter can be one of the following values.
ValueMeaning
RESOURCE_CONNECTEDEnumerate all currently connected resources. The function ignores the dwUsage parameter. For more information, see the following Remarks section.
RESOURCE_CONTEXTEnumerate only resources in the network context of the caller. Specify this value for a Network Neighborhood view. The function ignores the dwUsage parameter.
RESOURCE_GLOBALNETEnumerate all resources on the network.
RESOURCE_REMEMBEREDEnumerate all remembered (persistent) connections. The function ignores the dwUsage parameter.

dwType [in]
Resource types to be enumerated. This parameter can be a combination of the following values.
ValueMeaning
RESOURCETYPE_ANYAll resources. This value cannot be combined with RESOURCETYPE_DISK or RESOURCETYPE_PRINT.
RESOURCETYPE_DISKAll disk resources.
RESOURCETYPE_PRINTAll print resources.

If a network provider cannot distinguish between print and disk resources, it can enumerate all resources.
dwUsage [in]
Resource usage type to be enumerated. This parameter can be a combination of the following values.
ValueMeaning
0All resources.
RESOURCEUSAGE_CONNECTABLEAll connectable resources.
RESOURCEUSAGE_CONTAINERAll container resources.
RESOURCEUSAGE_ATTACHEDSetting this value forces WNetOpenEnum to fail if the user is not authenticated. The function fails even if the network allows enumeration without authentication.
RESOURCEUSAGE_ALLSetting this value is equivalent to setting RESOURCEUSAGE_CONNECTABLE, RESOURCEUSAGE_CONTAINER, and RESOURCEUSAGE_ATTACHED.

This parameter is ignored unless the dwScope parameter is equal to RESOURCE_GLOBALNET. For more information, see the following Remarks section.
lpNetResource [in]
Pointer to a NETRESOURCE structure that specifies the container to enumerate. If the dwScope parameter is not RESOURCE_GLOBALNET, this parameter must be NULL.
If this parameter is NULL, the root of the network is assumed. (The system organizes a network as a hierarchy; the root is the topmost container in the network.)
If this parameter is not NULL, it must point to a NETRESOURCE structure. This structure can be filled in by the application or it can be returned by a call to the WNetEnumResource function. The NETRESOURCE structure must specify a container resource; that is, the RESOURCEUSAGE_CONTAINER value must be specified in the dwUsage parameter.
To enumerate all network resources, an application can begin the enumeration by calling WNetOpenEnum with the lpNetResource parameter set to NULL, and then use the returned handle to call WNetEnumResource to enumerate resources. If one of the resources in the NETRESOURCE array returned by the WNetEnumResource function is a container resource, you can call WNetOpenEnum to open the resource for further enumeration.
lphEnum [out]
Pointer to an enumeration handle that can be used in a subsequent call to WNetEnumResource .
Return Value
If the function succeeds, the return value is NO_ERROR.
If the function fails, the return value is a system error code , such as one of the following values.
Return codeDescription
ERROR_NOT_CONTAINERThe lpNetResource parameter does not point to a container.
ERROR_INVALID_PARAMETEREither the dwScope or the dwType parameter is invalid, or there is an invalid combination of parameters.
ERROR_NO_NETWORKThe network is unavailable.
ERROR_EXTENDED_ERRORA network-specific error occurred. To obtain a description of the error, call the WNetGetLastError function.
ERROR_INVALID_ADDRESSA remote network resource name supplied in the NETRESOURCE structure resolved to an invalid network address.

Remarks
If the dwScope parameter is equal to RESOURCE_CONNECTED, a network connection made using the Microsoft LAN Manager network is omitted from the enumeration if the connection was made by an application running in a different logon session than the application calling the WNetOpenEnum function. This is because connections made using Microsoft LAN Manager are visible only to applications running in the same logon session as the application that made the connection. (To include the connection in the enumeration, it is not sufficient for the application to be running in the user account that created the connection.)
The exact interpretation of RESOURCE_CONTEXT in the dwScope parameter depends on the networks installed on the machine.
The WNetOpenEnum function is used to begin enumeration of the resources in a single container. The following examples show the hierarchical structure of a Microsoft LAN Manager network and a Novell NetWare network and identify the containers.
LanMan (container, in this case the provider)
ACCOUNTING (container, in this case the domain)
\\\\ACCTSPAY (container, in this case the server)
PAYFILES (disk)
LASERJET (print)

NetWare (container, in this case the provider)
MARKETING (container, in this case the server)
SYS (disk, first one on any NetWare server)
ANOTHERVOLUME (disk)
LASERJET (print)
Examples
For a code sample that illustrates an application-defined function that enumerates all the resources on a network, see Enumerating Network Resources .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode and ANSI namesWNetOpenEnumW (Unicode) and WNetOpenEnumA (ANSI)
See Also
Windows Networking (WNet) Overview
Windows Networking Functions
NETRESOURCE
WNetCloseEnum
WNetEnumResource
Send comments about this topic to Microsoft
Build date: 8/6/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa385478(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:23:26