1

How do you (programatically) show the windows local users/groups dialog? In Vista it's usually under Control Panel - Administrative Tools - Computer Management - Local Users and Groups. Similar kind of dialog with the same functionalities (add/remove users/groups) is also acceptable, as long as supported by Windows Xp and above.

Delphi codes would be great, although not necessary!

Luthfi
  • 432
  • 2
  • 5
  • 13

2 Answers2

2

It sounds like you want the Directory Object Picker dialog, documented here:

http://msdn.microsoft.com/en-us/library/ms676973(v=VS.85).aspx

It works with Windows 2000 or higher. There is some sample code here (in C++):

http://msdn.microsoft.com/en-us/library/ms675899(VS.85).aspx

Nate
  • 18,752
  • 8
  • 48
  • 54
  • I haven't tried it, but from the msdn article I assume it's to display some kind of object select dialog (which the object can be computers, users, or groups), not a simple local users/groups management. Or am I mistaken? – Luthfi Sep 20 '10 at 16:07
  • I may have mis-read your question. I thought you wanted to let the user select a user/group. It displays this dialog: http://imgur.com/Xz6Fo.png. In this example, it lets you pick a user. It can also be configured to select groups, to select from just the local computer, or to select from an Active Directory domain. (The Microsoft example code shows how to pick from a domain.) This is the “standard” way to pick a user, although it is fairly complex. – Nate Sep 20 '10 at 16:45
  • There you have it, that "standard" dialog is fairly complex for ordinary users. That's why I've created my own very simple version of it (just a list with checkboxes). However I'm not going to provide full support of adding or removing users/groups. – Luthfi Sep 21 '10 at 05:22
1

Seems like you are looking for lusrmgr.msc applet. You can execute it from command line, Delphi code example:

uses
  ShellAPI;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShellExecute(Handle, 'open', 'lusrmgr.msc', nil, nil, SW_SHOWNORMAL) ;
end;
kludg
  • 27,213
  • 5
  • 67
  • 118
  • This module is not available in Windows 7 Home Premium; probably the same applies to Windows Vista Home Premium. – Andreas Rejbrand Sep 20 '10 at 14:42
  • @Andreas Rejbrand - Yes, you can't run it in Vista Home Premium. – kludg Sep 20 '10 at 14:48
  • 1
    `control lusrmgr.msc`? or `control nusrmgr.msc`? or `control userpasswords`? or `control userpasswords2`? – Sertac Akyuz Sep 20 '10 at 15:00
  • @Sertac: You cannot start a *.msc by calling `control *.msc`; simply call `*.msc` alone. Anyhow: The first exists but is merely a template. The latter does not exist. The two remaining both work. – Andreas Rejbrand Sep 20 '10 at 15:04
  • @Andreas - Ah, Ok!, I thought I was writing `.cpl` not '.msc'. Anyway, working is good.. :) – Sertac Akyuz Sep 20 '10 at 15:07
  • @Serg: I have tried it, and this is exactly what I was looking for. The only problem is the add in is not available in any of Home editions of Windows (which is answered by Sertac). – Luthfi Sep 20 '10 at 16:10
  • @Andreas and Sertac: Thanks for pointing out that this solution does not available in Home editions and for possible replacement. Anyone can give me quick code to determine Home editions of Windows? – Luthfi Sep 20 '10 at 16:11
  • @Donn - See: [How to check in delphi the OS version?..](http://stackoverflow.com/questions/1268178/how-to-check-in-delphi-the-os-version-windows-7-or-server-2008-r2/1268320#1268320) – Sertac Akyuz Sep 20 '10 at 16:51
  • @DonnVall: check if localsec.dll is present in the system32 folder on Home editions and if so try registering it (regsvr32 localsec.dll). – Remko Sep 20 '10 at 17:26
  • @Remko & Sertac: Thx for the tip! – Luthfi Sep 21 '10 at 05:18