P
paf
Unregistered / Unconfirmed
GUEST, unregistred user!
USES
..,Winsvc;
.......
procedure TForm1.Button8Click(Sender: TObject);
var
re: SC_HANDLE;
szserviceName, szDisplayName: LPCTSTR;
begin
if open1.Execute then begin
hscmanager := OpenSCManager(nil, //指定计算机名,若为空则指定为本机
nil, //指定要打开的service control manager database,默认为空
SC_MANAGER_ENUMERATE_SERVICE //指定操作的权限
); //打开service control manager database
if hscmanager < 0 then
begin
showmessage('无法打开service control manager database');
exit;
end;
szserviceName := 'abc';
szDisplayName := 'BBBBBBBBBb';
Re := CreateService(hscmanager,
szServiceName,
szServiceName,
SC_MANAGER_ENUMERATE_SERVICE,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
LPCTSTR(open1.FileName),
nil,
nil,
nil,
nil,
nil);
caption :=format('返回信息: %s [%d]',[SysErrorMessage(GetLastError),GetLastError]);
end;
end;
Re 的返回值总为"0"
caption 返回信息总是: 拒绝访问! [5]
..,Winsvc;
.......
procedure TForm1.Button8Click(Sender: TObject);
var
re: SC_HANDLE;
szserviceName, szDisplayName: LPCTSTR;
begin
if open1.Execute then begin
hscmanager := OpenSCManager(nil, //指定计算机名,若为空则指定为本机
nil, //指定要打开的service control manager database,默认为空
SC_MANAGER_ENUMERATE_SERVICE //指定操作的权限
); //打开service control manager database
if hscmanager < 0 then
begin
showmessage('无法打开service control manager database');
exit;
end;
szserviceName := 'abc';
szDisplayName := 'BBBBBBBBBb';
Re := CreateService(hscmanager,
szServiceName,
szServiceName,
SC_MANAGER_ENUMERATE_SERVICE,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
LPCTSTR(open1.FileName),
nil,
nil,
nil,
nil,
nil);
caption :=format('返回信息: %s [%d]',[SysErrorMessage(GetLastError),GetLastError]);
end;
end;
Re 的返回值总为"0"
caption 返回信息总是: 拒绝访问! [5]