This function retrieves the remote name of the network resource associated with a local name.
At a Glance
Header file: | Winnetwk.h |
Windows CE versions: | 2.0 and later |
Syntax
DWORD WNetGetConnection( LPCTSTR lpLocalName,
LPTSTR lpRemoteName, LPDWORD lpnLength);
Parameters
lpLocalName
[in] Long pointer to a null-terminated string that specifies the local name of the network resource. Set up this resource with the WNetAddConnection3 function.
lpRemoteName
[out] Long pointer to a buffer that receives the null-terminated remote name used to make the connection.
lpnLength
[in/out] Long pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpRemoteName parameter. If the function fails because the buffer is not big enough, this parameter returns the required buffer size.
Return Values
ERROR_SUCCESS indicates success. An error value indicates failure. To get extended error information, call GetLastError. Possible GetLastError error values are described in the following table.
Value | Description |
ERROR_BAD_DEVICE | The string pointed to by the lpLocalName parameter is invalid. |
ERROR_NOT_CONNECTED | The network resource specified by lpLocalName is not currently connected and is not a persistent connection. |
ERROR_MORE_DATA | The lpRemoteName 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_UNAVAIL | The network resource specified by lpLocalName is not currently connected and is a persistent connection. |
ERROR_NO_NETWORK | No network is present. |
The WNetGetConnection function returns error values for compatibility with Windows for Workgroups. For compatibility with the Win32 API, the function also sets the error value returned by GetLastError.
Remarks
The WNetGetConnection function can be used to obtain information on network resources, such as printers.
See Also