网站首页  词典首页

请输入您要查询的函数:

 

术语 wnetaddconnection3
释义 WNetAddConnection3
语法:
C++
DWORD WNetAddConnection3(
__in HWND hwndOwner,
__in LPNETRESOURCE lpNetResource,
__in LPTSTR lpPassword,
__in LPTSTR lpUserName,
__in DWORD dwFlags
);
WNetAddConnection3功能
该WNetAddConnection3函数将连接到网络资源。该函数可以重定向本地设备网络资源。
该WNetAddConnection3功能类似于WNetAddConnection2函数。主要的区别是WNetAddConnection3有一个附加的参数,句柄一个窗口,对网络资源的提供者可以使用一个对话框的所有者窗口。在WNetAddConnection2函数和WNetAddConnection3功能取代WNetAddConnection功能。
参数
hwndOwner [in]
句柄的一个窗口,对网络资源的提供者可以使用一个对话框的所有者窗口。使用这个参数如果设置在dwFlags参数CONNECT_INTERACTIVE值。
该hwndOwner参数可以为NULL。如果是,对WNetAddConnection3调用等效于调用WNetAddConnection2函数。
lpNetResource [in]
一个 NETRESOURCE结构,指定连接的建议,如有关网络资源的信息,详细的指针,本地设备和网络资源提供商。
您必须指定的NETRESOURCE结构以下成员。
MemberMeaning
网络资源dwTypeThe类型连接。
如果lpLocalName成员指向一个非空字符串,该成员可以等于RESOURCETYPE_DISK或RESOURCETYPE_PRINT。
如果lpLocalName是NULL,或者如果它指向一个空字符串,却提示可以等于RESOURCETYPE_DISK,RESOURCETYPE_PRINT,或RESOURCETYPE_ANY。
虽然这个成员是必需的,它的信息可能被忽略的网络服务供应商。
lpLocalNameA指向一个空结束的字符串,它指定了一个本地设备名,如重定向的“F:”或“中将”lpt1。该字符串被视为一个不区分大小写的方式。
如果字符串为空或lpLocalName为NULL,则函数将网络资源没有重定向本地设备的连接。
lpRemoteNameA指向一个空结束的字符串,它指定了网络资源的连接。该字符串可达MAX_PATH字符的长度,而且必须遵循网络提供商的命名约定。
lpProviderA指向一个空结束的字符串,指定供应商的网络连接。
如果lpProvider是NULL,或者如果它指向一个空字符串解析字符串,操作系统尝试确定正确的供应商指出,由lpRemoteName成员。
如果这个成员不是NULL,操作系统尝试建立连接只名为网络提供商。
您应该设置这个成员仅当您知道您的网络提供商要使用。否则,让操作系统确定网络提供网络的名称映射到。
该WNetAddConnection3函数忽略了NETRESOURCE结构的其他成员。
lpPassword [in]
一个指向 null 结尾的字符串指针,指定要使用的密码,在使网络连接。
如果lpPassword为NULL,则函数使用当前默认密码与由lpUserName参数指定的用户关联。
如果lpPassword指向一个空字符串,该函数不使用密码。
如果连接失败,因为一个无效的密码和CONNECT_INTERACTIVE值在dwFlags参数设置,函数显示一个对话框,要求用户输入密码。
Windows 95/98中:此参数必须为NULL或空字符串。
lpUserName [in]
一个指向 null 结尾的字符串指针,用于指定建立连接的用户名。
如果lpUserName为NULL,则函数使用默认的用户名。 (在这个进程的用户上下文提供了默认用户名。)
该lpUserName参数指定当用户想连接到网络资源,他们被分配一个用户名或帐户比默认的用户名或账户。
用户名字符串都代表一个安全上下文。这可能是特定于网络提供商。
Windows 95/98中:此参数必须为NULL或空字符串。
dwFlags [in]
一个连接选项。下面的值是当前定义。
ValueMeaning
CONNECT_INTERACTIVEIf设置此标志,操作系统可能会互动的用户进行身份验证。
CONNECT_PROMPTThis标志指示系统不使用情况下为用户提供的机会,提供一个可供选择的用户名或密码任何默认设置。这个标志被忽略,除非CONNECT_INTERACTIVE也设置。
CONNECT_REDIRECTThis旗部队的地方时,连接设备重定向。
如果NETRESOURCE lpLocalName成员指定本地设备重定向,这个标志没有任何效果,因为操作系统仍然试图重定向指定的设备。当操作系统自动选择本地设备,却提示成员必须不等于RESOURCETYPE_ANY。
如果此标志没有设置,本地设备自动重定向选择了只有在网络要求本地设备被重定向。
Windows Server 2003和Windows XP的:当系统自动分配网络驱动器字母,字母Z开头指派:,则Y:,并结束与C:。这将减少每次登录(如网络驱动器号)和全球驱动器号(如磁盘驱动器)驱动器号相撞。请注意,早期版本的Windows分配驱动器号开始的C:和结束与Z:。
CONNECT_UPDATE_PROFILEThe网络资源的连接应该记住。
如果此位标志设置,操作系统会自动尝试恢复连接时,用户登录。
该操作系统还记得成功的连接重定向本地设备。它不记得连接不成功或deviceless连接。 (阿deviceless连接时发生lpLocalName成员为NULL或当它指向一个空字符串。)
如果此位标志清晰,操作系统不会自动恢复在登录连接。
CONNECT_COMMANDLINEIf这标志设置,操作系统会提示使用命令行,而不是一个图形用户界面(GUI)认证的用户。这个标志被忽略,除非CONNECT_INTERACTIVE也设置。
的Windows 2000/NT和Windows 95/98:此值不支持。
CONNECT_CMD_SAVECREDIf设置此标志,和操作系统的一个凭据提示,凭据应当由凭据经理保存。如果凭据经理是调用者的登录会话,或者如果网络运营商不支持保存凭据残疾人,此标志将被忽略。这个标志也被忽略,除非您设置CONNECT_COMMANDLINE标志。
的Windows 2000/NT和Windows 95/98:此值不支持。
返回值
如果函数成功,返回值为NO_ERROR。
如果函数失败,返回值是一个系统错误代码,如下列值之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe调用方不具有访问网络资源。
ERROR_ALREADY_ASSIGNEDThe本地设备的lpLocalName成员中指定已经连接到网络资源。
ERROR_BAD_DEV_TYPEThe类型的本地设备和网络资源类型不匹配。
ERROR_BAD_DEVICEThe值lpLocalName指定无效。
ERROR_BAD_NET_NAMEThe价值的lpRemoteName成员中指定的是不能接受的任何网络资源供应商,或者因为资源名称是无效的,或者因为命名的资源无法找到。
ERROR_BAD_PROFILEThe用户配置文件是不正确的格式。
ERROR_BAD_PROVIDERThe价值的lpProvider成员中指定不符合任何供应商。
ERROR_BUSYThe路由器或供应商正忙,可能初始化。打电话者应该重试。
ERROR_CANCELLEDThe企图使连接被取消通过一个对话框,从网络资源供应商,或由一个所谓的资源由用户。
ERROR_CANNOT_OPEN_PROFILEThe系统无法打开用户配置文件来处理持久连接。
ERROR_DEVICE_ALREADY_REMEMBEREDAn进入由lpLocalName成员中指定的设备已在用户配置文件。
ERROR_EXTENDED_ERRORA网络特定的错误。调用WNetGetLastError函数获取错误的描述。
ERROR_INVALID_PASSWORDThe指定的密码无效,CONNECT_INTERACTIVE未设置标志。
ERROR_NO_NET_OR_BAD_PATHThe操作无法执行,因为网络组件没有启动,或因为某一指定名称无法使用。
ERROR_NO_NETWORKThe网络不可用。
备注
该WNetUseConnection功能类似于WNetAddConnection3功能。主要的区别是WNetUseConnection可以自动选择一个未使用本地设备来重定向到网络资源。
在Windows Server 2003和Windows XP中,WNet函数创建和删除网络驱动器的MS字母- DOS设备命名与登录会话,因为MS - DOS设备是由AuthenticationID确定(本地唯一的标识符,或的LUID,与相关的关联登录会话。)这可能会影响应用程序的WNet函数调用来创建下一个用户登录网络驱动器号,现有的网络驱动器字母,但在不同的用户登录查询。这种情况的一个例子是,当用户的第二个登录,在登录会话中创建,例如,通过调用运行CreateProcessAsUser函数,第二个登录的应用程序调用GetLogicalDrives函数。到GetLogicalDrives函数调用不返回的网络驱动器由WNet函数创建信呼吁在首次登录。请注意,在前面的例子中第一个登录会话仍然存在,而且例子可以适用于任何登录会话,包括终端服务会话。有关更多信息,请参见定义一个MS - DOS设备名。
在Windows Server 2003和Windows XP中,如果一个服务作为LocalSystem运行调用WNetAddConnection3函数,然后映射的驱动器是大家有目共睹的用户登录会话。
对于微软网络供应商,该NETRESOURCE结构lpRemoteName委员指出的lpNetResource参数可以包含在点分十进制IPv4地址。一种每股例如可以如下:
\\ \\ 192.168.1.1 \\共享
在Windows Vista和更高版本Microsoft网络供应商,该NETRESOURCE结构lpRemoteName委员指出的lpNetResource参数可以包含一个IPv6地址。但是,IPv6的文字格式必须使用,使IPv6的地址是正确解析。一个IPv6地址是文字的形式:
IPv6的与':'由'替换的字符地址- '字符其次是“。IPv6的literal.net”字符串。
例如,下面的IPv6地址:
2001:4898:9:3:c069:aa97:fe76:2449
为每股例如可以如下:
\\ \\ 2001 - 4898 - 9 - 3 - c069 - aa97 - fe76 - 2449.ipv6 - literal.net \\共享
其他网络供应商可能会支持NETRESOURCE结构lpRemoteName委员指出的lpNetResource参数包含一个IPv4或IPv6地址,但是这是符合特定网络提供商。
Windows 7和Windows服务器2008 R2:如果WNetAddConnection3函数调用明确的用户在pUsername和lpPassword指定的凭据,以建立与特定服务器上的网络资源的连接,然后要求与这些参数为NULL或再次(使用默认的用户名或默认密码)到相同的服务器,与呼叫失败。返回的错误将ERROR_BAD_USERNAME或ERROR_INVALID_PASSWORD。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode和ANSI namesWNetAddConnection3W(Unicode)和WNetAddConnection3A(ANSI)的
参见
Windows网络(WNet)概述
Windows网络函数
NETRESOURCE
WNetAddConnection2
WNetCancelConnection2
WNetUseConnection
WNetGetConnection
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月6日
==英文原文==WNetAddConnection3 Function
The WNetAddConnection3 function makes a connection to a network resource. The function can redirect a local device to the network resource.
The WNetAddConnection3 function is similar to the WNetAddConnection2 function. The main difference is that WNetAddConnection3 has an additional parameter, a handle to a window that the provider of network resources can use as an owner window for dialog boxes. The WNetAddConnection2 function and the WNetAddConnection3 function supersede the WNetAddConnection function.
Syntax
C++
DWORD WNetAddConnection3(
__in HWND hwndOwner,
__in LPNETRESOURCE lpNetResource,
__in LPTSTR lpPassword,
__in LPTSTR lpUserName,
__in DWORD dwFlags
);
Parameters
hwndOwner [in]
A handle to a window that the provider of network resources can use as an owner window for dialog boxes. Use this parameter if you set the CONNECT_INTERACTIVE value in the dwFlags parameter.
The hwndOwner parameter can be NULL. If it is, a call to WNetAddConnection3 is equivalent to calling the WNetAddConnection2 function.
lpNetResource [in]
A pointer to a NETRESOURCE structure that specifies details of the proposed connection, such as information about the network resource, the local device, and the network resource provider.
You must specify the following members of the NETRESOURCE structure.
MemberMeaning
dwTypeThe type of network resource to connect to.
If the lpLocalName member points to a nonempty string, this member can be equal to RESOURCETYPE_DISK or RESOURCETYPE_PRINT.
If lpLocalName is NULL, or if it points to an empty string, dwType can be equal to RESOURCETYPE_DISK, RESOURCETYPE_PRINT, or RESOURCETYPE_ANY.
Although this member is required, its information may be ignored by the network service provider.
lpLocalNameA pointer to a null-terminated string that specifies the name of a local device to redirect, such as "F:" or "LPT1". The string is treated in a case-insensitive manner.
If the string is empty or if lpLocalName is NULL, the function makes a connection to the network resource without redirecting a local device.
lpRemoteNameA pointer to a null-terminated string that specifies the network resource to connect to. The string can be up to MAX_PATH characters in length, and must follow the network provider's naming conventions.
lpProviderA pointer to a null-terminated string that specifies the network provider to connect to.
If lpProvider is NULL, or if it points to an empty string, the operating system attempts to determine the correct provider by parsing the string pointed to by the lpRemoteName member.
If this member is not NULL, the operating system attempts to make a connection only to the named network provider.
You should set this member only if you know which network provider you want to use. Otherwise, let the operating system determine which network provider the network name maps to.

The WNetAddConnection3 function ignores the other members of the NETRESOURCE structure.
lpPassword [in]
A pointer to a null-terminated string that specifies a password to be used in making the network connection.
If lpPassword is NULL, the function uses the current default password associated with the user specified by the lpUserName parameter.
If lpPassword points to an empty string, the function does not use a password.
If the connection fails because of an invalid password and the CONNECT_INTERACTIVE value is set in the dwFlags parameter, the function displays a dialog box asking the user to type the password.
Windows Me/98/95: This parameter must be NULL or an empty string.
lpUserName [in]
A pointer to a null-terminated string that specifies a user name for making the connection.
If lpUserName is NULL, the function uses the default user name. (The user context for the process provides the default user name.)
The lpUserName parameter is specified when users want to connect to a network resource for which they have been assigned a user name or account other than the default user name or account.
The user-name string represents a security context . It may be specific to a network provider.
Windows Me/98/95: This parameter must be NULL or an empty string.
dwFlags [in]
A set of connection options. The following values are currently defined.
ValueMeaning
CONNECT_INTERACTIVEIf this flag is set, the operating system may interact with the user for authentication purposes.
CONNECT_PROMPTThis flag instructs the system not to use any default settings for user names or passwords without offering the user the opportunity to supply an alternative. This flag is ignored unless CONNECT_INTERACTIVE is also set.
CONNECT_REDIRECTThis flag forces the redirection of a local device when making the connection.
If the lpLocalName member of NETRESOURCE specifies a local device to redirect, this flag has no effect, because the operating system still attempts to redirect the specified device. When the operating system automatically chooses a local device, the dwType member must not be equal to RESOURCETYPE_ANY.
If this flag is not set, a local device is automatically chosen for redirection only if the network requires a local device to be redirected.
Windows Server 2003 and Windows XP: When the system automatically assigns network drive letters, letters are assigned beginning with Z:, then Y:, and ending with C:. This reduces collision between per-logon drive letters (such as network drive letters) and global drive letters (such as disk drives). Note that earlier versions of Windows assigned drive letters beginning with C: and ending with Z:.
CONNECT_UPDATE_PROFILEThe network resource connection should be remembered.
If this bit flag is set, the operating system automatically attempts to restore the connection when the user logs on.
The operating system remembers only successful connections that redirect local devices. It does not remember connections that are unsuccessful or deviceless connections. (A deviceless connection occurs when the lpLocalName member is NULL or when it points to an empty string.)
If this bit flag is clear, the operating system does not automatically restore the connection at logon.
CONNECT_COMMANDLINEIf this flag is set, the operating system prompts the user for authentication using the command line instead of a graphical user interface (GUI). This flag is ignored unless CONNECT_INTERACTIVE is also set.
Windows 2000/NT and Windows Me/98/95: This value is not supported.
CONNECT_CMD_SAVECREDIf this flag is set, and the operating system prompts for a credential, the credential should be saved by the credential manager. If the credential manager is disabled for the caller's logon session, or if the network provider does not support saving credentials, this flag is ignored. This flag is also ignored unless you set the CONNECT_COMMANDLINE flag.
Windows 2000/NT and Windows Me/98/95: This value is not supported.

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_ACCESS_DENIEDThe caller does not have access to the network resource.
ERROR_ALREADY_ASSIGNEDThe local device specified by the lpLocalName member is already connected to a network resource.
ERROR_BAD_DEV_TYPEThe type of local device and the type of network resource do not match.
ERROR_BAD_DEVICEThe value specified by lpLocalName is invalid.
ERROR_BAD_NET_NAMEThe value specified by the lpRemoteName member is not acceptable to any network resource provider, either because the resource name is invalid, or because the named resource cannot be located.
ERROR_BAD_PROFILEThe user profile is in an incorrect format.
ERROR_BAD_PROVIDERThe value specified by the lpProvider member does not match any provider.
ERROR_BUSYThe router or provider is busy, possibly initializing. The caller should retry.
ERROR_CANCELLEDThe attempt to make the connection was canceled by the user through a dialog box from one of the network resource providers, or by a called resource.
ERROR_CANNOT_OPEN_PROFILEThe system is unable to open the user profile to process persistent connections.
ERROR_DEVICE_ALREADY_REMEMBEREDAn entry for the device specified by the lpLocalName member is already in the user profile.
ERROR_EXTENDED_ERRORA network-specific error occurred. Call the WNetGetLastError function to obtain a description of the error.
ERROR_INVALID_PASSWORDThe specified password is invalid and the CONNECT_INTERACTIVE flag is not set.
ERROR_NO_NET_OR_BAD_PATHThe operation cannot be performed because a network component is not started or because a specified name cannot be used.
ERROR_NO_NETWORKThe network is unavailable.

Remarks
The WNetUseConnection function is similar to the WNetAddConnection3 function. The main difference is that WNetUseConnection can automatically select an unused local device to redirect to the network resource.
On Windows Server 2003 and Windows XP, the WNet functions create and delete network drive letters in the MS-DOS device namespace associated with a logon session because MS-DOS devices are identified by AuthenticationID (a locally unique identifier , or LUID, associated with a logon session.) This can affect applications that call one of the WNet functions to create a network drive letter under one user logon, but query for existing network drive letters under a different user logon. An example of this situation could be when a user's second logon is created within a logon session, for example, by calling the CreateProcessAsUser function, and the second logon runs an application that calls the GetLogicalDrives function. The call to the GetLogicalDrives function does not return network drive letters created by WNet function calls under the first logon. Note that in the preceding example the first logon session still exists, and the example could apply to any logon session, including a Terminal Services session. For more information, see Defining an MS-DOS Device Name .
On Windows Server 2003 and Windows XP, if a service that runs as LocalSystem calls the WNetAddConnection3 function, then the mapped drive is visible to all user logon sessions.
For Microsoft network providers, the lpRemoteName member of the NETRESOURCE structure pointed to by the lpNetResource parameter can contain an IPv4 address in dotted-decimal notation. An example for a share might be the following:
\\\\192.168.1.1\\share
For Microsoft network providers on Windows Vista and later, the lpRemoteName member of the NETRESOURCE structure pointed to by the lpNetResource parameter can contain an IPv6 address. However, the IPv6 literal format must be used so that the IPv6 address is parsed correctly. An IPv6 literal address is of the form:
ipv6-address with the ':' characters replaced by '-' characters followed by the ".ipv6-literal.net" string.
For example, for the following IPv6 address:
2001:4898:9:3:c069:aa97:fe76:2449
an example for a share might be the following:
\\\\2001-4898-9-3-c069-aa97-fe76-2449.ipv6-literal.net\\share
Other network providers may support the lpRemoteName member of the NETRESOURCE structure pointed to by the lpNetResource parameter that contains an IPv4 or IPv6 address, but this is up to specific network provider.
Windows 7 and Windows Server 2008 R2: If the WNetAddConnection3 function is called with explicit user credentials specified in the pUsername and lpPassword to establish a connection with a network resource on a specific server and then called again with either of these parameters as NULL (to use the default user name or default password) to the same server, the call with fail. The error returned will be ERROR_BAD_USERNAME or ERROR_INVALID_PASSWORD.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode and ANSI namesWNetAddConnection3W (Unicode) and WNetAddConnection3A (ANSI)
See Also
Windows Networking (WNet) Overview
Windows Networking Functions
NETRESOURCE
WNetAddConnection2
WNetCancelConnection2
WNetUseConnection
WNetGetConnection
Send comments about this topic to Microsoft
Build date: 8/6/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa385418(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:24:16