服務程式例子

2021-04-21 00:51:39 字數 2876 閱讀 4509

#include  

#include  

#include  

#include  

const   int   nbuffersize   =   500;  

char   pservicename[nbuffersize+1];  

char   pexefile[nbuffersize+1];  

service_status                     servicestatus;    

service_status_handle       hservicestatushandle;    

void   reporterror(lpctstr   s)  

void   showdebugmsg(lpctstr   s1,lpctstr   s2)  

void   winapi   myservicehandler(dword   fdwcontrol)  

;  

if   (!setservicestatus(hservicestatushandle,     &servicestatus))    

reporterror("setservicestatus");  

}  

void   winapi   myservicemain(   dword   dwargc,   lptstr   *lpszargv   )  

//   handle   error   condition    

status   =   getlasterror();    

if   (status!=no_error)    

//   initialization   complete   -   report   running   status    

servicestatus.dwcurrentstate               =   service_running;    

servicestatus.dwcheckpoint                   =   0;    

servicestatus.dwwaithint                       =   0;      

if(!setservicestatus(hservicestatushandle,   &servicestatus))    

}  

service_table_entry       dispatchtable   =    

,    

};  

bool   killservice(char*   pname)    

else  

reporterror("controlservice");  

closeservicehandle(schservice);    

}  

closeservicehandle(schscmanager);    

}  

return   false;  

}  

bool   runservice(char*   pname,   int   narg,   char**   parg)    

else  

reporterror("startservice");  

closeservicehandle(schservice);    

}  

closeservicehandle(schscmanager);    

}  

return   false;  

}  

void   uninstall(char*   pname)  

closeservicehandle(schscmanager);  

}  

}  

void   install(char*   ppath,   char*   pname)    

else  

closeservicehandle(schscmanager);  

}  

}  

top//continue...  

void   main(int   argc,   char   *argv   )  

else  

sprintf(pexefile,"%s",argv[0]);  

char   drive[_max_drive];  

char   dir[_max_dir];  

char   ext[_max_ext];  

_splitpath(pexefile,drive,dir,pservicename,ext) ;  

if(argc==2&&_stricmp("-u",argv[1])==0)  

uninstall(pservicename);  

else   if(argc==2&&_stricmp("-i",argv[1])==0)  

install(pexefile,   pservicename);  

else   if(argc==2&&_stricmp("-b",argv[1])==0)  

else   if(argc==3&&_stricmp("-k",argv[1])==0)  

else   if(argc>=3&&_stricmp("-r",argv[1])==0)  

else    

if(!startservicectrldispatcher(dispatchtable))  

reporterror("startservicectrldispatcher");  

}  

ODBC API 程式 例子

include include include mhdbapi.h include string include using namespace std int makesqlserverodbcdsn lpctstr strdbserver,lpctstr strdbname,lpctstr st...

grpc 服務呼叫例子

1.建立乙個hello.proto 其實就是定義乙個服務,然後後面需要實現它的介面 syntax proto3 path 表示生成的go檔案的存放位址,會自動生成目錄的。name 表示生成的go檔案所屬的包名 option go package hello package hello service...

wordcount例子程式

hadoop 0.20.1裡的wordcount源 與0.19.2已經有較大的區別了。在新版本的hadoop中,org.apache.hadoop.mapred包被org.apache.hadoop.mapreduce所取代。不過為了保持相容性,org.apache.hadoop.mapred還是存...