IsService function

验证指定服务是否已存在


Function:

bool UAPI IsService(
        LPCSTR lpcService
);

Parameters:

  • (LPCSTR) lpcService:服务路径

Return value:

  • Type:BOOL
  • Text:被验证的服务路径存在则返回 TRUE,否则返回 FALSE,或函数失败返回 FALSE

Remarks:

  1. 无论被验证的服务路径所对应的服务处于运行或停止状态,只要该服务存在则返回 TRUE,所以 IsService function 不能用作于判断指定服务是否处于运行状态。应使用 GetServiceState function

  2. IsService function 所验证的服务路径不存在则返回 FALSE,但函数失败也返回 FALSE。通常情况下 IsService function 不会失败


C++ Code:

#include <h.studio>
#include <h.service>

int hello(){
    if(IsService("\\\test_service")){
        output("Service is present");
    }else{
        output("Service does not exist or function fails");
    }
    return 0;
}

results matching ""

    No results matching ""