WNetGetConnection

This function is used to determine the name of the network resource associated with a local device.

DWORD WNetGetConnection(
    LPTSTR lpLocalName,
    LPTSTR lpRemoteName,
    LPDWORD lpBufferSize
    );
 
lpLocalName
Contains the name of the local device the caller is interested in.
lpRemoteName
Points to a buffer to receive the remote name used to make the connection.
lpBufferSize
This is used to specify the size of the buffer passed in. If the call fails because the buffer is not big enough, this location will be used to return the required buffer size.
WN_BAD_LOCALNAME lpLocalName is invalid
WN_NOT_CONNECTED lpLocalName not a redirected device
WN_MORE_DATA the buffer is too small
WN_CONNECTION_CLOSED the device is not currently connected, but it is a persistent connection.
WN_FUNCTION_BUSY The MPR or NP is busy (possibly initializing). The caller should retry.
WN_NO_NETWORK network is not present
WN_EXTENDED_ERROR a network specific error occurred. WNetGetLastError should be called to obtain a description of the error.