Retrieving a User Name

Windows CE 3.0

An application can use the WNetGetUser function to retrieve the name of the user associated with a connected network resource. The following code example shows how WNetGetUser function retrieves a user name based on a device name called MyDevice.

TCHAR szUserName[80];
DWORD dwResult, 
      cchBuffer = 80;

dwResult = WNetGetUser (TEXT("MyDevice"), szUserName, &cchBuffer);

if (dwResult == ERROR_SUCCESS)
  MessageBox (hwnd, szUserName, TEXT("Info"), MB_OK);
else 
{
  ErrorHandler (hwnd, dwResult, TEXT("WNetGetUser"));
  return FALSE;
} 

 Last updated on Friday, April 02, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.

Show: