Article ID: 173620
Article Last Modified on 11/21/2006
res = WNetGetUser("VERYBADPATHDESCRIPTION", szName, cbName)
The function will return NO_ERROR (Zero) indicating that it was successful,
even though there is no drive letter or other path, and the szName
parameter will receive the user's logged in name.
-or-
// Link with MPR.LIB
#include <windows.h>
#include <stdio.h>
#include <winnetwk.h>
void main(int argc, char *argv[])
{
TCHAR szName[50];
DWORD cbName = 50;
int res;
if((res = WNetGetUser(argv[1], szName, &cbName)) == NO_ERROR)
printf("UserName:\t%s\n", szName);
else
printf("Error: %d\n", res);
return;
}
Keywords: kbapi kbnetwork kbprb kbwnet KB173620