网站首页  词典首页

请输入您要查询的函数:

 

术语 wnetgetconnection
释义 WNetGetConnection
语法:
C++
DWORD WNetGetConnection(
__in LPCTSTR lpLocalName,
__out LPTSTR lpRemoteName,
__inout LPDWORD lpnLength
);
WNetGetConnection功能
该WNetGetConnection函数检索与本地设备相关的网络资源的名称。
参数
lpLocalName [in]
指针常量NULL结尾的字符串,指定本地设备名获取网络名称。
lpRemoteName [out]
指向一个以NULL结尾的字符串,它接收远程名称用于建立连接。
lpnLength [ in , out ]
指针变量指定的缓冲区大小指向的lpRemoteName参数,以字符。如果函数失败,因为缓冲区不够大,此参数返回所需的缓冲区大小。
返回值
如果函数成功,返回值为NO_ERROR。
如果函数失败,返回值是一个系统错误代码,如下列值之一。
返回codeDescription
ERROR_BAD_DEVICEThe字符串指出的lpLocalName参数是无效的。
ERROR_NOT_CONNECTEDThe设备指定的lpLocalName不是重定向设备。有关详细信息,请参阅下面的备注部分。
ERROR_MORE_DATAThe缓冲区太小。在lpnLength参数指向一个变量,它包含所需的缓冲区大小。更多的项目,可与后续调用。
ERROR_CONNECTION_UNAVAILThe设备当前未连接上,但它是一个持久连接。有关详细信息,请参阅下面的备注部分。
ERROR_NO_NETWORKThe网络不可用。
ERROR_EXTENDED_ERRORA网络特定的错误。要获取该错误的描述,调用WNetGetLastError功能。
对供应商ERROR_NO_NET_OR_BAD_PATHNone承认有一个连接的本地名称。然而,网络不可用至少一个供应商,其中可能属于该连接。
备注
如果网络连接了使用Microsoft LAN Manager的网络,并调用应用程序在不同的登录会话中运行的应用程序比所作的方面,为相关的本地设备调用WNetGetConnection函数将失败。函数失败ERROR_NOT_CONNECTED或ERROR_CONNECTION_UNAVAIL。这是因为使用的连接,Microsoft LAN Manager中是可见的只是应用相同的登录会话中运行的应用程序建立的连接。 (为避免失败,是没有足够的应用程序调用WNetGetConnection将运行在用户帐户创建连接。)
Windows Server 2003和Windows XP中:此功能查询MS - DOS设备的登录会话,因为MS - DOS设备是由AuthenticationID确定相关的命名空间。 (一个AuthenticationID是当地唯一的标识符,或的LUID,与登录会话相关联。)这可能会影响应用程序的WNet函数调用来创建下一个用户登录网络驱动器号,但现有的网络驱动器字母查询下不同的用户登录。这种情况的一个例子是,当用户的第二个登录,在登录会话中创建,例如,通过调用运行CreateProcessAsUser函数,第二个登录的应用程序调用GetLogicalDrives函数。 GetLogicalDrives不会返回网络驱动器由一个WNet函数下创建首次登录字母。请注意,在前面的例子中第一个登录会话仍然存在,而且例子可以适用于任何登录会话,包括终端服务会话。有关更多信息,请参见定义一个MS - DOS设备名。
实例
有关代码示例,演示如何使用WNetGetConnection函数来检索与本地设备相关的网络资源的名称,请参见检索连接名称。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode和ANSI namesWNetGetConnectionW(Unicode)和WNetGetConnectionA(ANSI)的
参见
Windows网络(WNet)概述
Windows网络函数
WNetAddConnection2
WNetAddConnection3
WNetGetUser
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月6日
==英文原文==WNetGetConnection Function
The WNetGetConnection function retrieves the name of the network resource associated with a local device.
Syntax
C++
DWORD WNetGetConnection(
__in LPCTSTR lpLocalName,
__out LPTSTR lpRemoteName,
__inout LPDWORD lpnLength
);
Parameters
lpLocalName [in]
Pointer to a constant null-terminated string that specifies the name of the local device to get the network name for.
lpRemoteName [out]
Pointer to a null-terminated string that receives the remote name used to make the connection.
lpnLength [in, out]
Pointer to a variable that specifies the size of the buffer pointed to by the lpRemoteName parameter, in characters. If the function fails because the buffer is not large enough, this parameter returns the required buffer size.
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_DEVICEThe string pointed to by the lpLocalName parameter is invalid.
ERROR_NOT_CONNECTEDThe device specified by lpLocalName is not a redirected device. For more information, see the following Remarks section.
ERROR_MORE_DATAThe buffer is too small. The lpnLength parameter points to a variable that contains the required buffer size. More entries are available with subsequent calls.
ERROR_CONNECTION_UNAVAILThe device is not currently connected, but it is a persistent connection. For more information, see the following Remarks section.
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_NO_NET_OR_BAD_PATHNone of the providers recognize the local name as having a connection. However, the network is not available for at least one provider to whom the connection may belong.

Remarks
If the network connection was made using the Microsoft LAN Manager network, and the calling application is running in a different logon session than the application that made the connection, a call to the WNetGetConnection function for the associated local device will fail. The function fails with ERROR_NOT_CONNECTED or ERROR_CONNECTION_UNAVAIL. This is because a connection made using Microsoft LAN Manager is visible only to applications running in the same logon session as the application that made the connection. (To prevent the call to WNetGetConnection from failing it is not sufficient for the application to be running in the user account that created the connection.)
Windows Server 2003 and Windows XP: This function queries the MS-DOS device namespaces 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 use the WNetGetConnection function to retrieve the name of the network resource associated with a local device, see Retrieving the Connection Name .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinnetwk.h
LibraryMpr.lib
DLLMpr.dll
Unicode and ANSI namesWNetGetConnectionW (Unicode) and WNetGetConnectionA (ANSI)
See Also
Windows Networking (WNet) Overview
Windows Networking Functions
WNetAddConnection2
WNetAddConnection3
WNetGetUser
Send comments about this topic to Microsoft
Build date: 8/6/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa385453(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:25:39