为 Service Application 添加描述文本的方法
给NT服务型程序加描述的方法,在网上找了找,好像只有通过用注册表的方法比较方便与实用。
自己整理了一下,帖出来共享。自己测试了一下,OK!
procedure ServiceUpdateDescription(const ServiceName, Description: string);
var
reg: TRegistry;
begin
reg := TRegistry.Create;
try
with reg do begin
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('SYSTEM\CurrentControlSet\Services\' + ServiceName, False) then
begin
WriteString('Description', Description);
end;
CloseKey;
end;
finally
reg.Free;
end;
end;
var
reg: TRegistry;
begin
reg := TRegistry.Create;
try
with reg do begin
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('SYSTEM\CurrentControlSet\Services\' + ServiceName, False) then
begin
WriteString('Description', Description);
end;
CloseKey;
end;
finally
reg.Free;
end;
end;
作者: 陆岛工作室