"tincctl stop" now removes the tinc service on Windows.

This commit is contained in:
Guus Sliepen 2011-07-17 19:23:52 +02:00
parent c6c989cfa1
commit 25091454da
2 changed files with 41 additions and 30 deletions

View file

@ -53,7 +53,7 @@ static SC_HANDLE service = NULL;
static SERVICE_STATUS status = {0};
static SERVICE_STATUS_HANDLE statushandle = 0;
bool install_service(void) {
static bool install_service(void) {
char command[4096] = "\"";
char **argp;
bool space;
@ -113,35 +113,6 @@ bool install_service(void) {
return true;
}
bool remove_service(void) {
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(!manager) {
logger(LOG_ERR, "Could not open service manager: %s", winerror(GetLastError()));
return false;
}
service = OpenService(manager, identname, SERVICE_ALL_ACCESS);
if(!service) {
logger(LOG_ERR, "Could not open %s service: %s", identname, winerror(GetLastError()));
return false;
}
if(!ControlService(service, SERVICE_CONTROL_STOP, &status))
logger(LOG_ERR, "Could not stop %s service: %s", identname, winerror(GetLastError()));
else
logger(LOG_INFO, "%s service stopped", identname);
if(!DeleteService(service)) {
logger(LOG_ERR, "Could not remove %s service: %s", identname, winerror(GetLastError()));
return false;
}
logger(LOG_INFO, "%s service removed", identname);
return true;
}
DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) {
switch(request) {
case SERVICE_CONTROL_INTERROGATE: