Ignore:
Timestamp:
08/17/10 11:23:57 (21 months ago)
Author:
jay
Message:

-- win32service application with start, stop, uninstall service, and start server normally integrated into one package. This is the initial commit for this approach.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/win32service/svccontrol/src/svccontrol.cpp

    r73 r78  
    44#include <aclapi.h> 
    55#include <stdio.h> 
    6  
    7 #pragma comment(lib, "advapi32.lib") 
    8  
    9 TCHAR szCommand[10]; 
    10 TCHAR szSvcName[80]; 
     6#include "svccontrol.h" 
     7 
     8TCHAR szControlCommand[TEXT_SIZE]; 
     9TCHAR szControlSvcName[TEXT_SIZE]; 
    1110 
    1211SC_HANDLE schSCManager; 
    1312SC_HANDLE schService; 
    1413 
    15 VOID __stdcall DisplayUsage(void); 
    16  
    17 VOID __stdcall DoStartSvc(void); 
    18 VOID __stdcall DoUpdateSvcDacl(void); 
    19 VOID __stdcall DoStopSvc(void); 
    20  
    21 BOOL __stdcall StopDependentServices(void); 
     14#pragma comment(lib, "advapi32.lib") 
     15 
    2216 
    2317// 
     
    3125//   None 
    3226// 
    33 void _tmain(int argc, TCHAR *argv[]) 
     27//void _tmain(int argc, TCHAR *argv[]) 
     28void svccontrol(TCHAR * argv[]) 
    3429{ 
    35     printf("\n"); 
     30    /*printf("\n"); 
     31         
    3632    if( argc != 3 ) 
    3733    { 
     
    4036        return; 
    4137    } 
    42  
    43     StringCchCopy(szCommand, 10, argv[1]); 
    44     StringCchCopy(szSvcName, 80, argv[2]); 
    45  
    46     if (lstrcmpi( szCommand, TEXT("start")) == 0 ) 
     38        */ 
     39    StringCchCopy(szControlCommand, TEXT_SIZE, argv[1]); 
     40    StringCchCopy(szControlSvcName, TEXT_SIZE, argv[2]); 
     41 
     42    if (lstrcmpi( szControlCommand, TEXT("startService")) == 0 ) 
    4743        DoStartSvc(); 
    48     else if (lstrcmpi( szCommand, TEXT("dacl")) == 0 ) 
     44    else if (lstrcmpi( szControlCommand, TEXT("dacl")) == 0 ) 
    4945        DoUpdateSvcDacl(); 
    50     else if (lstrcmpi( szCommand, TEXT("stop")) == 0 ) 
     46    else if (lstrcmpi( szControlCommand, TEXT("stopService")) == 0 ) 
    5147        DoStopSvc(); 
    5248    else  
    5349    { 
    54         _tprintf(TEXT("Unknown command (%s)\n\n"), szCommand); 
    55         DisplayUsage(); 
     50        _tprintf(TEXT("Unknown command (%s)\n\n"), szControlCommand); 
     51       // DisplayUsage(); 
    5652    } 
    5753} 
    58  
     54/* 
    5955VOID __stdcall DisplayUsage() 
    6056{ 
     
    6864    printf("\t  stop\n"); 
    6965} 
    70  
     66*/ 
    7167// 
    7268// Purpose:  
     
    104100    schService = OpenService(  
    105101        schSCManager,         // SCM database  
    106         szSvcName,            // name of service  
     102        szControlSvcName,            // name of service  
    107103        SERVICE_ALL_ACCESS);  // full access  
    108104  
     
    336332    schService = OpenService(  
    337333        schSCManager,              // SCManager database  
    338         szSvcName,                 // name of service  
     334        szControlSvcName,                 // name of service  
    339335        READ_CONTROL | WRITE_DAC); // access 
    340336  
     
    474470    schService = OpenService(  
    475471        schSCManager,         // SCM database  
    476         szSvcName,            // name of service  
     472        szControlSvcName,            // name of service  
    477473        SERVICE_STOP |  
    478474        SERVICE_QUERY_STATUS |  
Note: See TracChangeset for help on using the changeset viewer.