网站首页  词典首页

请输入您要查询的函数:

 

术语 wnetcancelconnection2
释义 WNetCancelConnection2
语法:
C++
DWORD WNetCancelConnection2(
__in LPCTSTR lpName,
__in DWORD dwFlags,
__in BOOL fForce
);
WNetCancelConnection2功能
该WNetCancelConnection2函数取消现有的网络连接。您还可以调用函数删除记忆网络当前未连接的连接。
该WNetCancelConnection2函数取代WNetCancelConnection功能。
参数
lpName [in]
指针常量NULL结尾的字符串,指定或者重定向的本地设备或远程网络资源的名称断开。
如果该参数指定了一个重定向的本地设备,只取消该函数指定的设备重定向。如果该参数指定远程网络资源,所有连接的设备没有被取消。
dwFlags [in]
连接类型。下面的值定义。
ValueMeaning
0The系统不更新有关该连接的信息。
如果连接是在注册表中持续显着,该系统继续恢复在下次登录连接。如果连接没有持续的标记,该函数忽略了CONNECT_UPDATE_PROFILE标志的设置。
CONNECT_UPDATE_PROFILEThe系统更新的信息,连接不再是一个持久的一用户配置文件。
该系统将不会恢复在随后登录该行动有关。 (断开资源使用远程名称并没有对持续连接的效果。)
fForce [in]
指定是否应该发生的断如果有打开的文件或连接工作。如果此参数为FALSE,函数失败如果有打开的文件或工作。
返回值
如果函数成功,返回值为NO_ERROR。
如果函数失败,返回值是一个系统错误代码,如下列值之一。
返回codeDescription
ERROR_BAD_PROFILEThe用户配置文件是不正确的格式。
ERROR_CANNOT_OPEN_PROFILEThe系统无法打开用户配置文件来处理持久连接。
ERROR_DEVICE_IN_USEThe设备使用中的一个积极的过程,不能断开。
ERROR_EXTENDED_ERRORA网络特定的错误。要获取该错误的描述,调用WNetGetLastError功能。
ERROR_NOT_CONNECTEDThe名称的lpName参数指定不是重定向设备或系统当前没有连接到该参数指定的设备。
ERROR_OPEN_FILESThere是打开的文件,并fForce参数为FALSE。
备注
Windows Server 2003和Windows XP中:在WNet函数创建和删除网络驱动器的MS字母- DOS设备命名与登录会话,因为MS - DOS设备是由AuthenticationID确定相关。 (一个AuthenticationID是当地唯一的标识符,或的LUID,与登录会话相关联。)这可能会影响应用程序的WNet函数调用来创建下一个用户登录网络驱动器号,但现有的网络驱动器字母查询下不同的用户登录。这种情况的一个例子是,当用户的第二个登录,在登录会话中创建,例如,通过调用运行CreateProcessAsUser函数,第二个登录的应用程序调用GetLogicalDrives函数。 GetLogicalDrives不会返回网络驱动器由一个WNet函数下创建首次登录字母。请注意,在前面的例子中第一个登录会话仍然存在,而且例子可以适用于任何登录会话,包括终端服务会话。有关更多信息,请参见定义一个MS - DOS设备名。
实例
有关代码示例,演示如何取消连接到网络资源,以期在WNetCancelConnection2函数调用,请取消网络连接。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode和ANSI namesWNetCancelConnection2W(Unicode)和WNetCancelConnection2A(ANSI)的
参见
Windows网络(WNet)概述
Windows网络函数
WNetAddConnection2
WNetAddConnection3
WNetGetConnection
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月6日
==英文原文==WNetCancelConnection2 Function
The WNetCancelConnection2 function cancels an existing network connection. You can also call the function to remove remembered network connections that are not currently connected.
The WNetCancelConnection2 function supersedes the WNetCancelConnection function.
Syntax
C++
DWORD WNetCancelConnection2(
__in LPCTSTR lpName,
__in DWORD dwFlags,
__in BOOL fForce
);
Parameters
lpName [in]
Pointer to a constant null-terminated string that specifies the name of either the redirected local device or the remote network resource to disconnect from.
If this parameter specifies a redirected local device, the function cancels only the specified device redirection. If the parameter specifies a remote network resource, all connections without devices are canceled.
dwFlags [in]
Connection type. The following values are defined.
ValueMeaning
0The system does not update information about the connection.
If the connection was marked as persistent in the registry, the system continues to restore the connection at the next logon. If the connection was not marked as persistent, the function ignores the setting of the CONNECT_UPDATE_PROFILE flag.
CONNECT_UPDATE_PROFILEThe system updates the user profile with the information that the connection is no longer a persistent one.
The system will not restore this connection during subsequent logon operations. (Disconnecting resources using remote names has no effect on persistent connections.)

fForce [in]
Specifies whether the disconnection should occur if there are open files or jobs on the connection. If this parameter is FALSE, the function fails if there are open files or jobs.
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_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_IN_USEThe device is in use by an active process and cannot be disconnected.
ERROR_EXTENDED_ERRORA network-specific error occurred. To obtain a description of the error, call the WNetGetLastError function.
ERROR_NOT_CONNECTEDThe name specified by the lpName parameter is not a redirected device, or the system is not currently connected to the device specified by the parameter.
ERROR_OPEN_FILESThere are open files, and the fForce parameter is FALSE.

Remarks
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. (An AuthenticationID is the 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. GetLogicalDrives does not return network drive letters created by a WNet function 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 .
Examples
For a code sample that illustrates how to cancel a connection to a network resource with a call to the WNetCancelConnection2 function, see Canceling a Network Connection .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode and ANSI namesWNetCancelConnection2W (Unicode) and WNetCancelConnection2A (ANSI)
See Also
Windows Networking (WNet) Overview
Windows Networking Functions
WNetAddConnection2
WNetAddConnection3
WNetGetConnection
Send comments about this topic to Microsoft
Build date: 8/6/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa385427(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:28:50