NPGetUser function

Retrieves the value of the current default user name or the user name used to establish a network connection.


  _In_    LPTSTR  lpName,
  _Out_   LPTSTR  lpUserName,
  _Inout_ LPDWORD lpBufferSize


lpName [in]

Pointer to the name of the local device the caller is interested in, or a remote name for a resource that the user has made a connection to. This parameter may be NULL or the empty string if the caller is interested in the name of the user currently logged on to the system. If a remote name for a resource is passed in, and the user is connected to that resource using different names, it is possible that a provider cannot resolve which user name to return. In this case the provider may make an arbitrary choice amongst the possible user names.

lpUserName [out]

Pointer to a buffer to receive the user name. This should be a name that can be passed into the NPAddConnection or NPAddConnection3 function to re-establish the connection with the same user name.

lpBufferSize [in, out]

Pointer to the size, in characters, of the lpUserName buffer. If the call fails because the buffer is not big enough, this location will be used to return the required buffer size.

Return value

If the function succeeds, it should return WN_SUCCESS. Otherwise it should return an error code, which can be one of the following.

Return codeDescription

The value in the lpName parameter is not the name of a redirected device or a connected remote name.


The buffer, lpUserName, is too small.


The network is not present.



Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]