c++写修改Windows服务类型的代码
来源:互联网 发布:喀秋莎录屏软件录微课 编辑:程序博客网 时间:2024/06/11 20:31
- VOID DoSvcStartType()
- {
- SC_HANDLE schSCManager;
- SC_HANDLE schService;
- // Get a handle to the SCM database.
- schSCManager = OpenSCManager(
- NULL, // local computer
- NULL, // ServicesActive database
- SC_MANAGER_ALL_ACCESS); // full access rights
- if (NULL == schSCManager)
- {
- printf("OpenSCManager failed (%d)/n", GetLastError());
- return;
- }
- // Get a handle to the service.
- schService = OpenService(
- schSCManager, // SCM database
- szSvcName, // name of service
- SERVICE_CHANGE_CONFIG); // need change config access
- if (schService == NULL)
- {
- printf("OpenService failed (%d)/n", GetLastError());
- CloseServiceHandle(schSCManager);
- return;
- }
- // Change the service start type.
- SC_LOCK sclLock;
- sclLock = LockServiceDatabase(schService);
- if (! ChangeServiceConfig(
- schService, // handle of service
- SERVICE_NO_CHANGE, // service type: no change
- //SERVICE_CHANGE_CONFIG,
- SERVICE_DEMAND_START, // service start type
- SERVICE_NO_CHANGE, // error control: no change
- NULL, // binary path: no change
- NULL, // load order group: no change
- NULL, // tag ID: no change
- NULL, // dependencies: no change
- NULL, // account name: no change
- L"ABC", // password: no change
- NULL) ) // display name: no change
- {
- //SERVICE_CHANGE_CONFIG
- printf("ChangeServiceConfig failed (%d)/n", GetLastError());
- }
- else printf("Service enabled successfully./n");
- //将启动类型更改为禁用
- if (! ChangeServiceConfig(
- schService, // handle of service
- SERVICE_NO_CHANGE, // service type: no change
- SERVICE_DISABLED,
- //SERVICE_DEMAND_START, // service start type
- SERVICE_NO_CHANGE, // error control: no change
- NULL, // binary path: no change
- NULL, // load order group: no change
- NULL, // tag ID: no change
- NULL, // dependencies: no change
- NULL, // account name: no change
- NULL, // password: no change
- NULL) ) // display name: no change
- {
- //SERVICE_CHANGE_CONFIG
- printf("2:ChangeServiceConfig failed (%d)/n", GetLastError());
- }
- else printf("2:Service enabled successfully./n");
- UnlockServiceDatabase(sclLock);
- CloseServiceHandle(schService);
- CloseServiceHandle(schSCManager);
- }
- c++写修改Windows服务类型的代码
- Windows服务用C++代码实现的一些操作-1:修改服务启动类型
- c#--写windows 服务
- windows 服务的安装 可以自己写代码安装
- 写Windows服务的几点心得(C#/VS2003)
- 一个用C写的windows服务框架
- C语言写windows服务例子
- 从C代码出发写系统服务
- Delphi启动/停止Windows服务,启动类型修改为"自动"
- Delphi启动/停止Windows服务,启动类型修改为"自动"
- Delphi启动/停止Windows服务,启动类型修改为"自动"
- 第一次写Windows服务的几点心得(C#/VS2003)
- 第一次写Windows服务的几点心得(C#/VS2003)
- 第一次写Windows服务的几点心得(C#/VS2003)
- 对于C# 写windows 服务的权限。(可以对C盘等进行读写等等)
- 写Windows服务程序的五个步骤
- C# 写一个简单的Windows服务
- 修改系统服务的启动类型并启动服务
- SQL多表连接查询
- openCV平滑函数----cvSmooth
- MyBatis之select
- Windows启动参数揭秘
- HttpContext类
- c++写修改Windows服务类型的代码
- tomcat增大内存
- SQL连接查询的方式
- java.net.MalformedURLException: unknown protocol: g ; jdom2 ;
- IT职场人生系列之二十三:知识体系(专家与杂家)
- 计算机学习进阶
- HttpContext.Cache和Application的区别
- java.lang.ClassNotFoundException: org.springframework.web.portlet.DispatcherPortlet
- 提高SQL查询性能的7个法宝