Changeset 86


Ignore:
Timestamp:
08/20/10 11:19:08 (18 months ago)
Author:
jay
Message:
  • Replaced sample.h with svcdefines.h.
  • Changes the function calling for uninstall, start, and stop service to avoid declaration of global array variable (to avoid common memory leaks)
Location:
trunk/sources/win32service
Files:
1 added
1 deleted
4 edited

Legend:

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

    r78 r86  
    44#include <stdio.h> 
    55#include "svcconfig.h" 
     6#include "svc/svcdefines.h" 
    67 
    78#pragma comment(lib, "advapi32.lib") 
    89 
    9 TCHAR szConfigCommand[TEXT_SIZE]; 
    10 TCHAR szConfigSvcName[TEXT_SIZE]; 
     10//TCHAR szConfigCommand[TEXT_SIZE]; 
     11//TCHAR ConfigSvcName[TEXT_SIZE]; 
    1112 
    1213 
     
    2122//   None 
    2223// 
    23 //void __cdecl _tmain(int argc, TCHAR *argv[]) 
    24 bool svcconfig (TCHAR * argv[]) 
     24/*void __cdecl _tmain(int argc, TCHAR *argv[]) 
    2525{ 
    2626        bool result = true; 
     
    3333        return; 
    3434    } 
    35         */ 
     35         
    3636    StringCchCopy(szConfigCommand, TEXT_SIZE, argv[1]); 
    3737    StringCchCopy(szConfigSvcName, TEXT_SIZE, argv[2]); 
     
    5555        return result; 
    5656} 
    57 /* 
     57 
    5858VOID __stdcall DisplayUsage() 
    5959{ 
     
    105105    schService = OpenService(  
    106106        schSCManager,          // SCM database  
    107         szConfigSvcName,             // name of service  
     107        /*szConfigSvcName*/SVCNAME,             // name of service  
    108108        SERVICE_QUERY_CONFIG); // need query config access  
    109109  
     
    183183    // Print the configuration information. 
    184184  
    185     _tprintf(TEXT("%s configuration: \n"), szConfigSvcName); 
     185    _tprintf(TEXT("%s configuration: \n"), /*szConfigSvcName*/SVCNAME); 
    186186    _tprintf(TEXT("  Type: 0x%x\n"), lpsc->dwServiceType); 
    187187    _tprintf(TEXT("  Start Type: 0x%x\n"), lpsc->dwStartType); 
     
    239239    schService = OpenService(  
    240240        schSCManager,            // SCM database  
    241         szConfigSvcName,               // name of service  
     241        /*szConfigSvcName*/SVCNAME,               // name of service  
    242242        SERVICE_CHANGE_CONFIG);  // need change config access  
    243243  
     
    304304    schService = OpenService(  
    305305        schSCManager,            // SCM database  
    306         szConfigSvcName,               // name of service  
     306        /*szConfigSvcName*/SVCNAME,               // name of service  
    307307        SERVICE_CHANGE_CONFIG);  // need change config access  
    308308  
     
    371371    schService = OpenService(  
    372372        schSCManager,            // SCM database  
    373         szConfigSvcName,               // name of service  
     373        /*szConfigSvcName*/SVCNAME,               // name of service  
    374374        SERVICE_CHANGE_CONFIG);  // need change config access  
    375375  
     
    431431    schService = OpenService(  
    432432        schSCManager,       // SCM database  
    433         szConfigSvcName,          // name of service  
     433        /*szConfigSvcName*/SVCNAME,          // name of service  
    434434        DELETE);            // need delete access  
    435435  
  • trunk/sources/win32service/svccontrol/src/svccontrol.cpp

    r78 r86  
    55#include <stdio.h> 
    66#include "svccontrol.h" 
    7  
    8 TCHAR szControlCommand[TEXT_SIZE]; 
    9 TCHAR szControlSvcName[TEXT_SIZE]; 
     7#include "svc/svcdefines.h" 
     8 
     9//TCHAR szControlCommand[TEXT_SIZE]; 
     10//TCHAR szControlSvcName[TEXT_SIZE]; 
    1011 
    1112SC_HANDLE schSCManager; 
     
    2526//   None 
    2627// 
    27 //void _tmain(int argc, TCHAR *argv[]) 
    28 void svccontrol(TCHAR * argv[]) 
     28/*void _tmain(int argc, TCHAR *argv[]) 
     29 
    2930{ 
    3031    /*printf("\n"); 
     
    3637        return; 
    3738    } 
    38         */ 
    3939    StringCchCopy(szControlCommand, TEXT_SIZE, argv[1]); 
    4040    StringCchCopy(szControlSvcName, TEXT_SIZE, argv[2]); 
     
    5252    } 
    5353} 
    54 /* 
     54 
    5555VOID __stdcall DisplayUsage() 
    5656{ 
     
    100100    schService = OpenService(  
    101101        schSCManager,         // SCM database  
    102         szControlSvcName,            // name of service  
     102        /*szControlSvcName*/SVCNAME,            // name of service  
    103103        SERVICE_ALL_ACCESS);  // full access  
    104104  
     
    332332    schService = OpenService(  
    333333        schSCManager,              // SCManager database  
    334         szControlSvcName,                 // name of service  
     334        /*szControlSvcName*/SVCNAME,                 // name of service  
    335335        READ_CONTROL | WRITE_DAC); // access 
    336336  
     
    470470    schService = OpenService(  
    471471        schSCManager,         // SCM database  
    472         szControlSvcName,            // name of service  
     472        /*szControlSvcName*/SVCNAME,            // name of service  
    473473        SERVICE_STOP |  
    474474        SERVICE_QUERY_STATUS |  
  • trunk/sources/win32service/win32service/include/svc/svc.h

    r78 r86  
    1  
    2 #include "svc/sample.h" 
    3  
    4 #define LOGFILE "C:\\ServiceLogs.txt" 
    51 
    62SERVICE_STATUS          gSvcStatus;  
     
    2319 
    2420HANDLE hThread = NULL; 
    25 TCHAR * svcCommand[3]; 
  • trunk/sources/win32service/win32service/src/svc/svc.cpp

    r78 r86  
    33#include <tchar.h> 
    44#include <strsafe.h> 
    5 #include "svc/Svc.h" 
     5#include "svc/svc.h" 
     6#include "svc/svcdefines.h" 
     7#include "svc/serviceregistry.h" 
    68#include "rtmpserver/rtmpserver.h" 
    79#include "svccontrol.h" 
     
    911 
    1012#pragma comment(lib, "advapi32.lib") 
    11  
    12 #define SVCNAME TEXT("evo") //name of the service 
    13  
    1413 
    1514// 
     
    3029    { 
    3130                SvcInstall(); 
     31                //OpenRegistry(); 
    3232        return; 
    3333    }else if( lstrcmpi( argv[1], TEXT("uninstallService")) == 0) 
    3434    { 
    35                 AddSvcCommand(argv[1]); 
    36                 bool result = svcconfig(svcCommand);//Delete service 
     35                DoDeleteSvc(); 
    3736        return; 
    3837    }  
     
    5251    }  
    5352 
    54         // Control the service 
    55         if( lstrcmpi( argv[1], TEXT("startService")) == 0 || lstrcmpi( argv[1], TEXT("stopService")) == 0) 
    56     { 
    57         AddSvcCommand(argv[1]); 
    58                 svccontrol(svcCommand);//Start/Stop service 
    59         return; 
    60     } else { 
     53        // Control the service and start the server normally 
     54        if( lstrcmpi( argv[1], TEXT("startService")) == 0) 
     55    { 
     56                DoStartSvc(); 
     57        return; 
     58    } else if( lstrcmpi( argv[1], TEXT("stopService")) == 0) 
     59    { 
     60                DoStopSvc(); 
     61        return; 
     62    }else { 
    6163                if ( argc == 1 ) //if no argument, assume that rtmpserver is started normally 
    6264                { 
    63                         AddSvcCommand(TEXT("query")); 
    64                         if (!svcconfig(svcCommand)){ 
     65                        if (!DoQuerySvc){ 
    6566                                printf("Server will start normally.\n\n"); 
    6667                                rtmpserver(); 
     
    7677        } 
    7778 
    78 } 
    79  
    80 //Populates the svcCommand array 
    81 VOID AddSvcCommand(TCHAR * command) 
    82 { 
    83         svcCommand[0] = TEXT(""); 
    84         svcCommand[1] = command; 
    85         svcCommand[2] = SVCNAME; 
    8679} 
    8780 
Note: See TracChangeset for help on using the changeset viewer.