سؤال

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.

هل كانت مفيدة؟

المحلول 3

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');

نصائح أخرى

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?

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top