Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 13559, TMHAUserList

by Markus Hajek Email: Anonymous


Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For C++Builder, Version 4.0  to 4.0 532 downloads
Copyright: No significant restrictions


Size: 2,058 bytes
Updated on Tue, 27 Jul 1999 00:00:00 GMT
Originally uploaded on Tue, 27 Jul 1999 00:00:00 GMT
SHA1 Hash: 4E40A76FA78AE6AEA3352AEA7677E138A4A64203
MD5 Hash: EC0FB74553E7AA85755C055FACB9C95A

    Explore the files in this upload

Description
cMHAUserList.cpp and .h contain the source for a component TMHAUserList.
This component demonstrates how to
a) find out which users are logged on under WinNT (including such that logged on to a share or the like)
b) find out which user is currently logged on interactively

!!! The later is reliable also when used in a service !!! - you can find out which user is logged on rather than under which user account the service is running. If no one is logged on (interactively), an empty string is returned in the GetInteractiveUser property of the component.

The techniques used here include
a) use of the WinAPI NetWkstaUserEnum() to get a list of all currently logged on users together with the domain they logged on to, from which server they come and to which other domains they are logged on, additionally
b) use of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon and its value "DefaultUserName" to find out who last logged on interactively
c) to find the currently interactively logged on user the user retrieved with b) is looked up in the list of a). If found, he is returned, otherwise an empty string is returned.


Hope somebody can use this,
it took me 2 weeks to find out a way how to get the "real" current user when running as a service under NT,


Cheers,

Markus Hájek
Vienna, Austria

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC04