使用vc创建删除windows服务
// Register the control request handler status.dwCurrentState = SERVICE_START_PENDING; status.dwControlsAccepted = SERVICE_ACCEPT_STOP; //注册服务控制 hServiceStatus = RegisterServiceCtrlHandler(szServiceName, ServiceStrl); if (hServiceStatus == NULL) { LogEvent(_T("Handler not installed")); return; } SetServiceStatus(hServiceStatus, &status); status.dwWin32ExitCode = S_OK; status.dwCheckPoint = 0; status.dwWaitHint = 0; status.dwCurrentState = SERVICE_RUNNING; SetServiceStatus(hServiceStatus, &status); //模拟服务的运行,10后自动退出。应用时将主要任务放于此即可 int i = 0; while (i < 10) { Sleep(1000); i++; } // status.dwCurrentState = SERVICE_STOPPED; SetServiceStatus(hServiceStatus, &status); LogEvent(_T("Service stopped")); }
- 1
- 粉丝: 0
- 资源: 6
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助