version 1.39, 2005/02/13 21:58:47
|
version 1.40, 2005/02/22 21:41:54
|
|
|
static HANDLE pegasus_service_event = NULL; | static HANDLE pegasus_service_event = NULL; |
static LPCSTR g_cimservice_key = TEXT("SYSTEM\\CurrentControlSet\\Services\\%s"); | static LPCSTR g_cimservice_key = TEXT("SYSTEM\\CurrentControlSet\\Services\\%s"); |
static LPCSTR g_cimservice_home = TEXT("home"); | static LPCSTR g_cimservice_home = TEXT("home"); |
|
static int g_argc = 0; |
|
static char **g_argv = 0; |
| |
// Constants representing the command line options. | // Constants representing the command line options. |
static const char OPTION_INSTALL[] = "install"; | static const char OPTION_INSTALL[] = "install"; |
|
|
//------------------------------------------------------------------------- | //------------------------------------------------------------------------- |
static unsigned __stdcall cimserver_windows_thread( void* parm ) | static unsigned __stdcall cimserver_windows_thread( void* parm ) |
{ | { |
int argc = 0; |
int rc = cimserver_run( g_argc, g_argv, false ); |
int rc = cimserver_run( argc, 0, false ); |
|
SetEvent(pegasus_service_event); | SetEvent(pegasus_service_event); |
_endthreadex( rc ); | _endthreadex( rc ); |
return rc; | return rc; |
|
|
// | // |
| |
unsigned threadid = 0; | unsigned threadid = 0; |
|
g_argc = argc; |
|
g_argv = argv; |
HANDLE hThread = (HANDLE)_beginthreadex( NULL, 0, cimserver_windows_thread, NULL, 0, &threadid ); | HANDLE hThread = (HANDLE)_beginthreadex( NULL, 0, cimserver_windows_thread, NULL, 0, &threadid ); |
if( hThread == NULL ) | if( hThread == NULL ) |
return 1; | return 1; |
|
|
//------------------------------------------------------------------------- | //------------------------------------------------------------------------- |
// START | // START |
//------------------------------------------------------------------------- | //------------------------------------------------------------------------- |
bool cimserver_start_nt_service(char *service_name) |
bool cimserver_start_nt_service(char *service_name, int num_args, char **service_args) |
{ | { |
Service::ReturnCode status = Service::SERVICE_RETURN_SUCCESS; | Service::ReturnCode status = Service::SERVICE_RETURN_SUCCESS; |
| |
|
|
pegasus_service.SetServiceName(service_name); | pegasus_service.SetServiceName(service_name); |
} | } |
| |
|
if(num_args > 0 && service_args != NULL) |
|
{ |
|
pegasus_service.SetServiceArgs(num_args, service_args); |
|
} |
|
|
status = pegasus_service.Start(5); | status = pegasus_service.Start(5); |
| |
return (status == Service::SERVICE_RETURN_SUCCESS) ? true : false; | return (status == Service::SERVICE_RETURN_SUCCESS) ? true : false; |
|
|
// Start as a NT service | // Start as a NT service |
// | // |
char *opt_arg = NULL; | char *opt_arg = NULL; |
|
int num_args = 0; |
if (i+1 < argc) | if (i+1 < argc) |
{ | { |
opt_arg = argv[i+1]; | opt_arg = argv[i+1]; |
|
num_args = argc - 3; |
} | } |
if(cimserver_start_nt_service(opt_arg)) |
else |
|
{ |
|
num_args = argc - 2; |
|
} |
|
|
|
char **service_args = &argv[1]; |
|
if(cimserver_start_nt_service(opt_arg, num_args, service_args)) |
{ | { |
//l10n | //l10n |
//cout << "\nPegasus started as NT Service"; | //cout << "\nPegasus started as NT Service"; |