Compartir a través de


Retrieving a Connection Name (Windows CE 5.0)

Send Feedback

WNet provides two functions for retrieving a connection name: WNetGetUniversalName and WNetGetConnection. WNetGetUniversalName takes a drive-based path for a network connection and obtains a more universal name in the form of a data structure.

WNetGetConnection enables an application to retrieve the name of a network resource associated with a local device. The following code example shows how WNetGetConnection retrieves the network name of a local device called MyDevice.

TCHAR szDeviceName[80];
DWORD dwResult, 
      cchBuffer = sizeof (szDeviceName);

dwResult = WNetGetConnection (TEXT("MyDevice"), szDeviceName, 
                              &cchBuffer);
switch (dwResult) 
{
  case ERROR_SUCCESS:
    MessageBox (hwnd, szDeviceName, TEXT("Info"), MB_OK);
    break;

  case ERROR_NOT_CONNECTED:
    MessageBox (hwnd, TEXT("MyDevice is not connected."), 
                TEXT("Info"), MB_OK);
    break;

  case ERROR_CONNECTION_UNAVAIL:
    // A connection is remembered, but not connected. 
    MessageBox (hwnd, TEXT("Connection unavailable."), 
                TEXT("Info"), MB_OK);
    break;

  default:
    ErrorHandler (hwnd, dwResult, TEXT("WNetGetConnection"));
    break;
} 

See Also

Windows Networking API/Redirector Application Development | Managing Network Connections with WNet | Retrieving Network Data

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.