扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
本篇内容主要讲解“Python服务程序代码怎么写”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Python服务程序代码怎么写”吧!
创新互联建站专注于曾都企业网站建设,响应式网站开发,成都做商城网站。曾都网站建设公司,为曾都等地区提供建站服务。全流程按需定制,专业设计,全程项目跟踪,创新互联建站专业和态度为您提供的服务#include "stdafx.h"
#include
using namespace std;
class CDSvr{
public:
static void ShowHelp(void);
CDSvr(){para=NULL;};
CDSvr(_TCHAR* argv[]);
~CDSvr(){};
void Run();
static bool CreateSvr(_TCHAR* svrname,_TCHAR* path);
static bool DeleteSvr(_TCHAR* svrname);
private:
_TCHAR** para;
};
CDSvr::CDSvr(_TCHAR* argv[]){
para=argv;
Run();
}
void CDSvr::Run(){
}
void CDSvr::ShowHelp(){
cout<<" [use] "<
bool CDSvr::CreateSvr(_TCHAR *svrname, _TCHAR *path){
SC_HANDLE sch=::OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE);
if( NULL==sch ){
cout<<"openSCManager failed!"<
}
SC_HANDLE sccs=NULL;
if( NULL==(sccs=::CreateService( sch,svrname,svrname,
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS,
SERVICE_AUTO_START,SERVICE_ERROR_NORMAL,path,NULL,NULL,NULL,NULL,NULL)
)
){
cout<<"CreateService Error"<
::CloseHandle(sccs);
return false;
}
::CloseHandle(sch);
::CloseHandle(sccs);
return true;
}
bool CDSvr::DeleteSvr(_TCHAR *svrname){
SC_HANDLE sch=::OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE);
if( NULL==sch ){
cout<<"openSCManager failed!"<
}
SC_HANDLE sc=::OpenService(sch,svrname,SERVICE_ALL_ACCESS);
if( NULL==sc ){
cout<<"open services failed!"<
::CloseHandle(sc);
return false;
}
if(::DeleteService(sc)){
cout<<"delete "<
cout<<"delete "<
::CloseHandle(sch);
::CloseHandle(sc);
return true;
};
int _tmain(int argc, _TCHAR* argv[])
{
if( argc<2 ){
CDSvr::ShowHelp();
}else if( argc==2 ){
if(CDSvr::DeleteSvr( argv[argc-1])){
cout<< " DONE !!!"<
cout<< " ERROR!!!"<
}else if( argc==3 ){
if(CDSvr::CreateSvr(argv[argc-2],argv[argc-1])){
cout<<" DONE!!!"<
cout<<" ERROR!!"<
}
return 0;
}
到此,相信大家对“Python服务程序代码怎么写”有了更深的了解,不妨来实际操作一番吧!这里是创新互联建站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流