summaryrefslogtreecommitdiffstats
path: root/admin/Sources/Clients/ogAdmWinClient/sources/servicio.h
blob: 760d2c1adfc46a1d053850ffd30a0a8c0879e211 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// ******************************************************************************************************************************************************************************
// Aplicación HIDRA
// Copyright 2003-2005 José Manuel Alonso. Todos los derechos reservados.
// Fichero: servicio.h
//	Descripción:
//		Este proyecto implementa el servicio hidra en un ordenador con plataforma windows NT. Este fichero aporta las funciones para crear el servicio
// ******************************************************************************************************************************************************************************
//____________________________________________________________________________________________________________________________
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (C) 1993-1997  Microsoft Corporation.  All Rights Reserved.
//
//  MODULE: service.h
//  AUTHOR: Craig Link
//
//  Comments:  The use of this header file and the accompanying service.c
//  file simplifies the process of writting a service.  You as a developer
//  simply need to follow the TODO's outlined in this header file, and 
//  implement the ServiceStart() and ServiceStop() functions.
//  
//  There is no need to modify the code in service.c.  Just add service.c
//  to your project and link with the following libraries...
//
//  libcmt.lib kernel32.lib advapi.lib shell32.lib
//
//  This code also supports unicode.  Be sure to compile both service.c and
//  and code #include "service.h" with the same Unicode setting.
//
//  Upon completion, your code will have the following command line interface
//
//  <service exe> -?                to display this list
//  <service exe> -install          to install the service
//  <service exe> -remove           to remove the service
//  <service exe> -debug <params>   to run as a console app for debugging
//
//  Note: This code also implements Ctrl+C and Ctrl+Break handlers
//        when using the debug option.  These console events cause
//        your ServiceStop routine to be called
//
//        Also, this code only handles the OWN_SERVICE service type
//        running in the LOCAL_SYSTEM security context.
//
//        To control your service ( start, stop, etc ) you may use the
//        Services control panel applet or the NET.EXE program.
//
//        To aid in writing/debugging service, the
//        SDK contains a utility (MSTOOLS\BIN\SC.EXE) that
//        can be used to control, configure, or obtain service status.
//        SC displays complete status for any service/driver
//        in the service database, and allows any of the configuration
//        parameters to be easily changed at the command line.
//        For more information on SC.EXE, type SC at the command line.
//
//____________________________________________________________________________________________________________________________
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <tchar.h>
#include "registrow.h"

#ifndef _SERVICE_H
#define _SERVICE_H

#ifdef __cplusplus
extern "C" {
#endif

// name of the executable
#define SZAPPNAME "ogAdmWinClient"
// internal name of the service
#define SZSERVICENAME "Cliente Opengnsys"
// displayed name of the service
#define SZSERVICEDISPLAYNAME "Cliente Opengnsys"
// list of service dependencies - "dep1\0dep2\0\0"
#define SZDEPENDENCIES ""

#define SERVIDOR_DEFAULT "0.0.0.0" 
#define PUERTO_DEFAULT	 "2003"	
#define IPLOCAL_DEFAULT "0.0.0.0"

#define CHKREGISTRY(f) if (!(f)) { return 0;}
#define RMVREGISTRY(f) if (!(f)) { return 0;}
#define TOMAPARAMINT(p) p=atoi(&argv[i][3]); 
#define TOMAPARAMSTR(p) strcpy(p,&argv[i][3]);

#define HIVE HKEY_LOCAL_MACHINE				// Rama del registro donde estarán los parametros de conexión
#define BASEKEY "SOFTWARE\\opengnsys"	// Key del registro para parametros de conexión
#define BASE "SOFTWARE\\opengnsys\\cliente"	// SubKey del registro para parametros de conexión

//____________________________________________________________________________________________________________________________
//
SERVICE_STATUS   ssStatus;       // current status of the service
SERVICE_STATUS_HANDLE   sshStatusHandle;
//
//____________________________________________________________________________________________________________________________
//		ServiceStart()must be defined by in your code.
//		The service should use ReportStatusToSCMgr to indicate
//		progress.  This routine must also be used by StartService()
//		to report to the SCM when the service is running.
//
//		If a ServiceStop procedure is going to take longer than
//		3 seconds to execute, it should spawn a thread to
//		execute the stop code, and return.  Otherwise, the
//		ServiceControlManager will believe that the service has
//		stopped responding
//
//____________________________________________________________________________________________________________________________
VOID ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv);
VOID ServiceStop();
//____________________________________________________________________________________________________________________________
//	The following are procedures which
//	may be useful to call within the above procedures,
//	but require no implementation by the user.
//	They are implemented in service.c
//
//  FUNCTION: ReportStatusToSCMgr()
//
//  PURPOSE: Sets the current status of the service and
//           reports it to the Service Control Manager
//
//  PARAMETERS:
//    dwCurrentState - the state of the service
//    dwWin32ExitCode - error code to report
//    dwWaitHint - worst case estimate to next checkpoint
//
//  RETURN VALUE:
//    TRUE  - success 
//    FALSE - failure
//____________________________________________________________________________________________________________________________
BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint);
//____________________________________________________________________________________________________________________________
//  FUNCTION: AddToMessageLog(LPTSTR lpszMsg)
//
//  PURPOSE: Allows any thread to log an error message
//
//  PARAMETERS:
//    lpszMsg - text for message
//
//  RETURN VALUE:
//    none
//____________________________________________________________________________________________________________________________
void AddToMessageLog(LPTSTR lpszMsg);
//____________________________________________________________________________________________________________________________
//
#ifdef __cplusplus
}
#endif

#endif