列出所有服务程序的代码,自己从列表中找一下。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WinSvc;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
HANDLE: SC_HANDLE;
buf: array [0..500] of TEnumServiceStatusA;
BytesNeeded, ServicesReturned, ResumeHandle: DWORD;
I: Integer;
begin
HANDLE := OpenSCManager(nil, nil, SC_MANAGER_ENUMERATE_SERVICE);
ResumeHandle := 0;
EnumServicesStatus(HANDLE, SERVICE_WIN32, SERVICE_ACTIVE or SERVICE_INACTIVE,
buf[0], sizeOf(Buf), BytesNeeded, ServicesReturned, ResumeHandle);
ListBox1.Items.Clear;
for I := 0 to ServicesReturned - 1 do
begin
listbox1.Items.add(StrPas(buf.lpDisplayName));
end;
CloseServiceHandle(HANDLE);
end;
end.