Deleting a Service

博客介绍了服务配置程序删除服务的操作。通过OpenService函数获取对已安装服务对象具有DELETE访问权限的句柄,再利用DeleteService函数结合该句柄,将服务从SCM数据库中移除。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Deleting a Service

In the following example, a service configuration program uses the OpenService function to get a handle with DELETE access to an installed service object. The program then uses the service object handle in the DeleteService function to remove the service from the SCM database.

BOOL DeleteSampleService() 
{ 
    schService = OpenService( 
        schSCManager,       // SCManager database 
        TEXT("Sample_Srv"), // name of service 
        DELETE);            // only need DELETE access 
 
    if (schService == NULL)
    { 
        printf("OpenService failed (%d)/n", GetLastError()); 
        return FALSE;
    }
 
    if (! DeleteService(schService) ) 
    {
        printf("DeleteService failed (%d)/n", GetLastError()); 
        return FALSE;
    }
    else 
        printf("DeleteService succeeded/n"); 
 
    CloseServiceHandle(schService); 
    return TRUE;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值