本篇內(nèi)容主要講解“Python服務(wù)程序代碼怎么寫”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“Python服務(wù)程序代碼怎么寫”吧!
創(chuàng)新互聯(lián)建站專注于曾都企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站開發(fā),成都做商城網(wǎng)站。曾都網(wǎng)站建設(shè)公司,為曾都等地區(qū)提供建站服務(wù)。全流程按需定制,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)#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服務(wù)程序代碼怎么寫”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)建站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!