Commit eda4e86bdeb5eef1bc4a5200dd4d19d47cbe6d3c

Authored by anderson.peterle@previdencia.gov.br
1 parent f40c7147
Exists in master

Exclusão para posterior reposição com versão 2.6-Beta-2

git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@956 fecfc0c7-e812-0410-ae72-849f08638ee7
cacicservice/CACICsvc.cfg
... ... @@ -1,36 +0,0 @@
1   --$A8
2   --$B-
3   --$C+
4   --$D+
5   --$E-
6   --$F-
7   --$G+
8   --$H+
9   --$I+
10   --$J+
11   --$K-
12   --$L+
13   --$M-
14   --$N+
15   --$O+
16   --$P+
17   --$Q-
18   --$R-
19   --$S-
20   --$T-
21   --$U-
22   --$V+
23   --$W-
24   --$X+
25   --$YD
26   --$Z1
27   --cg
28   --AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
29   --H+
30   --W+
31   --M
32   --$M16384,1048576
33   --K$00400000
34   --E"..\"
35   --LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
36   --LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
cacicservice/CACICsvc.dof
... ... @@ -1,142 +0,0 @@
1   -[FileVersion]
2   -Version=7.0
3   -[Compiler]
4   -A=8
5   -B=0
6   -C=1
7   -D=1
8   -E=0
9   -F=0
10   -G=1
11   -H=1
12   -I=1
13   -J=1
14   -K=0
15   -L=1
16   -M=0
17   -N=1
18   -O=1
19   -P=1
20   -Q=0
21   -R=0
22   -S=0
23   -T=0
24   -U=0
25   -V=1
26   -W=0
27   -X=1
28   -Y=1
29   -Z=1
30   -ShowHints=1
31   -ShowWarnings=1
32   -UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
33   -NamespacePrefix=
34   -SymbolDeprecated=1
35   -SymbolLibrary=1
36   -SymbolPlatform=1
37   -UnitLibrary=1
38   -UnitPlatform=1
39   -UnitDeprecated=1
40   -HResultCompat=1
41   -HidingMember=1
42   -HiddenVirtual=1
43   -Garbage=1
44   -BoundsError=1
45   -ZeroNilCompat=1
46   -StringConstTruncated=1
47   -ForLoopVarVarPar=1
48   -TypedConstVarPar=1
49   -AsgToTypedConst=1
50   -CaseLabelRange=1
51   -ForVariable=1
52   -ConstructingAbstract=1
53   -ComparisonFalse=1
54   -ComparisonTrue=1
55   -ComparingSignedUnsigned=1
56   -CombiningSignedUnsigned=1
57   -UnsupportedConstruct=1
58   -FileOpen=1
59   -FileOpenUnitSrc=1
60   -BadGlobalSymbol=1
61   -DuplicateConstructorDestructor=1
62   -InvalidDirective=1
63   -PackageNoLink=1
64   -PackageThreadVar=1
65   -ImplicitImport=1
66   -HPPEMITIgnored=1
67   -NoRetVal=1
68   -UseBeforeDef=1
69   -ForLoopVarUndef=1
70   -UnitNameMismatch=1
71   -NoCFGFileFound=1
72   -MessageDirective=1
73   -ImplicitVariants=1
74   -UnicodeToLocale=1
75   -LocaleToUnicode=1
76   -ImagebaseMultiple=1
77   -SuspiciousTypecast=1
78   -PrivatePropAccessor=1
79   -UnsafeType=1
80   -UnsafeCode=1
81   -UnsafeCast=1
82   -[Linker]
83   -MapFile=0
84   -OutputObjs=0
85   -ConsoleApp=1
86   -DebugInfo=0
87   -RemoteSymbols=0
88   -MinStackSize=16384
89   -MaxStackSize=1048576
90   -ImageBase=4194304
91   -ExeDescription=
92   -[Directories]
93   -OutputDir=..\
94   -UnitOutputDir=
95   -PackageDLLOutputDir=
96   -PackageDCPOutputDir=
97   -SearchPath=
98   -Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP;MSICS_D7_Rtl;PJVersion;FileSecurity;Jcl;JclVcl;JvCoreD7R;JvSystemD7R;JvStdCtrlsD7R;JvAppFrmD7R;JvBandsD7R;JvDBD7R;JvDlgsD7R;JvBDED7R;JvCmpD7R;JvCryptD7R;JvCtrlsD7R;JvCustomD7R;JvDockingD7R;JvDotNetCtrlsD7R;JvEDID7R;JvGlobusD7R;JvHMID7R;JvInterpreterD7R;JvJansD7R;JvManagedThreadsD7R;JvMMD7R;JvNetD7R;JvPageCompsD7R;JvPluginD7R;JvPrintPreviewD7R;JvRuntimeDesignD7R;JvTimeFrameworkD7R;JvValidatorsD7R;JvWizardD7R;JvXPCtrlsD7R
99   -Conditionals=
100   -DebugSourceDirs=
101   -UsePackages=0
102   -[Parameters]
103   -RunParams=
104   -HostApplication=
105   -Launcher=
106   -UseLauncher=0
107   -DebugCWD=
108   -[Language]
109   -ActiveLang=
110   -ProjectLang=
111   -RootDir=E:\NTService\
112   -[Version Info]
113   -IncludeVerInfo=1
114   -AutoIncBuild=0
115   -MajorVer=2
116   -MinorVer=6
117   -Release=0
118   -Build=2
119   -Debug=0
120   -PreRelease=0
121   -Special=0
122   -Private=0
123   -DLL=0
124   -Locale=11274
125   -CodePage=1252
126   -[Version Info Keys]
127   -CompanyName=Dataprev - Emp. de TI da Prev Social - UDSL/SSLC
128   -FileDescription=Sistema CACIC - Módulo para Sustentação do Agente Principal
129   -FileVersion=2.6.0.2
130   -InternalName=
131   -LegalCopyright=
132   -LegalTrademarks=
133   -OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.6.0.1
136   -Comments=Licença: GNU/LGPL
137   -[HistoryLists\hlUnitAliases]
138   -Count=1
139   -Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
140   -[HistoryLists\hlOutputDirectorry]
141   -Count=1
142   -Item0=..\
cacicservice/CACICsvc.dpr
... ... @@ -1,29 +0,0 @@
1   -(**
2   ----------------------------------------------------------------------------------------------------------------------------------------------------------------
3   -Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil
4   -
5   -Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais
6   -
7   -O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
8   -publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opinião) qualquer versão.
9   -
10   -Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer
11   -MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
12   -
13   -Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software
14   -Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15   ----------------------------------------------------------------------------------------------------------------------------------------------------------------
16   -*)
17   -program CACICsvc;
18   -
19   -uses
20   - SvcMgr,
21   - CACICsvcMain in 'CACICsvcMain.pas' {CACICservice: TService},
22   - CACIC_Library in '..\CACIC_Library.pas';
23   -{$R *.RES}
24   -
25   -begin
26   - Application.Initialize;
27   - Application.CreateForm(TCACICservice, CACICservice);
28   - Application.Run;
29   -end.
cacicservice/CACICsvc.res
No preview for this file type
cacicservice/CACICsvcMain.ddp
No preview for this file type
cacicservice/CACICsvcMain.dfm
... ... @@ -1,20 +0,0 @@
1   -object CACICservice: TCACICservice
2   - OldCreateOrder = False
3   - DisplayName = 'CACICservice'
4   - Interactive = True
5   - AfterInstall = ServiceAfterInstall
6   - OnExecute = ServiceExecute
7   - OnStart = ServiceStart
8   - OnStop = ServiceStop
9   - Left = 192
10   - Top = 107
11   - Height = 375
12   - Width = 544
13   - object Timer_CHKsis: TTimer
14   - Enabled = False
15   - Interval = 60000
16   - OnTimer = Timer_CHKsisTimer
17   - Left = 464
18   - Top = 16
19   - end
20   -end
cacicservice/CACICsvcMain.pas
... ... @@ -1,384 +0,0 @@
1   -(**
2   ----------------------------------------------------------------------------------------------------------------------------------------------------------------
3   -Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil
4   -
5   -Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais
6   -
7   -O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
8   -publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opinião) qualquer versão.
9   -
10   -Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer
11   -MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
12   -
13   -Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software
14   -Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15   ----------------------------------------------------------------------------------------------------------------------------------------------------------------
16   -*)
17   -unit CACICsvcMain;
18   -
19   -interface
20   -
21   -uses
22   - Windows,
23   - Messages,
24   - SysUtils,
25   - Classes,
26   - SvcMgr,
27   - strUtils,
28   - ExtCtrls,
29   - CACIC_Library,
30   - Psapi,
31   - tlhelp32,
32   - JwaWinNT, { As units com prefixo Jwa constam do Pacote Jedi_API22a }
33   - JwaWinBase, { que pode ser obtido em http://sourceforge.net/projects/jedi-apilib/files/JEDI%20Windows%20API/JEDI%20API%202.2a%20and%20WSCL%200.9.2a/jedi_api22a_jwscl092a.zip/download }
34   - JwaWtsApi32,
35   - JwaWinSvc,
36   - JwaWinType,
37   - JwaNtStatus;
38   -
39   -var
40   - boolStarted : boolean;
41   - g_oCacic : TCACIC;
42   -
43   -//
44   -const
45   - SE_DEBUG_NAME = 'SeDebugPrivilege';
46   -//
47   -
48   -type
49   - TCACICservice = class(TService)
50   - Timer_CHKsis: TTimer;
51   - procedure ServiceExecute(Sender: TService);
52   - procedure ServiceStart(Sender: TService; var Started: Boolean);
53   - procedure ServiceAfterInstall(Sender: TService);
54   - procedure Timer_CHKsisTimer(Sender: TObject);
55   - procedure ServiceStop(Sender: TService; var Stopped: Boolean);
56   - private
57   -
58   - { Internal Start & Stop methods }
59   - function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String;
60   - procedure logDEBUG(Msg : String);
61   - Procedure WMEndSession(var Msg : TWMEndSession) ; message WM_ENDSESSION;
62   - procedure ExecutaCACIC;
63   - function startapp : integer;
64   - public
65   - { Public declarations }
66   -
67   - function GetServiceController: TServiceController; override;
68   - end;
69   -
70   -var
71   - CACICservice: TCACICservice;
72   -
73   -function CreateEnvironmentBlock(var lpEnvironment: Pointer;
74   - hToken: THandle;
75   - bInherit: BOOL): BOOL; stdcall; external 'userenv';
76   -function DestroyEnvironmentBlock(pEnvironment: Pointer): BOOL; stdcall; external 'userenv';
77   -
78   -implementation
79   -
80   -{$R *.DFM}
81   -
82   -// Solução adaptada a partir do exemplo contido em http://www.codeproject.com/KB/vista-security/VistaSessions.aspx?msg=2750630
83   -// para execução a partir de token do WinLogon, possibilitando a exibição do ícone da aplicação na bandeja do systray em
84   -// plataforma MS-VISTA.
85   -function TCACICservice.startapp : integer;
86   -var
87   - pi : PROCESS_INFORMATION;
88   - si : STARTUPINFO;
89   - bresult : boolean;
90   - dwSessionId,winlogonPid : DWORD;
91   - hUserToken,hUserTokenDup,hPToken,hProcess,hsnap : THANDLE;
92   - dwCreationFlags : DWORD;
93   - procEntry : TPROCESSENTRY32;
94   - winlogonSessId : DWORD;
95   - tp : TOKEN_PRIVILEGES;
96   - // luid : TLargeInteger;
97   - abcd, abc, dup : integer;
98   - lpenv : pointer;
99   - iResultOfCreateProcessAsUser : integer;
100   -
101   -begin
102   - Result := 0;
103   - bresult := false;
104   -
105   - //TOKEN_ADJUST_SESSIONID := 256;
106   -
107   - // Log the client on to the local computer.
108   -
109   -
110   - dwSessionId := WTSGetActiveConsoleSessionId();
111   - hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
112   - if (hSnap = INVALID_HANDLE_VALUE) then
113   - begin
114   - result := 1;
115   - exit;
116   - end;
117   -
118   - procEntry.dwSize := sizeof(TPROCESSENTRY32);
119   -
120   - if (not Process32First(hSnap, procEntry)) then
121   - begin
122   - result := 1;
123   - exit;
124   - end;
125   -
126   - repeat
127   - if (comparetext(procEntry.szExeFile, 'winlogon.exe') = 0) then
128   - begin
129   - // We found a winlogon process...
130   -
131   - // make sure it's running in the console session
132   -
133   - winlogonSessId := 0;
134   - if (ProcessIdToSessionId(procEntry.th32ProcessID, winlogonSessId) and (winlogonSessId = dwSessionId)) then
135   - begin
136   - winlogonPid := procEntry.th32ProcessID;
137   - break;
138   - end;
139   - end;
140   -
141   - until (not Process32Next(hSnap, procEntry));
142   -
143   - ////////////////////////////////////////////////////////////////////////
144   -
145   - WTSQueryUserToken(dwSessionId, hUserToken);
146   - dwCreationFlags := NORMAL_PRIORITY_CLASS or CREATE_NEW_CONSOLE;
147   - ZeroMemory(@si, sizeof(STARTUPINFO));
148   - si.cb := sizeof(STARTUPINFO);
149   - si.lpDesktop := 'winsta0\default';
150   - ZeroMemory(@pi, sizeof(pi));
151   - hProcess := OpenProcess(MAXIMUM_ALLOWED,FALSE,winlogonPid);
152   -
153   - if(not OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY
154   - or TOKEN_DUPLICATE or TOKEN_ASSIGN_PRIMARY or TOKEN_ADJUST_SESSIONID
155   - or TOKEN_READ or TOKEN_WRITE, hPToken)) then
156   - begin
157   - abcd := GetLastError();
158   - logDEBUG('Process token open Error: ' + inttostr(GetLastError()));
159   - end;
160   -
161   - if (not LookupPrivilegeValue(nil,SE_DEBUG_NAME,tp.Privileges[0].Luid)) then
162   - begin
163   - logDEBUG('Lookup Privilege value Error: ' + inttostr(GetLastError()));
164   - end;
165   -
166   - tp.PrivilegeCount := 1;
167   - tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
168   -
169   - DuplicateTokenEx(hPToken,MAXIMUM_ALLOWED,Nil,SecurityIdentification,TokenPrimary,hUserTokenDup);
170   - dup := GetLastError();
171   -
172   - // Adjust Token privilege
173   -
174   - SetTokenInformation(hUserTokenDup,TokenSessionId,pointer(dwSessionId),sizeof(DWORD));
175   -
176   - if (not AdjustTokenPrivileges(hUserTokenDup,FALSE,@tp,sizeof(TOKEN_PRIVILEGES),nil,nil)) then
177   - begin
178   - abc := GetLastError();
179   - logDEBUG('Adjust Privilege value Error: ' + inttostr(GetLastError()));
180   - end;
181   -
182   - if (GetLastError() = ERROR_NOT_ALL_ASSIGNED) then
183   - begin
184   - logDEBUG('Token does not have the provilege');
185   - end;
186   -
187   - lpEnv := nil;
188   -
189   - if(CreateEnvironmentBlock(lpEnv,hUserTokenDup,TRUE)) then
190   - begin
191   - dwCreationFlags := dwCreationFlags or CREATE_UNICODE_ENVIRONMENT;
192   - end
193   - else
194   - lpEnv := nil;
195   -
196   - // Launch the process in the client's logon session.
197   - bResult := CreateProcessAsUser( hUserTokenDup, // client's access token
198   - PAnsiChar(g_oCacic.getCacicPath + 'cacic2.exe'), // file to execute
199   - nil, // command line
200   - nil, // pointer to process SECURITY_ATTRIBUTES
201   - nil, // pointer to thread SECURITY_ATTRIBUTES
202   - FALSE, // handles are not inheritable
203   - dwCreationFlags, // creation flags
204   - lpEnv, // pointer to new environment block
205   - PAnsiChar(g_oCacic.getCacicPath), // name of current directory
206   - si, // pointer to STARTUPINFO structure
207   - pi // receives information about new process
208   - );
209   -
210   - // End impersonation of client.
211   - //GetLastError Shud be 0
212   - iResultOfCreateProcessAsUser := GetLastError();
213   -
214   - //Perform All the Close Handles tasks
215   - CloseHandle(hProcess);
216   - CloseHandle(hUserToken);
217   - CloseHandle(hUserTokenDup);
218   - CloseHandle(hPToken);
219   -end;
220   -//
221   -procedure TCACICservice.WMEndSession(var Msg : TWMEndSession) ;
222   -begin
223   - if Msg.EndSession = TRUE then
224   - logDEBUG('Windows finalizado em ' + FormatDateTime('c', Now)) ;
225   - inherited;
226   - Application.Free;
227   -end;
228   -
229   -// Funções Auxiliares
230   -function TCACICservice.GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String;
231   -//Para buscar do Arquivo INI...
232   -// Marreta devido a limitações do KERNEL w9x no tratamento de arquivos texto e suas seções
233   -//function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String;
234   -var
235   - FileText : TStringList;
236   - i, j, v_Size_Section, v_Size_Key : integer;
237   - v_SectionName, v_KeyName : string;
238   - begin
239   - logDEBUG('GetVCRini: Secao: '+p_Secao+' Chave: '+p_Chave+' File: '+p_File);
240   - Result := '';
241   - v_SectionName := '[' + p_Secao + ']';
242   - v_Size_Section := strLen(PChar(v_SectionName));
243   - v_KeyName := p_Chave + '=';
244   - v_Size_Key := strLen(PChar(v_KeyName));
245   - FileText := TStringList.Create;
246   - try
247   - FileText.LoadFromFile(p_File);
248   - For i := 0 To FileText.Count - 1 Do
249   - Begin
250   - if (LowerCase(Trim(PChar(Copy(FileText[i],1,v_Size_Section)))) = LowerCase(Trim(PChar(v_SectionName)))) then
251   - Begin
252   - For j := i to FileText.Count - 1 Do
253   - Begin
254   - if (LowerCase(Trim(PChar(Copy(FileText[j],1,v_Size_Key)))) = LowerCase(Trim(PChar(v_KeyName)))) then
255   - Begin
256   - Result := PChar(Copy(FileText[j],v_Size_Key + 1,strLen(PChar(FileText[j]))-v_Size_Key));
257   - Break;
258   - End;
259   - End;
260   - End;
261   - if (Result <> '') then break;
262   - End;
263   - finally
264   - FileText.Free;
265   - end;
266   - end;
267   -
268   -procedure TCACICservice.logDEBUG(Msg : String);
269   -var fLog: textfile;
270   -begin
271   - // Somente gravarei informações para debug se o arquivo "<HomeDrive>:\CACICsvc.log" existir
272   - if FileExists(g_oCacic.Windows.getHomeDrive + g_oCacic.Windows.getWinDir + 'CACICsvc.log') then
273   - Begin
274   - AssignFile(fLog, g_oCacic.Windows.getHomeDrive + g_oCacic.Windows.getWinDir + 'CACICsvc.log');
275   - if FileExists(g_oCacic.Windows.getHomeDrive + g_oCacic.Windows.getWinDir + 'CACICsvc.log') then
276   - Append(fLog)
277   - else
278   - Rewrite(fLog);
279   - Writeln(fLog,FormatDateTime('dd/mm hh:nn:ss ', Now) + '[CACICsvc][DEBUG] : ' +msg);
280   - CloseFile(fLog);
281   - End;
282   -End;
283   -
284   -procedure ServiceController(CtrlCode: DWord); stdcall;
285   -begin
286   - CACICservice.Controller(CtrlCode);
287   -end;
288   -
289   -function TCACICservice.GetServiceController: TServiceController;
290   -begin
291   - Result := ServiceController;
292   -end;
293   -
294   -procedure TCACICservice.ServiceExecute(Sender: TService);
295   -begin
296   - { Loop while service is active in SCM }
297   - While NOT Terminated do
298   - Begin
299   - { Process Service Requests }
300   - ServiceThread.ProcessRequests( False );
301   - { Allow system some time }
302   - Sleep(1);
303   - End;
304   -end;
305   -
306   -procedure TCACICservice.ServiceStart(Sender: TService; var Started: Boolean);
307   -begin
308   -
309   - g_oCacic := TCACIC.Create;
310   - g_oCacic.setCacicPath(GetValorChaveRegIni('Cacic2', 'cacic_dir', g_oCacic.getWinDir + 'chksis.ini'));
311   - CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : setCacicPath => '+GetValorChaveRegIni('Cacic2', 'cacic_dir', g_oCacic.getWinDir + 'chksis.ini'));
312   -
313   - CACICservice.logDEBUG('TCACICservice.ServiceStart');
314   - Started := true;
315   -
316   - ExecutaCACIC;
317   -
318   - Timer_CHKsis.Interval := 60000;
319   - Timer_CHKsis.Enabled := true;
320   -
321   - While not Terminated do
322   - Sleep(250);
323   -end;
324   -
325   -procedure TCACICservice.ExecutaCACIC;
326   -Begin
327   - CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : deleteFile => '+g_oCacic.getCacicPath + 'aguarde_CACIC.txt');
328   - DeleteFile(PAnsiChar(g_oCacic.getCacicPath + 'aguarde_CACIC.txt'));
329   - Sleep(3000);
330   -
331   - // Se o arquivo indicador de execução não existir...
332   - if not (FileExists(g_oCacic.getCacicPath + 'aguarde_CACIC.txt')) then
333   - Begin
334   - // Executo o CHKsis, verificando a estrutura do sistema
335   - Try
336   - CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : createSampleProcess => '+g_oCacic.getWinDir + 'chksis.exe');
337   - g_oCacic.createSampleProcess(g_oCacic.getWinDir + 'chksis.exe',false,SW_HIDE);
338   - Except
339   - End;
340   -
341   - While not (FileExists(g_oCacic.getCacicPath + 'cacic2.exe')) do
342   - Sleep(5000); // Espero 5 segundos...
343   -
344   - // Executo o Agente Principal do CACIC
345   - Try
346   - // Execução diferenciada para >= VISTA devido ao impedimento de escrita na Notification Area imposta a processos/serviços.
347   - if (g_oCacic.isWindowsGEVista) then
348   - Begin
349   - CACICservice.logDEBUG('TCACICservice.ExecutaCACIC invocando CACICservice.startapp para execução de "'+g_oCacic.getCacicPath + 'cacic2.exe'+'"');
350   - CACICservice.startapp;
351   - End
352   - else
353   - Begin
354   - CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : createSampleProcess => '+g_oCacic.getCacicPath + 'cacic2.exe');
355   - g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'cacic2.exe',false,SW_NORMAL);
356   - End;
357   - Except
358   - End;
359   - End;
360   -End;
361   -
362   -procedure TCACICservice.ServiceAfterInstall(Sender: TService);
363   -begin
364   - ServiceStart(nil,boolStarted);
365   - CACICservice.logDEBUG('TCACICservice.ServiceAfterInstall');
366   -end;
367   -
368   -procedure TCACICservice.Timer_CHKsisTimer(Sender: TObject);
369   -begin
370   - CACICservice.logDEBUG('TCACICservice.Timer_CHKsisTimer');
371   - ExecutaCACIC;
372   -
373   - // Verificações diversas
374   -
375   -end;
376   -
377   -procedure TCACICservice.ServiceStop(Sender: TService;
378   - var Stopped: Boolean);
379   -begin
380   - CACICservice.logDEBUG('TCACICservice.ServiceStop');
381   - Stopped := true;
382   -end;
383   -
384   -end.
cacicservice/CACICsvcThread.pas
... ... @@ -1,66 +0,0 @@
1   -(*
2   - A Windows NT Service Thread
3   - ===========================
4   -
5   - Author Kim Sandell
6   - Email: kim.sandell@nsftele.com
7   -*)
8   -unit CACICsvcThread;
9   -
10   -interface
11   -
12   -uses
13   - Windows, Messages, SysUtils, Classes;
14   -
15   -
16   -type
17   - TNTServiceThread = Class(TThread)
18   - private
19   - { Private declarations }
20   - Public
21   - { Public declarations }
22   - Interval : Integer;
23   -
24   - Procedure Execute; Override;
25   - Published
26   - { Published declarations }
27   - End;
28   -
29   -implementation
30   -
31   -{ TNTServiceThread }
32   -
33   -procedure TNTServiceThread.Execute;
34   -var TimeOut : integer;
35   -begin
36   - // Do NOT free on termination - The Serivce frees the Thread
37   - FreeOnTerminate := False;
38   -
39   - // Set Interval
40   - TimeOut := Interval * 4;
41   -
42   - // Main Loop
43   - Try
44   - While Not Terminated do
45   - Begin
46   - // Decrement timeout
47   - Dec( TimeOut );
48   -
49   - If (TimeOut=0) then
50   - Begin
51   - // Reset timer
52   - TimeOut := Interval * 4;
53   -
54   - End;
55   - // Wait 1/4th of a second
56   - Sleep(250);
57   - End;
58   - Except
59   - On E:Exception do ; // TODO: Exception logging...
60   - End;
61   - // Terminate the Thread - This signals Terminated=True
62   - Terminate;
63   -
64   -end;
65   -
66   -end.
cacicservice/cacic_service_32x32.ico
No preview for this file type