Retrieving a User Name
A version of this page is also available for
4/8/2010
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;
}
See Also
Concepts
Windows Networking API/Redirector Application Development
Managing Network Connections with WNet
Retrieving Network Data