网站首页  词典首页

请输入您要查询的函数:

 

术语 wnetaddconnection
释义 WNetAddConnection
语法:
C++
DWORD WNetAddConnection(
__in LPCTSTR lpRemoteName,
__in LPCTSTR lpPassword,
__in LPCTSTR lpLocalName
);
WNetAddConnection功能
该WNetAddConnection功能可调用应用程序的本地设备连接到网络资源。一个成功的连接是一贯的,也就是说,系统会自动恢复登录在随后的行动有关。
注意:此功能仅提供了兼容性与16位的Windows版本。其他基于Windows的应用程序应该调用WNetAddConnection2或WNetAddConnection3功能。
参数
lpRemoteName [in]
阿为一个恒定的空指针结尾的字符串,它指定了网络资源的连接。
lpPassword [in]
阿为一个恒定的空指针结尾的字符串,指定要使用的密码进行连接。此参数通常是与当前用户关联的密码。
如果该参数为NULL,则默认密码是使用。如果字符串是空的,没有密码的使用。
Windows 95/98中:此参数必须为NULL或空字符串。
lpLocalName [in]
阿为一个恒定的空指针结尾的字符串,它指定了一个本地设备名被重定向,例如“传真:”或“中将”lpt1。该字符串被视为一个不区分大小写的方式。如果字符串为NULL,是对网络资源的连接是在没有重定向本地设备。
返回值
如果函数成功,返回值为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_CANNOT_OPEN_PROFILEThe系统无法打开用户配置文件来处理持久连接。
ERROR_DEVICE_ALREADY_REMEMBEREDAn项在lpLocalName参数指定的设备已在用户配置文件。
ERROR_EXTENDED_ERRORA网络特定的错误。要获取该错误的描述,调用WNetGetLastError功能。
ERROR_INVALID_PASSWORDThe无效指定的密码。
ERROR_NO_NET_OR_BAD_PATHThe操作无法执行,因为网络组件没有启动,或因为某一指定名称无法使用。
ERROR_NO_NETWORKThe网络不可用。
备注
在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运行调用WNetAddConnection函数,然后映射的驱动器是大家有目共睹的用户登录会话。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode和ANSI namesWNetAddConnectionW(Unicode)和WNetAddConnectionA(ANSI)的
参见
Windows网络(WNet)概述
Windows网络函数
WNetAddConnection2
WNetAddConnection3
WNetCancelConnection
WNetCancelConnection2
WNetGetConnection
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月6日
==英文原文==WNetAddConnection Function
The WNetAddConnection function enables the calling application to connect a local device to a network resource. A successful connection is persistent, meaning that the system automatically restores the connection during subsequent logon operations.
Note This function is provided only for compatibility with 16-bit versions of Windows. Other Windows-based applications should call the WNetAddConnection2 or the WNetAddConnection3 function.
Syntax
C++
DWORD WNetAddConnection(
__in LPCTSTR lpRemoteName,
__in LPCTSTR lpPassword,
__in LPCTSTR lpLocalName
);
Parameters
lpRemoteName [in]
A pointer to a constant null-terminated string that specifies the network resource to connect to.
lpPassword [in]
A pointer to a constant null-terminated string that specifies the password to be used to make a connection. This parameter is usually the password associated with the current user.
If this parameter is NULL, the default password is used. If the string is empty, no password is used.
Windows Me/98/95: This parameter must be NULL or an empty string.
lpLocalName [in]
A pointer to a constant null-terminated string that specifies the name of a local device to be redirected, such as "F:" or "LPT1". The string is treated in a case-insensitive manner. If the string is NULL, a connection to the network resource is made without redirecting the local device.
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 device specified in the lpLocalName parameter is already connected.
ERROR_BAD_DEV_TYPEThe device type and the resource type do not match.
ERROR_BAD_DEVICEThe value specified in the lpLocalName parameter is invalid.
ERROR_BAD_NET_NAMEThe value specified in the lpRemoteName parameter is not valid or cannot be located.
ERROR_BAD_PROFILEThe user profile is in an incorrect format.
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 in the lpLocalName parameter is already in the user profile.
ERROR_EXTENDED_ERRORA network-specific error occurred. To obtain a description of the error, call the WNetGetLastError function.
ERROR_INVALID_PASSWORDThe specified password is invalid.
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
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 WNetAddConnection function, then the mapped drive is visible to all user logon sessions.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode and ANSI namesWNetAddConnectionW (Unicode) and WNetAddConnectionA (ANSI)
See Also
Windows Networking (WNet) Overview
Windows Networking Functions
WNetAddConnection2
WNetAddConnection3
WNetCancelConnection
WNetCancelConnection2
WNetGetConnection
Send comments about this topic to Microsoft
Build date: 8/6/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa385410(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:26:44