delphi的自定义函数调用方法
functionServiceGetStatus(sMachine,sService:string):DWord;varschm,schs:SC_Handle;ss:TS...
function ServiceGetStatus(sMachine, sService: string ): DWord;
var
schm, schs: SC_Handle;
ss: TServiceStatus;
dwStat : DWord;
begin
dwStat := 0;
schm := OpenSCManager(PChar(sMachine), Nil, SC_MANAGER_CONNECT);
if(schm > 0)then
begin
schs := OpenService(schm, PChar(sService), SERVICE_QUERY_STATUS);
if(schs > 0)then
begin
if(QueryServiceStatus(schs, ss))then
begin
dwStat := ss.dwCurrentState;
end;
CloseServiceHandle(schs);
end;
CloseServiceHandle(schm);
end;
Result := dwStat;
end;
{判断某服务是否安装,未安装返回true,已安装返回false}
function ServiceUninstalled(sMachine, sService : string ) : boolean;
begin
Result := 0 = ServiceGetStatus(sMachine, sService);
end;
{判断某服务是否启动,启动返回true,未启动返回false}
function ServiceRunning(sMachine, sService : string ) : boolean;
begin
Result := SERVICE_RUNNING = ServiceGetStatus(sMachine, sService );
end;
{判断某服务是否停止,停止返回true,未停止返回false}
function ServiceStopped(sMachine, sService : string ) : boolean;
begin
Result := SERVICE_STOPPED = ServiceGetStatus(sMachine, sService );
end;
以上是代码,请问各位大爷,咋调用呢?谢谢 我是初学者。。。 展开
var
schm, schs: SC_Handle;
ss: TServiceStatus;
dwStat : DWord;
begin
dwStat := 0;
schm := OpenSCManager(PChar(sMachine), Nil, SC_MANAGER_CONNECT);
if(schm > 0)then
begin
schs := OpenService(schm, PChar(sService), SERVICE_QUERY_STATUS);
if(schs > 0)then
begin
if(QueryServiceStatus(schs, ss))then
begin
dwStat := ss.dwCurrentState;
end;
CloseServiceHandle(schs);
end;
CloseServiceHandle(schm);
end;
Result := dwStat;
end;
{判断某服务是否安装,未安装返回true,已安装返回false}
function ServiceUninstalled(sMachine, sService : string ) : boolean;
begin
Result := 0 = ServiceGetStatus(sMachine, sService);
end;
{判断某服务是否启动,启动返回true,未启动返回false}
function ServiceRunning(sMachine, sService : string ) : boolean;
begin
Result := SERVICE_RUNNING = ServiceGetStatus(sMachine, sService );
end;
{判断某服务是否停止,停止返回true,未停止返回false}
function ServiceStopped(sMachine, sService : string ) : boolean;
begin
Result := SERVICE_STOPPED = ServiceGetStatus(sMachine, sService );
end;
以上是代码,请问各位大爷,咋调用呢?谢谢 我是初学者。。。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询