Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a list of user profiles on a computer in C++ Win32

Tags:

c++

winapi

What is the best way to enumerate all of the user profiles on a computer?

I know how to get the currently logged in user profile, and I know how to get the "all user" profile. But I'd like to get a list of each and every profile on the computer.

like image 613
Net Citizen Avatar asked Sep 03 '09 21:09

Net Citizen


People also ask

How do I get a list of users in Windows?

Open Computer Management, and go to “Local Users and Groups -> Users.” On the right side, you get to see all the user accounts, their names as used by Windows behind the scenes, their full names (or the display names), and, in some cases, also a description.

How do I list all users on a Windows system PowerShell?

Use Get-LocalUser PowerShell cmdlet to List All User Accounts. The Get-LocalUser PowerShell cmdlet lists all the local users on a device.

How do I find users on a server?

Step 1- Open the Command Line Interface by running "cmd" in the run dialog box (Win + R). Step 2- Type query user and press Enter. It will list all users that are currently logged on your computer.


1 Answers

Before going the undocumented route like flokra suggests, I would try NetUserEnum() or NetQueryDisplayInformation()

If you want to go into undocumented land, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList has a (incomplete) list of accounts (It's missing special accounts like ASPNET, HelpAssistant and SUPPORT_xxxx) It also has the path to the profile folder, which is a lot safer than using %ALLUSERSPROFILE%\..\ but why use it when there is GetProfilesDirectory()

like image 126
Anders Avatar answered Sep 28 '22 06:09

Anders