如何把系统服务添加到listview
unit Unit1;
interface
uses
WinSvc,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
type
TESS = array[0..4096] of TEnumServiceStatus;
PESS = ^TESS;
var
pSvc: PESS;
hSCManager: SC_HANDLE;
nRetByte, nRetNum, nRetResume: DWORD;
i: Integer;
begin
hSCManager := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS);
if hSCManager <= 0 then
Exit;
nRetResume := 0;
New(pSvc);
EnumServicesStatus(hSCManager, SERVICE_WIN32, SERVICE_STATE_ALL, pSvc^[0], SizeOf(pSvc^),
nRetByte, nRetNum, nRetResume);
for i := 0 to nRetNum - 1 do
begin
ListBox1.Items.Add(pSvc^[i].lpDisplayName);
end;
Dispose(pSvc);
CloseServiceHandle(hSCManager);
end;
end.
我看到别人的代码.但是此方法是加入到listbox 我需要加入到listveiw
不光要有服务名.还要有相关的描述.状态等.希望高手给个例子.