WNetGetConnection

  DWORD WNetGetConnection(lpszLocalName, lpszRemoteName, lpcchBuffer)    
  LPTSTR lpszLocalName; /* pointer to local name */
  LPTSTR lpszRemoteName; /* pointer to buffer for remote name */
  LPDWORD lpcchBuffer; /* pointer to buffer size (in characters) */

The WNetGetConnection function retrieves the name of the network resource associated with a local device.

Parameters

lpszLocalName

Points to a null-terminated string that specifies the name of the local device to get the network name for.

lpszRemoteName

Points to a buffer to receive the null-terminated remote name used to make the connection.

lpcchBuffer

Specifies the size (in characters) of the buffer pointed to by the lpszRemoteName parameter. If the function fails because the buffer is not big enough, this location is used to return the required buffer size.

Return Value

If the function is successful, the return value is NO_ERROR. Otherwise, it is an error code, which may be one of the following:

Value Meaning

ERROR_BAD_DEVICE The string pointed to by lpszLocalName is invalid.
ERROR_NOT_CONNECTED The device specified by lpszLocalName is not redirected.
ERROR_MORE_DATA The buffer is too small. The lpcchBuffer parameter contains the required buffer size.
ERROR_CONNECTION_UNAVAIL The device is not currently connected, but it is a remembered (persistent) connection.
ERROR_NO_NETWORK No network is present.
ERROR_EXTENDED_ERROR A network-specific error occurred. Use the WNetGetLastError function to obtain a description of the error.

This function returns error codes for compatibility with Windows 3.1. For compatibility with Win32, the function also sets the error-code value returned by the GetLastError function.

See Also

WNetGetLastError, WNetGetUser