7

I would like to add a button to my application ( frontend to a service) that will open the service properties dialog (like in services mmc snapin ) for my service.

There are numerous examples to open file properties, but that is not what i want. i dont know where to start.

Lawrence Ward
  • 549
  • 1
  • 5
  • 17
  • 1
    I'm not sure if this is possible. You could use the ServiceController class and build your own dialog quite easilly. – Panos Rontogiannis Nov 26 '12 at 16:18
  • i already use the service control manager api to do the basic things like installing, starting, stoping, uninstalling... however i want to add the properties dialog so that the user can customize other properties for the service like recovery options – Lawrence Ward Nov 27 '12 at 10:44
  • I see. I cannot find a way to do this using the API in System.serviceProcess. The answer in the following question http://stackoverflow.com/questions/6364700/setting-recovery-options-on-windows-services shows an approach on how to handle the recovery yourself. – Panos Rontogiannis Nov 27 '12 at 15:16
  • i am positive that there must be a way that is similar to the file properties dialog(using ShellExecute). for example: how do other processes open the display properties dialog or other similar dialogs that are often associated with the shell? – Lawrence Ward Nov 27 '12 at 19:00
  • @twittfort, you can see my example to do that – Alex Egorov Mar 16 '20 at 12:56

3 Answers3

6

Based off of the services.msc, the page comes from filemgmt.dll and is called ServicePageGeneral. While the COM components are registered, I cannot find any documentation for the CLSID in question, nor for any of the other strings present in filemgmt.dll.

This does not rule out the possibility that there exists an established API, or a command line option to show the dialog, but I certainly can't find one.

Further substantiating the case that the dialog is not reusable, Process Explorer and SQL Server Configuration Manager both re-implement the dialog, rather than showing the services.msc version.

Related: How do I open properties box for individual services from command line or link?

Community
  • 1
  • 1
Mitch
  • 21,223
  • 6
  • 63
  • 86
1

You should develop you custom "Service Console", with .NET and WMI classes you can query the service list in the computer, get the actual status, aditionally you should execute Windows Commands from you application to Start, Stop Services.

Eduardo Vélez
  • 193
  • 1
  • 4
  • i really dont want to duplicate what the operating system has already done. any administrator already knows how to use this dialog. – Lawrence Ward Nov 21 '14 at 08:50
  • Lawrence, you still need the dialog two years after asking the question? :) – Bohdan Nov 21 '14 at 10:56
  • I do, it would realy make a nifty aditional feature to my offering. At the time I decided that the effort required to make my own was too much and the feature has never been included. – Lawrence Ward Nov 24 '14 at 09:03
0

Today I'm found that this is possible!

This is code on Delphi, which uses MMC 2.0 Automation Object Model

var
  objMMC: OleVariant;

procedure ShowSvcProperties(const ASvcName: string);
var
  objView, objList, objItem: OleVariant;
  SvcEnum: IEnumVariant;
  Value: UInt32;
  sName: string;
begin
  objMMC := CreateOleObject('MMC20.Application');
  objMMC.Load('services.msc');
  objView := objMMC.Document.ActiveView;
  objList := objView.ListItems;
  SvcEnum := IUnknown(objList._NewEnum) as IEnumVariant;
  while SvcEnum.Next(1, objItem, Value) = S_OK do
  try
    sName := objItem.Name;
    if SameText(sName, ASvcName) then begin
      objView.Select(objItem);
      objView.DisplaySelectionPropertySheet;
      Break;
    end;
  finally
    VariantClear(objItem);
  end;
end;

And now to show service properties dialog just call ShowSvcProperties('Plug and Play');

Alex Egorov
  • 907
  • 7
  • 26