Commit 004d4bae9706fbf6edd7288f9708a10577ce453a
1 parent
0f8c3887
Exists in
master
Implementacao de controles para uso do srCACIC - Suporte Remoto, adequacoes ao f…
…uncionamento do agente principal como servico, correcoes diversas. git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@759 fecfc0c7-e812-0410-ae72-849f08638ee7
Showing
44 changed files
with
1773 additions
and
399 deletions
Show diff stats
CACIC_Library.pas
@@ -47,7 +47,7 @@ unit CACIC_Library; | @@ -47,7 +47,7 @@ unit CACIC_Library; | ||
47 | interface | 47 | interface |
48 | 48 | ||
49 | uses | 49 | uses |
50 | - Windows, SysUtils, StrUtils; | 50 | + Windows, SysUtils, StrUtils, md5; |
51 | 51 | ||
52 | type | 52 | type |
53 | 53 | ||
@@ -96,6 +96,7 @@ type | @@ -96,6 +96,7 @@ type | ||
96 | function isWindowsAdmin(): Boolean; | 96 | function isWindowsAdmin(): Boolean; |
97 | function createSampleProcess(p_cmd: string; p_wait: boolean ): boolean; | 97 | function createSampleProcess(p_cmd: string; p_wait: boolean ): boolean; |
98 | procedure showTrayIcon(p_visible:boolean); | 98 | procedure showTrayIcon(p_visible:boolean); |
99 | + function GetFileHash(strFileName : String) : String; | ||
99 | end; | 100 | end; |
100 | 101 | ||
101 | {*------------------------------------------------------------------------------ | 102 | {*------------------------------------------------------------------------------ |
@@ -531,6 +532,19 @@ begin | @@ -531,6 +532,19 @@ begin | ||
531 | end; | 532 | end; |
532 | 533 | ||
533 | {*------------------------------------------------------------------------------ | 534 | {*------------------------------------------------------------------------------ |
535 | + Para cálculo de HASH de determinado arquivo. | ||
536 | + | ||
537 | + @autor: Anderson Peterle | ||
538 | + @param p_strFileName - Nome do arquivo para extração do HashCode | ||
539 | +-------------------------------------------------------------------------------} | ||
540 | +function TCACIC_Windows.GetFileHash(strFileName : String) : String; | ||
541 | +Begin | ||
542 | + Result := 'Arquivo "'+strFileName+'" Inexistente!'; | ||
543 | + if (FileExists(strFileName)) then | ||
544 | + Result := MD5Print(MD5File(strFileName)); | ||
545 | +End; | ||
546 | + | ||
547 | +{*------------------------------------------------------------------------------ | ||
534 | Mostra ou oculta o cacic na "systray" do windows | 548 | Mostra ou oculta o cacic na "systray" do windows |
535 | 549 | ||
536 | @autor: Diversos - compilado de vários exemplos obtidos na internet | 550 | @autor: Diversos - compilado de vários exemplos obtidos na internet |
cacic2.res
No preview for this file type
No preview for this file type
No preview for this file type
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
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 | +-LE"e:\arquivos de programas\borland\delphi7\Projects\Bpl" | ||
35 | +-LN"e:\arquivos de programas\borland\delphi7\Projects\Bpl" |
@@ -0,0 +1,136 @@ | @@ -0,0 +1,136 @@ | ||
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=4 | ||
117 | +Release=0 | ||
118 | +Build=758 | ||
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 - Empresa de TI da Prev Social | ||
128 | +FileDescription=CACICservice - Módulo Serviço para Sustentação do Agente Principal | ||
129 | +FileVersion=2.4.0.758 | ||
130 | +InternalName= | ||
131 | +LegalCopyright= | ||
132 | +LegalTrademarks= | ||
133 | +OriginalFilename= | ||
134 | +ProductName= | ||
135 | +ProductVersion=2.4.0.758 | ||
136 | +Comments= |
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
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 | + | ||
23 | +{$R *.RES} | ||
24 | + | ||
25 | +begin | ||
26 | + Application.Initialize; | ||
27 | + Application.CreateForm(TCACICservice, CACICservice); | ||
28 | + Application.Run; | ||
29 | +end. |
No preview for this file type
No preview for this file type
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
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 | + | ||
23 | +{$R *.RES} | ||
24 | + | ||
25 | +begin | ||
26 | + Application.Initialize; | ||
27 | + Application.CreateForm(TCACICservice, CACICservice); | ||
28 | + Application.Run; | ||
29 | +end. |
No preview for this file type
No preview for this file type
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
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 |
@@ -0,0 +1,239 @@ | @@ -0,0 +1,239 @@ | ||
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 Windows, | ||
22 | + Messages, | ||
23 | + SysUtils, | ||
24 | + Classes, | ||
25 | + SvcMgr, | ||
26 | + strUtils, | ||
27 | + ExtCtrls; | ||
28 | + | ||
29 | +var strHomeDrive, | ||
30 | + strCacicDir : String; | ||
31 | + boolStarted : boolean; | ||
32 | + | ||
33 | +type | ||
34 | + TCACICservice = class(TService) | ||
35 | + Timer_CHKsis: TTimer; | ||
36 | + procedure ServiceExecute(Sender: TService); | ||
37 | + procedure ServiceStart(Sender: TService; var Started: Boolean); | ||
38 | + procedure ServiceAfterInstall(Sender: TService); | ||
39 | + procedure Timer_CHKsisTimer(Sender: TObject); | ||
40 | + procedure ServiceStop(Sender: TService; var Stopped: Boolean); | ||
41 | + private | ||
42 | + | ||
43 | + { Internal Start & Stop methods } | ||
44 | + function HomeDrive : string; | ||
45 | + function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String; | ||
46 | + function GetAppPath: String; | ||
47 | + procedure doSaveLog(Msg : String); | ||
48 | + Procedure WMEndSession(var Msg : TWMEndSession) ; message WM_ENDSESSION; | ||
49 | + procedure ExecutaCACIC; | ||
50 | + public | ||
51 | + { Public declarations } | ||
52 | + | ||
53 | + function GetServiceController: TServiceController; override; | ||
54 | + end; | ||
55 | + | ||
56 | +var | ||
57 | + CACICservice: TCACICservice; | ||
58 | + | ||
59 | +implementation | ||
60 | + | ||
61 | +{$R *.DFM} | ||
62 | +procedure TCACICservice.WMEndSession(var Msg : TWMEndSession) ; | ||
63 | +begin | ||
64 | + if Msg.EndSession = TRUE then | ||
65 | + doSaveLog('Windows finalizado em ' + FormatDateTime('c', Now)) ; | ||
66 | + inherited; | ||
67 | + Application.Free; | ||
68 | +end; | ||
69 | +// Funções Auxiliares | ||
70 | +function TCACICservice.GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String; | ||
71 | +//Para buscar do Arquivo INI... | ||
72 | +// Marreta devido a limitações do KERNEL w9x no tratamento de arquivos texto e suas seções | ||
73 | +//function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String; | ||
74 | +var | ||
75 | + FileText : TStringList; | ||
76 | + i, j, v_Size_Section, v_Size_Key : integer; | ||
77 | + v_SectionName, v_KeyName : string; | ||
78 | + begin | ||
79 | +//doSaveLog('GetVCRini: Secao: '+p_Secao+' Chave: '+p_Chave+' File: '+p_File); | ||
80 | + Result := ''; | ||
81 | + v_SectionName := '[' + p_Secao + ']'; | ||
82 | + v_Size_Section := strLen(PChar(v_SectionName)); | ||
83 | + v_KeyName := p_Chave + '='; | ||
84 | + v_Size_Key := strLen(PChar(v_KeyName)); | ||
85 | + FileText := TStringList.Create; | ||
86 | + try | ||
87 | + FileText.LoadFromFile(p_File); | ||
88 | + For i := 0 To FileText.Count - 1 Do | ||
89 | + Begin | ||
90 | + if (LowerCase(Trim(PChar(Copy(FileText[i],1,v_Size_Section)))) = LowerCase(Trim(PChar(v_SectionName)))) then | ||
91 | + Begin | ||
92 | + For j := i to FileText.Count - 1 Do | ||
93 | + Begin | ||
94 | + if (LowerCase(Trim(PChar(Copy(FileText[j],1,v_Size_Key)))) = LowerCase(Trim(PChar(v_KeyName)))) then | ||
95 | + Begin | ||
96 | + Result := PChar(Copy(FileText[j],v_Size_Key + 1,strLen(PChar(FileText[j]))-v_Size_Key)); | ||
97 | + Break; | ||
98 | + End; | ||
99 | + End; | ||
100 | + End; | ||
101 | + if (Result <> '') then break; | ||
102 | + End; | ||
103 | + finally | ||
104 | + FileText.Free; | ||
105 | + end; | ||
106 | + end; | ||
107 | + | ||
108 | +function TCACICservice.GetAppPath: String; | ||
109 | +Var | ||
110 | + Test : String; | ||
111 | + Res : Longint; | ||
112 | + CurSize : Longint; | ||
113 | +begin | ||
114 | + CurSize := 1024; | ||
115 | + SetLength(Test, CurSize); | ||
116 | + Res := GetModuleFilename(GetModuleHandle(nil), PChar(test), CurSize); | ||
117 | + If (res > curSize) then | ||
118 | + begin | ||
119 | + CurSize := res + 10; | ||
120 | + SetLength(Test, CurSize); | ||
121 | + Res := GetModuleFilename(GetModuleHandle(nil), PChar(test), CurSize); | ||
122 | + end; | ||
123 | + Setlength(Test, Res); | ||
124 | + test := ExtractFileDir(Test); | ||
125 | + if (test[Length(test)] = '\') or (test[Length(test)]='/') then | ||
126 | + SetLength(Test, Length(test) - 1); | ||
127 | + Result := test; | ||
128 | +end; | ||
129 | + | ||
130 | +function TCACICservice.HomeDrive : string; | ||
131 | +var WinDir : array [0..144] of char; | ||
132 | +begin | ||
133 | + GetWindowsDirectory (WinDir, 144); | ||
134 | + Result := StrPas (WinDir); | ||
135 | +end; | ||
136 | + | ||
137 | +procedure TCACICservice.doSaveLog(Msg : String); | ||
138 | +var fLog: textfile; | ||
139 | +begin | ||
140 | + AssignFile(fLog, HomeDrive + '\CACICsvc.log'); | ||
141 | + if FileExists(HomeDrive + '\CACICsvc.log') then | ||
142 | + Append(fLog) | ||
143 | + else | ||
144 | + Rewrite(fLog); | ||
145 | + Writeln(fLog,FormatDateTime('dd/mm hh:nn:ss ', Now) + '[CACICsvc] : ' +msg); | ||
146 | + CloseFile(fLog); | ||
147 | +End; | ||
148 | + | ||
149 | +procedure ServiceController(CtrlCode: DWord); stdcall; | ||
150 | +begin | ||
151 | + CACICservice.Controller(CtrlCode); | ||
152 | +end; | ||
153 | + | ||
154 | +function TCACICservice.GetServiceController: TServiceController; | ||
155 | +begin | ||
156 | + Result := ServiceController; | ||
157 | +end; | ||
158 | + | ||
159 | +procedure TCACICservice.ServiceExecute(Sender: TService); | ||
160 | +begin | ||
161 | + doSaveLog('TCACICservice.ServiceExecute'); | ||
162 | + | ||
163 | + { Loop while service is active in SCM } | ||
164 | + While NOT Terminated do | ||
165 | + Begin | ||
166 | + { Process Service Requests } | ||
167 | + ServiceThread.ProcessRequests( False ); | ||
168 | + { Allow system some time } | ||
169 | + Sleep(1); | ||
170 | + End; | ||
171 | +end; | ||
172 | + | ||
173 | +procedure TCACICservice.ServiceStart(Sender: TService; var Started: Boolean); | ||
174 | +begin | ||
175 | + | ||
176 | + Started := true; | ||
177 | + | ||
178 | + ExecutaCACIC; | ||
179 | + | ||
180 | + Timer_CHKsis.Interval := 60000; | ||
181 | + Timer_CHKsis.Enabled := true; | ||
182 | + | ||
183 | + While not Terminated do | ||
184 | + Sleep(250); | ||
185 | + | ||
186 | + | ||
187 | +end; | ||
188 | + | ||
189 | +procedure TCACICservice.ExecutaCACIC; | ||
190 | +Begin | ||
191 | + | ||
192 | + strHomeDrive := MidStr(HomeDrive,1,3); //x:\ | ||
193 | + strCacicDir := strHomeDrive + GetValorChaveRegIni('Cacic2', 'cacic_dir', GetAppPath + '\chksis.ini'); | ||
194 | + | ||
195 | + DeleteFile(strCacicDir + '\aguarde_CACIC.txt'); | ||
196 | + Sleep(3000); | ||
197 | + | ||
198 | + // Se o arquivo indicador de execução não existir... | ||
199 | + if not (FileExists(strCacicDir + '\aguarde_CACIC.txt')) then | ||
200 | + Begin | ||
201 | + // Executo o CHKsis, verificando a estrutura do sistema | ||
202 | + Try | ||
203 | + WinEXEC(PChar(HomeDrive + '\chksis.exe'),sw_HIDE); | ||
204 | + Except | ||
205 | + End; | ||
206 | + | ||
207 | + While not (FileExists(strCacicDir + '\cacic2.exe')) do | ||
208 | + Sleep(5000); // Espero 5 segundos... | ||
209 | + End; | ||
210 | + | ||
211 | + | ||
212 | + // Executo o Agente Principal do CACIC | ||
213 | + Try | ||
214 | + WinEXEC(PChar(strCacicDir + '\cacic2.exe'),sw_hide); | ||
215 | + Except | ||
216 | + End; | ||
217 | +End; | ||
218 | + | ||
219 | +procedure TCACICservice.ServiceAfterInstall(Sender: TService); | ||
220 | + | ||
221 | +begin | ||
222 | + ServiceStart(nil,boolStarted); | ||
223 | +end; | ||
224 | + | ||
225 | +procedure TCACICservice.Timer_CHKsisTimer(Sender: TObject); | ||
226 | +begin | ||
227 | + ExecutaCACIC; | ||
228 | + | ||
229 | + // Verificações diversas | ||
230 | + | ||
231 | +end; | ||
232 | + | ||
233 | +procedure TCACICservice.ServiceStop(Sender: TService; | ||
234 | + var Stopped: Boolean); | ||
235 | +begin | ||
236 | + Stopped := true; | ||
237 | +end; | ||
238 | + | ||
239 | +end. |
No preview for this file type
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
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 |
@@ -0,0 +1,234 @@ | @@ -0,0 +1,234 @@ | ||
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, Messages, SysUtils, Classes, SvcMgr,strutils, ExtCtrls; | ||
23 | + | ||
24 | +var strHomeDrive, | ||
25 | + strCacicDir : String; | ||
26 | + boolStarted : boolean; | ||
27 | + | ||
28 | +type | ||
29 | + TCACICservice = class(TService) | ||
30 | + Timer_CHKsis: TTimer; | ||
31 | + procedure ServiceExecute(Sender: TService); | ||
32 | + procedure ServiceStart(Sender: TService; var Started: Boolean); | ||
33 | + procedure ServiceAfterInstall(Sender: TService); | ||
34 | + procedure Timer_CHKsisTimer(Sender: TObject); | ||
35 | + procedure ServiceStop(Sender: TService; var Stopped: Boolean); | ||
36 | + private | ||
37 | + | ||
38 | + { Internal Start & Stop methods } | ||
39 | + function HomeDrive : string; | ||
40 | + function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String; | ||
41 | + function GetAppPath: String; | ||
42 | + procedure doSaveLog(Msg : String); | ||
43 | + Procedure WMEndSession(var Msg : TWMEndSession) ; message WM_ENDSESSION; | ||
44 | + procedure ExecutaCACIC; | ||
45 | + public | ||
46 | + { Public declarations } | ||
47 | + | ||
48 | + function GetServiceController: TServiceController; override; | ||
49 | + end; | ||
50 | + | ||
51 | +var | ||
52 | + CACICservice: TCACICservice; | ||
53 | + | ||
54 | +implementation | ||
55 | + | ||
56 | +{$R *.DFM} | ||
57 | +procedure TCACICservice.WMEndSession(var Msg : TWMEndSession) ; | ||
58 | +begin | ||
59 | + if Msg.EndSession = TRUE then | ||
60 | + doSaveLog('Windows finalizado em ' + FormatDateTime('c', Now)) ; | ||
61 | + inherited; | ||
62 | + Application.Free; | ||
63 | +end; | ||
64 | +// Funções Auxiliares | ||
65 | +function TCACICservice.GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String; | ||
66 | +//Para buscar do Arquivo INI... | ||
67 | +// Marreta devido a limitações do KERNEL w9x no tratamento de arquivos texto e suas seções | ||
68 | +//function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String; | ||
69 | +var | ||
70 | + FileText : TStringList; | ||
71 | + i, j, v_Size_Section, v_Size_Key : integer; | ||
72 | + v_SectionName, v_KeyName : string; | ||
73 | + begin | ||
74 | +//doSaveLog('GetVCRini: Secao: '+p_Secao+' Chave: '+p_Chave+' File: '+p_File); | ||
75 | + Result := ''; | ||
76 | + v_SectionName := '[' + p_Secao + ']'; | ||
77 | + v_Size_Section := strLen(PChar(v_SectionName)); | ||
78 | + v_KeyName := p_Chave + '='; | ||
79 | + v_Size_Key := strLen(PChar(v_KeyName)); | ||
80 | + FileText := TStringList.Create; | ||
81 | + try | ||
82 | + FileText.LoadFromFile(p_File); | ||
83 | + For i := 0 To FileText.Count - 1 Do | ||
84 | + Begin | ||
85 | + if (LowerCase(Trim(PChar(Copy(FileText[i],1,v_Size_Section)))) = LowerCase(Trim(PChar(v_SectionName)))) then | ||
86 | + Begin | ||
87 | + For j := i to FileText.Count - 1 Do | ||
88 | + Begin | ||
89 | + if (LowerCase(Trim(PChar(Copy(FileText[j],1,v_Size_Key)))) = LowerCase(Trim(PChar(v_KeyName)))) then | ||
90 | + Begin | ||
91 | + Result := PChar(Copy(FileText[j],v_Size_Key + 1,strLen(PChar(FileText[j]))-v_Size_Key)); | ||
92 | + Break; | ||
93 | + End; | ||
94 | + End; | ||
95 | + End; | ||
96 | + if (Result <> '') then break; | ||
97 | + End; | ||
98 | + finally | ||
99 | + FileText.Free; | ||
100 | + end; | ||
101 | + end; | ||
102 | + | ||
103 | +function TCACICservice.GetAppPath: String; | ||
104 | +Var | ||
105 | + Test : String; | ||
106 | + Res : Longint; | ||
107 | + CurSize : Longint; | ||
108 | +begin | ||
109 | + CurSize := 1024; | ||
110 | + SetLength(Test, CurSize); | ||
111 | + Res := GetModuleFilename(GetModuleHandle(nil), PChar(test), CurSize); | ||
112 | + If (res > curSize) then | ||
113 | + begin | ||
114 | + CurSize := res + 10; | ||
115 | + SetLength(Test, CurSize); | ||
116 | + Res := GetModuleFilename(GetModuleHandle(nil), PChar(test), CurSize); | ||
117 | + end; | ||
118 | + Setlength(Test, Res); | ||
119 | + test := ExtractFileDir(Test); | ||
120 | + if (test[Length(test)] = '\') or (test[Length(test)]='/') then | ||
121 | + SetLength(Test, Length(test) - 1); | ||
122 | + Result := test; | ||
123 | +end; | ||
124 | + | ||
125 | +function TCACICservice.HomeDrive : string; | ||
126 | +var WinDir : array [0..144] of char; | ||
127 | +begin | ||
128 | + GetWindowsDirectory (WinDir, 144); | ||
129 | + Result := StrPas (WinDir); | ||
130 | +end; | ||
131 | + | ||
132 | +procedure TCACICservice.doSaveLog(Msg : String); | ||
133 | +var fLog: textfile; | ||
134 | +begin | ||
135 | + AssignFile(fLog, HomeDrive + '\CACICsvc.log'); | ||
136 | + if FileExists(HomeDrive + '\CACICsvc.log') then | ||
137 | + Append(fLog) | ||
138 | + else | ||
139 | + Rewrite(fLog); | ||
140 | + Writeln(fLog,FormatDateTime('dd/mm hh:nn:ss ', Now) + '[CACICsvc] : ' +msg); | ||
141 | + CloseFile(fLog); | ||
142 | +End; | ||
143 | + | ||
144 | +procedure ServiceController(CtrlCode: DWord); stdcall; | ||
145 | +begin | ||
146 | + CACICservice.Controller(CtrlCode); | ||
147 | +end; | ||
148 | + | ||
149 | +function TCACICservice.GetServiceController: TServiceController; | ||
150 | +begin | ||
151 | + Result := ServiceController; | ||
152 | +end; | ||
153 | + | ||
154 | +procedure TCACICservice.ServiceExecute(Sender: TService); | ||
155 | +begin | ||
156 | + doSaveLog('TCACICservice.ServiceExecute'); | ||
157 | + | ||
158 | + { Loop while service is active in SCM } | ||
159 | + While NOT Terminated do | ||
160 | + Begin | ||
161 | + { Process Service Requests } | ||
162 | + ServiceThread.ProcessRequests( False ); | ||
163 | + { Allow system some time } | ||
164 | + Sleep(1); | ||
165 | + End; | ||
166 | +end; | ||
167 | + | ||
168 | +procedure TCACICservice.ServiceStart(Sender: TService; var Started: Boolean); | ||
169 | +begin | ||
170 | + | ||
171 | + Started := true; | ||
172 | + | ||
173 | + ExecutaCACIC; | ||
174 | + | ||
175 | + Timer_CHKsis.Interval := 60000; | ||
176 | + Timer_CHKsis.Enabled := true; | ||
177 | + | ||
178 | + While not Terminated do | ||
179 | + Sleep(250); | ||
180 | + | ||
181 | + | ||
182 | +end; | ||
183 | + | ||
184 | +procedure TCACICservice.ExecutaCACIC; | ||
185 | +Begin | ||
186 | + | ||
187 | + strHomeDrive := MidStr(HomeDrive,1,3); //x:\ | ||
188 | + strCacicDir := strHomeDrive + GetValorChaveRegIni('Cacic2', 'cacic_dir', GetAppPath + '\chksis.ini'); | ||
189 | + | ||
190 | + DeleteFile(strCacicDir + '\aguarde_CACIC.txt'); | ||
191 | + Sleep(3000); | ||
192 | + | ||
193 | + // Se o arquivo indicador de execução não existir... | ||
194 | + if not (FileExists(strCacicDir + '\aguarde_CACIC.txt')) then | ||
195 | + Begin | ||
196 | + // Executo o CHKsis, verificando a estrutura do sistema | ||
197 | + Try | ||
198 | + WinEXEC(PChar(HomeDrive + '\chksis.exe'),sw_HIDE); | ||
199 | + Except | ||
200 | + End; | ||
201 | + | ||
202 | + While not (FileExists(strCacicDir + '\cacic2.exe')) do | ||
203 | + Sleep(5000); // Espero 5 segundos... | ||
204 | + End; | ||
205 | + | ||
206 | + | ||
207 | + // Executo o Agente Principal do CACIC | ||
208 | + Try | ||
209 | + WinEXEC(PChar(strCacicDir + '\cacic2.exe'),sw_hide); | ||
210 | + Except | ||
211 | + End; | ||
212 | +End; | ||
213 | + | ||
214 | +procedure TCACICservice.ServiceAfterInstall(Sender: TService); | ||
215 | + | ||
216 | +begin | ||
217 | + ServiceStart(nil,boolStarted); | ||
218 | +end; | ||
219 | + | ||
220 | +procedure TCACICservice.Timer_CHKsisTimer(Sender: TObject); | ||
221 | +begin | ||
222 | + ExecutaCACIC; | ||
223 | + | ||
224 | + // Verificações diversas | ||
225 | + | ||
226 | +end; | ||
227 | + | ||
228 | +procedure TCACICservice.ServiceStop(Sender: TService; | ||
229 | + var Stopped: Boolean); | ||
230 | +begin | ||
231 | + Stopped := true; | ||
232 | +end; | ||
233 | + | ||
234 | +end. |
No preview for this file type
@@ -0,0 +1,66 @@ | @@ -0,0 +1,66 @@ | ||
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. |
@@ -0,0 +1,202 @@ | @@ -0,0 +1,202 @@ | ||
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, StrUtils; | ||
14 | + | ||
15 | +var strHomeDrive, | ||
16 | + strCacicDir : String; | ||
17 | + | ||
18 | +type | ||
19 | + TNTServiceThread = Class(TThread) | ||
20 | + private | ||
21 | + { Private declarations } | ||
22 | + function HomeDrive : string; | ||
23 | + function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String; | ||
24 | + function GetAppPath: String; | ||
25 | + procedure doSaveLog(Msg : String); | ||
26 | + function CreateProcessSimple(sExecutableFilePath : string ) : String; | ||
27 | + Public | ||
28 | + { Public declarations } | ||
29 | + Interval : Integer; | ||
30 | + | ||
31 | + Procedure Execute; Override; | ||
32 | + Published | ||
33 | + { Published declarations } | ||
34 | + End; | ||
35 | + | ||
36 | +implementation | ||
37 | + | ||
38 | +{ TNTServiceThread } | ||
39 | +// Funções Auxiliares | ||
40 | +function TNTServiceThread.GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String; | ||
41 | +//Para buscar do Arquivo INI... | ||
42 | +// Marreta devido a limitações do KERNEL w9x no tratamento de arquivos texto e suas seções | ||
43 | +//function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String; | ||
44 | +var | ||
45 | + FileText : TStringList; | ||
46 | + i, j, v_Size_Section, v_Size_Key : integer; | ||
47 | + v_SectionName, v_KeyName : string; | ||
48 | + begin | ||
49 | +//doSaveLog('GetVCRini: Secao: '+p_Secao+' Chave: '+p_Chave+' File: '+p_File); | ||
50 | + Result := ''; | ||
51 | + v_SectionName := '[' + p_Secao + ']'; | ||
52 | + v_Size_Section := strLen(PChar(v_SectionName)); | ||
53 | + v_KeyName := p_Chave + '='; | ||
54 | + v_Size_Key := strLen(PChar(v_KeyName)); | ||
55 | + FileText := TStringList.Create; | ||
56 | + try | ||
57 | + FileText.LoadFromFile(p_File); | ||
58 | + For i := 0 To FileText.Count - 1 Do | ||
59 | + Begin | ||
60 | + if (LowerCase(Trim(PChar(Copy(FileText[i],1,v_Size_Section)))) = LowerCase(Trim(PChar(v_SectionName)))) then | ||
61 | + Begin | ||
62 | + For j := i to FileText.Count - 1 Do | ||
63 | + Begin | ||
64 | + if (LowerCase(Trim(PChar(Copy(FileText[j],1,v_Size_Key)))) = LowerCase(Trim(PChar(v_KeyName)))) then | ||
65 | + Begin | ||
66 | + Result := PChar(Copy(FileText[j],v_Size_Key + 1,strLen(PChar(FileText[j]))-v_Size_Key)); | ||
67 | + Break; | ||
68 | + End; | ||
69 | + End; | ||
70 | + End; | ||
71 | + if (Result <> '') then break; | ||
72 | + End; | ||
73 | + finally | ||
74 | + FileText.Free; | ||
75 | + end; | ||
76 | + end; | ||
77 | + | ||
78 | +function TNTServiceThread.GetAppPath: String; | ||
79 | +Var | ||
80 | + Test : String; | ||
81 | + Res : Longint; | ||
82 | + CurSize : Longint; | ||
83 | +begin | ||
84 | + CurSize := 1024; | ||
85 | + SetLength(Test, CurSize); | ||
86 | + Res := GetModuleFilename(GetModuleHandle(nil), PChar(test), CurSize); | ||
87 | + If (res > curSize) then | ||
88 | + begin | ||
89 | + CurSize := res + 10; | ||
90 | + SetLength(Test, CurSize); | ||
91 | + Res := GetModuleFilename(GetModuleHandle(nil), PChar(test), CurSize); | ||
92 | + end; | ||
93 | + Setlength(Test, Res); | ||
94 | + test := ExtractFileDir(Test); | ||
95 | + if (test[Length(test)] = '\') or (test[Length(test)]='/') then | ||
96 | + SetLength(Test, Length(test) - 1); | ||
97 | + Result := test; | ||
98 | +end; | ||
99 | + | ||
100 | +function TNTServiceThread.HomeDrive : string; | ||
101 | +var WinDir : array [0..144] of char; | ||
102 | +begin | ||
103 | + GetWindowsDirectory (WinDir, 144); | ||
104 | + Result := StrPas (WinDir); | ||
105 | +end; | ||
106 | + | ||
107 | +procedure TNTServiceThread.doSaveLog(Msg : String); | ||
108 | +var fLog: textfile; | ||
109 | +begin | ||
110 | + AssignFile(fLog, strHomeDrive + 'CACICsvc.log'); | ||
111 | + if FileExists(strHomeDrive + 'CACICsvc.log') then | ||
112 | + Append(fLog) | ||
113 | + else | ||
114 | + Rewrite(fLog); | ||
115 | + Writeln(fLog,FormatDateTime('dd/mm hh:nn:ss ', Now) + '[CACICsvc] : ' +msg); | ||
116 | + CloseFile(fLog); | ||
117 | +End; | ||
118 | + | ||
119 | +function TNTServiceThread.CreateProcessSimple(sExecutableFilePath : string ) : string; | ||
120 | +var | ||
121 | + pi: TProcessInformation; | ||
122 | + si: TStartupInfo; | ||
123 | +begin | ||
124 | + FillMemory( @si, sizeof( si ), 0 ); | ||
125 | + si.cb := sizeof( si ); | ||
126 | + | ||
127 | + CreateProcess( | ||
128 | + Nil, | ||
129 | + PChar( sExecutableFilePath ), | ||
130 | + Nil, Nil, False, | ||
131 | + NORMAL_PRIORITY_CLASS, Nil, Nil, | ||
132 | + si, pi ); | ||
133 | + | ||
134 | + // "after calling code" such as | ||
135 | + // the code to wait until the | ||
136 | + // process is done should go here | ||
137 | + | ||
138 | + CloseHandle( pi.hProcess ); | ||
139 | + CloseHandle( pi.hThread ); | ||
140 | +end; | ||
141 | + | ||
142 | +procedure TNTServiceThread.Execute; | ||
143 | +begin | ||
144 | + strHomeDrive := MidStr(HomeDrive,1,3); //x:\ | ||
145 | + doSaveLog('strHomeDrive: '+strHomeDrive); | ||
146 | + | ||
147 | + strCacicDir := strHomeDrive + GetValorChaveRegIni('Cacic2', 'cacic_dir', GetAppPath + '\chksis.ini'); | ||
148 | + doSaveLog('strCacicDir: '+strCacicDir); | ||
149 | + | ||
150 | + // Executo o CHKsis, verificando a estrutura do sistema | ||
151 | + Try | ||
152 | + CreateProcessSimple(PChar(HomeDrive + '\chksis.exe')); | ||
153 | + Except | ||
154 | + End; | ||
155 | + | ||
156 | + While not (FileExists(strCacicDir + '\cacic2.exe')) do | ||
157 | + Sleep(5000); // Espero 5 segundos... | ||
158 | + | ||
159 | + // Executo o Agente Principal do CACIC | ||
160 | + Try | ||
161 | + doSaveLog('Executarei "'+strCacicDir + '\cacic2.exe"'); | ||
162 | + CreateProcessSimple(PChar(strCacicDir + '\cacic2.exe')); | ||
163 | + Except | ||
164 | + End; | ||
165 | + | ||
166 | + While not Terminated do | ||
167 | + Sleep(250); | ||
168 | + | ||
169 | + { | ||
170 | + // Do NOT free on termination - The Serivce frees the Thread | ||
171 | + FreeOnTerminate := False; | ||
172 | + | ||
173 | + // Set Interval | ||
174 | + TimeOut := Interval * 4; | ||
175 | + | ||
176 | + // Main Loop | ||
177 | + Try | ||
178 | + While Not Terminated do | ||
179 | + Begin | ||
180 | + // Decrement timeout | ||
181 | + Dec( TimeOut ); | ||
182 | + | ||
183 | + If (TimeOut=0) then | ||
184 | + Begin | ||
185 | + // Reset timer | ||
186 | + TimeOut := Interval * 4; | ||
187 | + | ||
188 | + // Beep once per x seconds | ||
189 | + Beep; | ||
190 | + End; | ||
191 | + // Wait 1/4th of a second | ||
192 | + Sleep(250); | ||
193 | + End; | ||
194 | + Except | ||
195 | + On E:Exception do ; // TODO: Exception logging... | ||
196 | + End; | ||
197 | + // Terminate the Thread - This signals Terminated=True | ||
198 | + Terminate; | ||
199 | + } | ||
200 | +end; | ||
201 | + | ||
202 | +end. |
No preview for this file type
chkcacic/FormConfig.dfm
@@ -4,7 +4,7 @@ object Configs: TConfigs | @@ -4,7 +4,7 @@ object Configs: TConfigs | ||
4 | BorderIcons = [] | 4 | BorderIcons = [] |
5 | BorderStyle = bsSingle | 5 | BorderStyle = bsSingle |
6 | Caption = 'Configura'#231#245'es do CHKCACIC' | 6 | Caption = 'Configura'#231#245'es do CHKCACIC' |
7 | - ClientHeight = 382 | 7 | + ClientHeight = 367 |
8 | ClientWidth = 490 | 8 | ClientWidth = 490 |
9 | Color = clBtnFace | 9 | Color = clBtnFace |
10 | Font.Charset = DEFAULT_CHARSET | 10 | Font.Charset = DEFAULT_CHARSET |
@@ -29,7 +29,7 @@ object Configs: TConfigs | @@ -29,7 +29,7 @@ object Configs: TConfigs | ||
29 | Font.Style = [fsBold] | 29 | Font.Style = [fsBold] |
30 | ParentFont = False | 30 | ParentFont = False |
31 | TabOrder = 3 | 31 | TabOrder = 3 |
32 | - object Label1: TLabel | 32 | + object lbMensagemNaoAplicavel: TLabel |
33 | Left = 265 | 33 | Left = 265 |
34 | Top = 25 | 34 | Top = 25 |
35 | Width = 200 | 35 | Width = 200 |
@@ -57,7 +57,7 @@ object Configs: TConfigs | @@ -57,7 +57,7 @@ object Configs: TConfigs | ||
57 | end | 57 | end |
58 | object Memo_te_instala_informacoes_extras: TMemo | 58 | object Memo_te_instala_informacoes_extras: TMemo |
59 | Left = 9 | 59 | Left = 9 |
60 | - Top = 65 | 60 | + Top = 66 |
61 | Width = 462 | 61 | Width = 462 |
62 | Height = 144 | 62 | Height = 144 |
63 | Color = clInactiveBorder | 63 | Color = clInactiveBorder |
chkcacic/FormConfig.pas
@@ -31,7 +31,7 @@ type | @@ -31,7 +31,7 @@ type | ||
31 | Label_ip_serv_cacic: TLabel; | 31 | Label_ip_serv_cacic: TLabel; |
32 | Label_cacic_dir: TLabel; | 32 | Label_cacic_dir: TLabel; |
33 | gbOpcional: TGroupBox; | 33 | gbOpcional: TGroupBox; |
34 | - Label1: TLabel; | 34 | + lbMensagemNaoAplicavel: TLabel; |
35 | Label_te_instala_informacoes_extras: TLabel; | 35 | Label_te_instala_informacoes_extras: TLabel; |
36 | Button_Gravar: TButton; | 36 | Button_Gravar: TButton; |
37 | Memo_te_instala_informacoes_extras: TMemo; | 37 | Memo_te_instala_informacoes_extras: TMemo; |
chkcacic/chkcacic.res
No preview for this file type
chkcacic/main.dfm
chkcacic/main.pas
@@ -81,9 +81,10 @@ uses Windows, | @@ -81,9 +81,10 @@ uses Windows, | ||
81 | NTFileSecurity, | 81 | NTFileSecurity, |
82 | IdFTP, | 82 | IdFTP, |
83 | Tlhelp32, | 83 | Tlhelp32, |
84 | - dialogs, | ||
85 | ExtCtrls, | 84 | ExtCtrls, |
86 | - CACIC_Library; | 85 | + CACIC_Library, |
86 | + WinSvc, | ||
87 | + dialogs; | ||
87 | 88 | ||
88 | var v_ip_serv_cacic, | 89 | var v_ip_serv_cacic, |
89 | v_cacic_dir, | 90 | v_cacic_dir, |
@@ -137,7 +138,6 @@ Function ChecaVersoesAgentes(p_strNomeAgente : String) : integer; // 2.2.0.16 | @@ -137,7 +138,6 @@ Function ChecaVersoesAgentes(p_strNomeAgente : String) : integer; // 2.2.0.16 | ||
137 | Function Explode(Texto, Separador : String) : TStrings; | 138 | Function Explode(Texto, Separador : String) : TStrings; |
138 | Function FindWindowByTitle(WindowTitle: string): Hwnd; | 139 | Function FindWindowByTitle(WindowTitle: string): Hwnd; |
139 | Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean; | 140 | Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean; |
140 | -function Get_File_Size(sFileToExamine: string): integer; // 2.2.0.31 | ||
141 | function GetFolderDate(Folder: string): TDateTime; | 141 | function GetFolderDate(Folder: string): TDateTime; |
142 | function GetNetworkUserName : String; // 2.2.0.32 | 142 | function GetNetworkUserName : String; // 2.2.0.32 |
143 | Function GetRootKey(strRootKey: String): HKEY; | 143 | Function GetRootKey(strRootKey: String): HKEY; |
@@ -152,6 +152,9 @@ Function SetValorChaveRegEdit(Chave: String; Dado: Variant): Variant; | @@ -152,6 +152,9 @@ Function SetValorChaveRegEdit(Chave: String; Dado: Variant): Variant; | ||
152 | Function SetValorChaveRegIni(p_Secao, p_Chave, p_Valor, p_File : String): String; | 152 | Function SetValorChaveRegIni(p_Secao, p_Chave, p_Valor, p_File : String): String; |
153 | Function RemoveCaracteresEspeciais(Texto : String) : String; | 153 | Function RemoveCaracteresEspeciais(Texto : String) : String; |
154 | Function VerFmt(const MS, LS: DWORD): string; | 154 | Function VerFmt(const MS, LS: DWORD): string; |
155 | +function ServiceStart(sService : string ) : boolean; | ||
156 | +function ServiceRunning(sMachine, sService: PChar): Boolean; | ||
157 | +function ServiceStopped(sMachine, sService: PChar): Boolean; | ||
155 | 158 | ||
156 | type | 159 | type |
157 | TForm1 = class(TForm) | 160 | TForm1 = class(TForm) |
@@ -172,6 +175,130 @@ uses FormConfig; | @@ -172,6 +175,130 @@ uses FormConfig; | ||
172 | 175 | ||
173 | {$R *.dfm} | 176 | {$R *.dfm} |
174 | 177 | ||
178 | +function ServiceGetStatus(sMachine, sService: PChar): DWORD; | ||
179 | + {******************************************} | ||
180 | + {*** Parameters: ***} | ||
181 | + {*** sService: specifies the name of the service to open | ||
182 | + {*** sMachine: specifies the name of the target computer | ||
183 | + {*** ***} | ||
184 | + {*** Return Values: ***} | ||
185 | + {*** -1 = Error opening service ***} | ||
186 | + {*** 1 = SERVICE_STOPPED ***} | ||
187 | + {*** 2 = SERVICE_START_PENDING ***} | ||
188 | + {*** 3 = SERVICE_STOP_PENDING ***} | ||
189 | + {*** 4 = SERVICE_RUNNING ***} | ||
190 | + {*** 5 = SERVICE_CONTINUE_PENDING ***} | ||
191 | + {*** 6 = SERVICE_PAUSE_PENDING ***} | ||
192 | + {*** 7 = SERVICE_PAUSED ***} | ||
193 | + {******************************************} | ||
194 | +var | ||
195 | + SCManHandle, SvcHandle: SC_Handle; | ||
196 | + SS: TServiceStatus; | ||
197 | + dwStat: DWORD; | ||
198 | +begin | ||
199 | + dwStat := 0; | ||
200 | + // Open service manager handle. | ||
201 | + LogDEBUG('Executando OpenSCManager.SC_MANAGER_CONNECT'); | ||
202 | + SCManHandle := OpenSCManager(sMachine, nil, SC_MANAGER_CONNECT); | ||
203 | + if (SCManHandle > 0) then | ||
204 | + begin | ||
205 | + LogDEBUG('Executando OpenService.SERVICE_QUERY_STATUS'); | ||
206 | + SvcHandle := OpenService(SCManHandle, sService, SERVICE_QUERY_STATUS); | ||
207 | + // if Service installed | ||
208 | + if (SvcHandle > 0) then | ||
209 | + begin | ||
210 | + LogDEBUG('O serviço "'+ sService +'" já está instalado.'); | ||
211 | + // SS structure holds the service status (TServiceStatus); | ||
212 | + if (QueryServiceStatus(SvcHandle, SS)) then | ||
213 | + dwStat := ss.dwCurrentState; | ||
214 | + CloseServiceHandle(SvcHandle); | ||
215 | + end; | ||
216 | + CloseServiceHandle(SCManHandle); | ||
217 | + end; | ||
218 | + Result := dwStat; | ||
219 | +end; | ||
220 | + | ||
221 | +// start service | ||
222 | +// | ||
223 | +// return TRUE if successful | ||
224 | +// | ||
225 | +// sService | ||
226 | +// service name, ie: Alerter | ||
227 | +// | ||
228 | +function ServiceStart(sService : string ) : boolean; | ||
229 | +var schm, | ||
230 | + schs : SC_Handle; | ||
231 | + | ||
232 | + ss : TServiceStatus; | ||
233 | + psTemp : PChar; | ||
234 | + dwChkP : DWord; | ||
235 | +begin | ||
236 | + ss.dwCurrentState := 0; | ||
237 | + | ||
238 | + logDEBUG('Executando Service Start'); | ||
239 | + | ||
240 | + // connect to the service control manager | ||
241 | + schm := OpenSCManager(Nil,Nil,SC_MANAGER_CONNECT); | ||
242 | + | ||
243 | + // if successful... | ||
244 | + if(schm > 0)then | ||
245 | + begin | ||
246 | + // open a handle to the specified service | ||
247 | + schs := OpenService(schm,PChar(sService),SERVICE_START or SERVICE_QUERY_STATUS); | ||
248 | + | ||
249 | + // if successful... | ||
250 | + if(schs > 0)then | ||
251 | + begin | ||
252 | + logDEBUG('Open Service OK'); | ||
253 | + psTemp := Nil; | ||
254 | + if(StartService(schs,0,psTemp)) then | ||
255 | + begin | ||
256 | + logDEBUG('Entrando em Start Service'); | ||
257 | + // check status | ||
258 | + if(QueryServiceStatus(schs,ss))then | ||
259 | + begin | ||
260 | + while(SERVICE_RUNNING <> ss.dwCurrentState)do | ||
261 | + begin | ||
262 | + // dwCheckPoint contains a value that the service increments periodically | ||
263 | + // to report its progress during a lengthy operation. | ||
264 | + dwChkP := ss.dwCheckPoint; | ||
265 | + | ||
266 | + // wait a bit before checking status again | ||
267 | + // dwWaitHint is the estimated amount of time the calling program should wait before calling | ||
268 | + // QueryServiceStatus() again idle events should be handled here... | ||
269 | + | ||
270 | + Sleep(ss.dwWaitHint); | ||
271 | + | ||
272 | + if(not QueryServiceStatus(schs,ss))then | ||
273 | + begin | ||
274 | + break; | ||
275 | + end; | ||
276 | + | ||
277 | + if(ss.dwCheckPoint < dwChkP)then | ||
278 | + begin | ||
279 | + // QueryServiceStatus didn't increment dwCheckPoint as it should have. | ||
280 | + // avoid an infinite loop by breaking | ||
281 | + break; | ||
282 | + end; | ||
283 | + end; | ||
284 | + end | ||
285 | + else | ||
286 | + logDEBUG('Oops! Problema com StartService!'); | ||
287 | + end; | ||
288 | + | ||
289 | + // close service handle | ||
290 | + CloseServiceHandle(schs); | ||
291 | + end; | ||
292 | + | ||
293 | + // close service control manager handle | ||
294 | + CloseServiceHandle(schm); | ||
295 | + end | ||
296 | + else | ||
297 | + Configs.Memo_te_instala_informacoes_extras.Lines.Add('Oops! Problema com o Service Control Manager!'); | ||
298 | + // return TRUE if the service status is running | ||
299 | + Result := SERVICE_RUNNING = ss.dwCurrentState; | ||
300 | +end; | ||
301 | + | ||
175 | function GetNetworkUserName : String; | 302 | function GetNetworkUserName : String; |
176 | // Gets the name of the user currently logged into the network on | 303 | // Gets the name of the user currently logged into the network on |
177 | // the local PC | 304 | // the local PC |
@@ -282,6 +409,10 @@ begin | @@ -282,6 +409,10 @@ begin | ||
282 | except | 409 | except |
283 | //Erro na gravação do log! | 410 | //Erro na gravação do log! |
284 | end; | 411 | end; |
412 | + try | ||
413 | + Configs.Memo_te_instala_informacoes_extras.Lines.Add(strMsg); | ||
414 | + except | ||
415 | + end; | ||
285 | end; | 416 | end; |
286 | 417 | ||
287 | procedure LogDebug(p_msg:string); | 418 | procedure LogDebug(p_msg:string); |
@@ -730,7 +861,7 @@ begin | @@ -730,7 +861,7 @@ begin | ||
730 | LogDebug('FTP: UserName => "'+p_Username+'"'); | 861 | LogDebug('FTP: UserName => "'+p_Username+'"'); |
731 | IdFTP.Username := p_Username; | 862 | IdFTP.Username := p_Username; |
732 | 863 | ||
733 | - LogDebug('FTP: PassWord => "'+p_Password+'"'); | 864 | + LogDebug('FTP: PassWord => "**********"'); |
734 | IdFTP.Password := p_Password; | 865 | IdFTP.Password := p_Password; |
735 | 866 | ||
736 | LogDebug('FTP: PathServer => "'+p_PathServer+'"'); | 867 | LogDebug('FTP: PathServer => "'+p_PathServer+'"'); |
@@ -755,18 +886,18 @@ begin | @@ -755,18 +886,18 @@ begin | ||
755 | IdFTP.ChangeDir(p_PathServer); | 886 | IdFTP.ChangeDir(p_PathServer); |
756 | Try | 887 | Try |
757 | LogDebug('Iniciando FTP de "'+p_Dest + '\' + p_File+'"'); | 888 | LogDebug('Iniciando FTP de "'+p_Dest + '\' + p_File+'"'); |
758 | - LogDebug('Size de "'+p_File+'" Antes do FTP => '+IntToSTR(IdFTP.Size(p_File))); | 889 | + LogDebug('HashCode de "'+p_File+'" Antes do FTP => '+g_oCacic.GetFileHash(p_File)); |
759 | IdFTP.Get(p_File, p_Dest + '\' + p_File, True, True); | 890 | IdFTP.Get(p_File, p_Dest + '\' + p_File, True, True); |
760 | - LogDebug('Size de "'+p_Dest + '\' + p_File +'" Após o FTP => '+IntToSTR(Get_File_Size(p_Dest + '\' + p_File))); | 891 | + LogDebug('HashCode de "'+p_Dest + '\' + p_File +'" Após o FTP => '+g_oCacic.GetFileHash(p_Dest + '\' + p_File)); |
761 | Finally | 892 | Finally |
762 | - LogDebug('Size de "'+p_Dest + '\' + p_File +'" Após o FTP em Finally => '+IntToStr(Get_File_Size(p_Dest + '\' + p_File))); | 893 | + LogDebug('HashCode de "'+p_Dest + '\' + p_File +'" Após o FTP em Finally => '+g_oCacic.GetFileHash(p_Dest + '\' + p_File)); |
763 | IdFTP.Disconnect; | 894 | IdFTP.Disconnect; |
764 | IdFTP.Free; | 895 | IdFTP.Free; |
765 | result := true; | 896 | result := true; |
766 | End; | 897 | End; |
767 | Except | 898 | Except |
768 | Begin | 899 | Begin |
769 | - LogDebug('Oops! Problemas Sem Início de Operação...'); | 900 | + LogDebug('Oops! Problemas Sem Início de FTP...'); |
770 | result := false; | 901 | result := false; |
771 | End; | 902 | End; |
772 | end; | 903 | end; |
@@ -1025,14 +1156,14 @@ end; | @@ -1025,14 +1156,14 @@ end; | ||
1025 | 1156 | ||
1026 | function Posso_Rodar_CACIC : boolean; | 1157 | function Posso_Rodar_CACIC : boolean; |
1027 | Begin | 1158 | Begin |
1159 | + result := false; | ||
1160 | + | ||
1161 | + // Se eu conseguir matar o arquivo abaixo é porque não há outra sessão deste agente aberta... (POG? Nããão! :) ) | ||
1162 | + Matar(v_cacic_dir,'aguarde_CACIC.txt'); | ||
1163 | + | ||
1028 | // Se o aguarde_CACIC.txt existir é porque refere-se a uma versão mais atual: 2.2.0.20 ou maior | 1164 | // Se o aguarde_CACIC.txt existir é porque refere-se a uma versão mais atual: 2.2.0.20 ou maior |
1029 | - if (FileExists(g_oCacic.getCacicPath() + '\aguarde_CACIC.txt')) then | ||
1030 | - Begin | ||
1031 | - // Se eu conseguir matar o arquivo abaixo é porque não há outra sessão deste agente aberta... (POG? Nããão! :) ) | ||
1032 | - Matar(v_cacic_dir,'aguarde_CACIC.txt'); | ||
1033 | - if (not (FileExists(v_cacic_dir + 'aguarde_CACIC.txt'))) then | ||
1034 | - result := true; | ||
1035 | - End; | 1165 | + if not (FileExists(g_oCacic.getCacicPath() + '\aguarde_CACIC.txt')) then |
1166 | + result := true; | ||
1036 | End; | 1167 | End; |
1037 | function GetFolderDate(Folder: string): TDateTime; | 1168 | function GetFolderDate(Folder: string): TDateTime; |
1038 | var | 1169 | var |
@@ -1055,75 +1186,57 @@ begin | @@ -1055,75 +1186,57 @@ begin | ||
1055 | end; | 1186 | end; |
1056 | end; | 1187 | end; |
1057 | 1188 | ||
1058 | -function Get_File_Size(sFileToExamine: string): integer; | ||
1059 | -var | ||
1060 | - SearchRec: TSearchRec; | ||
1061 | - sgPath: string; | ||
1062 | - inRetval, I1: Integer; | ||
1063 | -begin | ||
1064 | - sgPath := ExpandFileName(sFileToExamine); | ||
1065 | - try | ||
1066 | - inRetval := FindFirst(ExpandFileName(sFileToExamine), faAnyFile, SearchRec); | ||
1067 | - if inRetval = 0 then | ||
1068 | - I1 := SearchRec.Size | ||
1069 | - else | ||
1070 | - I1 := -1; | ||
1071 | - finally | ||
1072 | - SysUtils.FindClose(SearchRec); | ||
1073 | - end; | ||
1074 | - Result := I1; | ||
1075 | -end; | ||
1076 | - | ||
1077 | -procedure verifyAndGet(strModuleName, | ||
1078 | - strDestinationFolderName, | ||
1079 | - strServUpdates, | ||
1080 | - strPortaServUpdates, | ||
1081 | - strNomeUsuarioLoginServUpdates, | ||
1082 | - strSenhaLoginServUpdates, | ||
1083 | - strPathServUpdates, | ||
1084 | - strExibeInformacoes : String); | ||
1085 | - var intFileSize : integer; | 1189 | +procedure verifyAndGet(p_strModuleName, |
1190 | + p_strFileHash, | ||
1191 | + p_strDestinationFolderName, | ||
1192 | + p_strServUpdates, | ||
1193 | + p_strPortaServUpdates, | ||
1194 | + p_strNomeUsuarioLoginServUpdates, | ||
1195 | + p_strSenhaLoginServUpdates, | ||
1196 | + p_strPathServUpdates, | ||
1197 | + p_strExibeInformacoes : String); | ||
1198 | + var v_strFileHash : String; | ||
1086 | Begin | 1199 | Begin |
1087 | 1200 | ||
1088 | // Verifico validade do Módulo e mato-o em caso negativo. | 1201 | // Verifico validade do Módulo e mato-o em caso negativo. |
1089 | - intFileSize := Get_File_Size(strDestinationFolderName + '\'+strModuleName); | 1202 | + v_strFileHash := g_oCacic.GetFileHash(p_strDestinationFolderName + '\'+p_strModuleName); |
1090 | 1203 | ||
1091 | - LogDebug('verifyAndGet - intFileSize de "'+strDestinationFolderName + '\'+strModuleName+'": ' + IntToStr(intFileSize)); | 1204 | + LogDebug('verifyAndGet - strFileHash de "'+p_strDestinationFolderName + '\'+p_strModuleName+'": ' + v_strFileHash); |
1092 | 1205 | ||
1093 | - If (intFileSize <= 0) then | ||
1094 | - Matar(strDestinationFolderName, strModuleName); | 1206 | + If (v_strFileHash <> p_strFileHash) then |
1207 | + Matar(p_strDestinationFolderName, p_strModuleName); | ||
1095 | 1208 | ||
1096 | - If not FileExists(strDestinationFolderName + '\'+strModuleName) Then | 1209 | + If not FileExists(p_strDestinationFolderName + '\'+p_strModuleName) Then |
1097 | Begin | 1210 | Begin |
1098 | - if (FileExists(ExtractFilePath(Application.Exename) + '\modulos\'+strModuleName)) then | 1211 | + if (FileExists(ExtractFilePath(Application.Exename) + '\modulos\'+p_strModuleName)) then |
1099 | Begin | 1212 | Begin |
1100 | - LogDiario('Copiando '+strModuleName+' de '+ExtractFilePath(Application.Exename)+'modulos\'); | ||
1101 | - CopyFile(PChar(ExtractFilePath(Application.Exename) + 'modulos\'+strModuleName), PChar(strDestinationFolderName + '\'+strModuleName),false); | ||
1102 | - FileSetAttr (PChar(strDestinationFolderName + '\' + strModuleName),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED | 1213 | + LogDiario('Copiando '+p_strModuleName+' de '+ExtractFilePath(Application.Exename)+'modulos\'); |
1214 | + CopyFile(PChar(ExtractFilePath(Application.Exename) + 'modulos\'+p_strModuleName), PChar(p_strDestinationFolderName + '\'+p_strModuleName),false); | ||
1215 | + FileSetAttr (PChar(p_strDestinationFolderName + '\' + p_strModuleName),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED | ||
1103 | End | 1216 | End |
1104 | else | 1217 | else |
1105 | begin | 1218 | begin |
1106 | Try | 1219 | Try |
1107 | - if not FTP(strServUpdates, | ||
1108 | - strPortaServUpdates, | ||
1109 | - strNomeUsuarioLoginServUpdates, | ||
1110 | - strSenhaLoginServUpdates, | ||
1111 | - strPathServUpdates, | ||
1112 | - strModuleName, | ||
1113 | - strDestinationFolderName) and (strExibeInformacoes = 'S') then | ||
1114 | - MessageDLG(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+strDestinationFolderName + '\'+strModuleName+'".'+#13#10+'Verifique o Servidor de Updates.',mtError,[mbOK],0); | 1220 | + if not FTP(p_strServUpdates, |
1221 | + p_strPortaServUpdates, | ||
1222 | + p_strNomeUsuarioLoginServUpdates, | ||
1223 | + p_strSenhaLoginServUpdates, | ||
1224 | + p_strPathServUpdates, | ||
1225 | + p_strModuleName, | ||
1226 | + p_strDestinationFolderName) then | ||
1227 | + Configs.Memo_te_instala_informacoes_extras.Lines.add(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+p_strDestinationFolderName + '\'+p_strModuleName+'".'+#13#10+'Verifique o Servidor de Updates.'); | ||
1115 | Except | 1228 | Except |
1116 | - LogDebug('FTP de "'+ strDestinationFolderName + '\' + strModuleName+'" Interrompido.'); | 1229 | + LogDebug('FTP de "'+ p_strDestinationFolderName + '\' + p_strModuleName+'" Interrompido.'); |
1117 | End; | 1230 | End; |
1118 | 1231 | ||
1119 | - if not FileExists(strDestinationFolderName + '\' + strModuleName) Then | 1232 | + if not FileExists(p_strDestinationFolderName + '\' + p_strModuleName) Then |
1120 | Begin | 1233 | Begin |
1121 | - LogDebug('Problemas Efetuando Download de '+ strDestinationFolderName + '\' + strModuleName+' (FTP)'); | 1234 | + LogDebug('Problemas Efetuando Download de '+ p_strDestinationFolderName + '\' + p_strModuleName+' (FTP)'); |
1122 | LogDebug('Conexão:'); | 1235 | LogDebug('Conexão:'); |
1123 | - LogDebug(strServUpdates+', '+strPortaServUpdates+', '+strNomeUsuarioLoginServUpdates+', '+strSenhaLoginServUpdates+', '+strPathServUpdates); | 1236 | + LogDebug(p_strServUpdates+', '+p_strPortaServUpdates+', '+p_strNomeUsuarioLoginServUpdates+', '+p_strSenhaLoginServUpdates+', '+p_strPathServUpdates); |
1124 | End | 1237 | End |
1125 | else | 1238 | else |
1126 | - LogDiario('Download Concluído de "'+strModuleName+'" (FTP)'); | 1239 | + LogDiario('Download Concluído de "'+p_strModuleName+'" (FTP)'); |
1127 | end; | 1240 | end; |
1128 | End; | 1241 | End; |
1129 | End; | 1242 | End; |
@@ -1131,6 +1244,7 @@ procedure verifyAndGet(strModuleName, | @@ -1131,6 +1244,7 @@ procedure verifyAndGet(strModuleName, | ||
1131 | procedure chkcacic; | 1244 | procedure chkcacic; |
1132 | var bool_configura, | 1245 | var bool_configura, |
1133 | bool_ExistsAutoRun, | 1246 | bool_ExistsAutoRun, |
1247 | + bool_ArquivoINI, | ||
1134 | bool_CommandLine : boolean; | 1248 | bool_CommandLine : boolean; |
1135 | 1249 | ||
1136 | v_te_serv_updates, | 1250 | v_te_serv_updates, |
@@ -1143,10 +1257,8 @@ var bool_configura, | @@ -1143,10 +1257,8 @@ var bool_configura, | ||
1143 | strAux, | 1257 | strAux, |
1144 | strDataHoraCACIC2_INI, | 1258 | strDataHoraCACIC2_INI, |
1145 | strDataHoraGERCOLS_INI, | 1259 | strDataHoraGERCOLS_INI, |
1146 | - strDataHoraSRCACICSRV_INI, | ||
1147 | strDataHoraCACIC2_FIM, | 1260 | strDataHoraCACIC2_FIM, |
1148 | - strDataHoraGERCOLS_FIM, | ||
1149 | - strDataHoraSRCACICSRV_FIM : String; | 1261 | + strDataHoraGERCOLS_FIM : String; |
1150 | 1262 | ||
1151 | Request_Config : TStringList; | 1263 | Request_Config : TStringList; |
1152 | v_array_modulos : TStrings; | 1264 | v_array_modulos : TStrings; |
@@ -1155,6 +1267,8 @@ var bool_configura, | @@ -1155,6 +1267,8 @@ var bool_configura, | ||
1155 | intDownload_CACIC2, | 1267 | intDownload_CACIC2, |
1156 | intDownload_GER_COLS, | 1268 | intDownload_GER_COLS, |
1157 | intAux : integer; | 1269 | intAux : integer; |
1270 | + | ||
1271 | + wordServiceStatus : DWORD; | ||
1158 | begin | 1272 | begin |
1159 | strDataHoraCACIC2_INI := ''; | 1273 | strDataHoraCACIC2_INI := ''; |
1160 | strDataHoraCACIC2_FIM := ''; | 1274 | strDataHoraCACIC2_FIM := ''; |
@@ -1163,6 +1277,7 @@ begin | @@ -1163,6 +1277,7 @@ begin | ||
1163 | v_te_instala_frase_sucesso := 'INSTALAÇÃO/ATUALIZAÇÃO EFETUADA COM SUCESSO!'; | 1277 | v_te_instala_frase_sucesso := 'INSTALAÇÃO/ATUALIZAÇÃO EFETUADA COM SUCESSO!'; |
1164 | v_te_instala_frase_insucesso := '***** INSTALAÇÃO/ATUALIZAÇÃO NÃO EFETUADA COM SUCESSO *****'; | 1278 | v_te_instala_frase_insucesso := '***** INSTALAÇÃO/ATUALIZAÇÃO NÃO EFETUADA COM SUCESSO *****'; |
1165 | bool_CommandLine := false; | 1279 | bool_CommandLine := false; |
1280 | + bool_ArquivoINI := FileExists(ExtractFilePath(Application.Exename) + '\chkcacic.ini'); | ||
1166 | 1281 | ||
1167 | Try | 1282 | Try |
1168 | v_home_drive := MidStr(HomeDrive,1,3); //x:\ | 1283 | v_home_drive := MidStr(HomeDrive,1,3); //x:\ |
@@ -1200,9 +1315,11 @@ begin | @@ -1200,9 +1315,11 @@ begin | ||
1200 | //v_cacic_dir := 'Cacic'; | 1315 | //v_cacic_dir := 'Cacic'; |
1201 | //v_exibe_informacoes := 'N'; // Manter o "N", pois, esse mesmo ChkCacic será colocado em NetLogons! | 1316 | //v_exibe_informacoes := 'N'; // Manter o "N", pois, esse mesmo ChkCacic será colocado em NetLogons! |
1202 | 1317 | ||
1318 | + // Se a chamada ao chkCACIC não passou parâmetros de IP do Servidor nem Pasta Padrão... | ||
1319 | + // Obs.: Normalmente a chamada com passagem de parâmetros é feita por script em servidor de domínio, para automatização do processo | ||
1203 | if not bool_CommandLine then | 1320 | if not bool_CommandLine then |
1204 | Begin | 1321 | Begin |
1205 | - If not (FileExists(ExtractFilePath(Application.Exename) + '\chkcacic.ini')) then | 1322 | + If not bool_ArquivoINI then |
1206 | Begin | 1323 | Begin |
1207 | LogDiario('Abrindo formulário de configurações'); | 1324 | LogDiario('Abrindo formulário de configurações'); |
1208 | CriaFormConfigura; | 1325 | CriaFormConfigura; |
@@ -1228,14 +1345,51 @@ begin | @@ -1228,14 +1345,51 @@ begin | ||
1228 | End; | 1345 | End; |
1229 | End; | 1346 | End; |
1230 | 1347 | ||
1348 | + LogDebug('Tipo de Drive: '+intToStr(GetDriveType(nil))); | ||
1349 | + | ||
1350 | + if not (GetDriveType(nil) = DRIVE_REMOTE) then | ||
1351 | + Begin | ||
1352 | + CriaFormConfigura; | ||
1353 | + Configs.Visible := true; | ||
1354 | + | ||
1355 | + Configs.gbObrigatorio.BringToFront; | ||
1356 | + Configs.gbOpcional.BringToFront; | ||
1357 | + | ||
1358 | + Configs.Label_ip_serv_cacic.BringToFront; | ||
1359 | + Configs.Edit_ip_serv_cacic.Text := v_ip_serv_cacic; | ||
1360 | + Configs.Edit_ip_serv_cacic.ReadOnly := true; | ||
1361 | + Configs.Edit_ip_serv_cacic.BringToFront; | ||
1362 | + | ||
1363 | + Configs.Label_cacic_dir.BringToFront; | ||
1364 | + Configs.Edit_cacic_dir.Text := v_cacic_dir; | ||
1365 | + Configs.Edit_cacic_dir.ReadOnly := true; | ||
1366 | + configs.Edit_cacic_dir.BringToFront; | ||
1367 | + | ||
1368 | + Configs.Label_te_instala_informacoes_extras.Visible := false; | ||
1369 | + | ||
1370 | + Configs.ckboxExibeInformacoes.Checked := true; | ||
1371 | + Configs.ckboxExibeInformacoes.Visible := false; | ||
1372 | + | ||
1373 | + Configs.Height := 357; | ||
1374 | + Configs.lbMensagemNaoAplicavel.Visible := false; | ||
1375 | + | ||
1376 | + Configs.Memo_te_instala_informacoes_extras.Clear; | ||
1377 | + Configs.Memo_te_instala_informacoes_extras.Top := 15; | ||
1378 | + Configs.Memo_te_instala_informacoes_extras.Height := 196; | ||
1379 | + | ||
1380 | + Configs.gbObrigatorio.Caption := 'Configuração'; | ||
1381 | + Configs.gbObrigatorio.Visible := true; | ||
1382 | + | ||
1383 | + Configs.gbOpcional.Caption := 'Andamento da Instalação/Atualização'; | ||
1384 | + Configs.gbOpcional.Visible := true; | ||
1385 | + | ||
1386 | + Configs.Refresh; | ||
1387 | + Configs.Show; | ||
1388 | + End; | ||
1389 | + | ||
1231 | // Verifica se o S.O. é NT Like e se o Usuário está com privilégio administrativo... | 1390 | // Verifica se o S.O. é NT Like e se o Usuário está com privilégio administrativo... |
1232 | - if (g_oCacic.isWindowsNTPlataform()) and (not g_oCacic.isWindowsAdmin()) then begin // Se NT/2000/XP/... | ||
1233 | - if (v_exibe_informacoes = 'S') then | ||
1234 | - MessageDLG(#13#10+'ATENÇÃO! Essa aplicação requer execução com nível administrativo.',mtError,[mbOK],0); | ||
1235 | - LogDiario('Sem Privilégios: Necessário ser administrador "local" da estação'); | ||
1236 | - ComunicaInsucesso('0'); // O indicador "0" (zero) sinalizará falta de privilégio na estação | ||
1237 | - end | ||
1238 | - else begin | 1391 | + if (g_oCacic.isWindowsNTPlataform()) and (g_oCacic.isWindowsAdmin()) then |
1392 | + Begin | ||
1239 | LogDebug(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); | 1393 | LogDebug(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); |
1240 | LogDebug(':::::::::::::: OBTENDO VALORES DO "chkcacic.ini" ::::::::::::::'); | 1394 | LogDebug(':::::::::::::: OBTENDO VALORES DO "chkcacic.ini" ::::::::::::::'); |
1241 | LogDebug(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); | 1395 | LogDebug(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); |
@@ -1261,8 +1415,8 @@ begin | @@ -1261,8 +1415,8 @@ begin | ||
1261 | Try | 1415 | Try |
1262 | Begin | 1416 | Begin |
1263 | // Liberando as conexões de Saída para o FTP | 1417 | // Liberando as conexões de Saída para o FTP |
1264 | - SetValorChaveRegEdit('HKEY_LOCAL//_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\FTP-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App=C:\\windows\\system32\\ftp.exe|Name=Programa de transferência de arquivos|Desc=Programa de transferência de arquivos|Edge=FALSE|'); | ||
1265 | - SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\FTP-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App=C:\\windows\\system32\\ftp.exe|Name=Programa de transferência de arquivos|Desc=Programa de transferência de arquivos|Edge=FALSE|'); | 1418 | + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\FTP-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+HomeDrive+'\system32\\ftp.exe|Name=Programa de transferência de arquivos|Desc=Programa de transferência de arquivos|Edge=FALSE|'); |
1419 | + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\FTP-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+HomeDrive+'\system32\\ftp.exe|Name=Programa de transferência de arquivos|Desc=Programa de transferência de arquivos|Edge=FALSE|'); | ||
1266 | 1420 | ||
1267 | // Liberando as conexões de Saída para o Ger_Cols | 1421 | // Liberando as conexões de Saída para o Ger_Cols |
1268 | SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-GERCOLS-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+Dir+'\modulos\\ger_cols.exe|Name=Módulo Gerente de Coletas do Sistema CACIC|Desc=Módulo Gerente de Coletas do Sistema CACIC|Edge=FALSE|'); | 1422 | SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-GERCOLS-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+Dir+'\modulos\\ger_cols.exe|Name=Módulo Gerente de Coletas do Sistema CACIC|Desc=Módulo Gerente de Coletas do Sistema CACIC|Edge=FALSE|'); |
@@ -1303,6 +1457,7 @@ begin | @@ -1303,6 +1457,7 @@ begin | ||
1303 | LogDiario('Abrindo formulário de configurações'); | 1457 | LogDiario('Abrindo formulário de configurações'); |
1304 | bool_configura := false; | 1458 | bool_configura := false; |
1305 | CriaFormConfigura; | 1459 | CriaFormConfigura; |
1460 | + | ||
1306 | Configs.Edit_ip_serv_cacic.text := v_ip_serv_cacic; | 1461 | Configs.Edit_ip_serv_cacic.text := v_ip_serv_cacic; |
1307 | Configs.Edit_cacic_dir.text := v_cacic_dir; | 1462 | Configs.Edit_cacic_dir.text := v_cacic_dir; |
1308 | if v_exibe_informacoes = 'S' then | 1463 | if v_exibe_informacoes = 'S' then |
@@ -1352,7 +1507,7 @@ begin | @@ -1352,7 +1507,7 @@ begin | ||
1352 | Response_Config := TStringStream.Create(''); | 1507 | Response_Config := TStringStream.Create(''); |
1353 | 1508 | ||
1354 | Try | 1509 | Try |
1355 | - LogDiario('Iniciando comunicação com '+'http://' + v_ip_serv_cacic + '/cacic2/ws/get_config.php'); | 1510 | + LogDiario('Iniciando comunicação com Servidor Gerente WEB do CACIC'); |
1356 | IdHTTP1 := TIdHTTP.Create(IdHTTP1); | 1511 | IdHTTP1 := TIdHTTP.Create(IdHTTP1); |
1357 | idHTTP1.AllowCookies := true; | 1512 | idHTTP1.AllowCookies := true; |
1358 | idHTTP1.ASCIIFilter := false; | 1513 | idHTTP1.ASCIIFilter := false; |
@@ -1372,7 +1527,7 @@ begin | @@ -1372,7 +1527,7 @@ begin | ||
1372 | idHTTP1.Request.ContentType := 'text/html'; | 1527 | idHTTP1.Request.ContentType := 'text/html'; |
1373 | idHTTP1.SendBufferSize := 32768; | 1528 | idHTTP1.SendBufferSize := 32768; |
1374 | idHTTP1.Tag := 0; | 1529 | idHTTP1.Tag := 0; |
1375 | - | 1530 | + |
1376 | IdHTTP1.Post('http://' + v_ip_serv_cacic + '/cacic2/ws/get_config.php', Request_Config, Response_Config); | 1531 | IdHTTP1.Post('http://' + v_ip_serv_cacic + '/cacic2/ws/get_config.php', Request_Config, Response_Config); |
1377 | idHTTP1.Disconnect; | 1532 | idHTTP1.Disconnect; |
1378 | idHTTP1.Free; | 1533 | idHTTP1.Free; |
@@ -1396,13 +1551,11 @@ begin | @@ -1396,13 +1551,11 @@ begin | ||
1396 | LogDebug('------------------------------'); | 1551 | LogDebug('------------------------------'); |
1397 | LogDebug('Cacic2 - Agente do Systray.........: '+XML_RetornaValor('CACIC2', v_retorno)); | 1552 | LogDebug('Cacic2 - Agente do Systray.........: '+XML_RetornaValor('CACIC2', v_retorno)); |
1398 | LogDebug('Ger_Cols - Gerente de Coletas........: '+XML_RetornaValor('GER_COLS', v_retorno)); | 1553 | LogDebug('Ger_Cols - Gerente de Coletas........: '+XML_RetornaValor('GER_COLS', v_retorno)); |
1399 | - LogDebug('SrCACIC - Suporte Remoto Seguro.....: '+XML_RetornaValor('SRCACICSRV', v_retorno)); | ||
1400 | LogDebug('ChkSis - Verificador de Integridade: '+XML_RetornaValor('CHKSIS', v_retorno)); | 1554 | LogDebug('ChkSis - Verificador de Integridade: '+XML_RetornaValor('CHKSIS', v_retorno)); |
1401 | LogDebug(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); | 1555 | LogDebug(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); |
1402 | Except | 1556 | Except |
1403 | Begin | 1557 | Begin |
1404 | - if v_exibe_informacoes = 'S' then | ||
1405 | - MessageDLG(#13#10+'ATENÇÃO! Não foi possível estabelecer comunicação com o módulo Gerente WEB em "'+v_ip_serv_cacic+'".',mtError,[mbOK],0); | 1558 | + Configs.Memo_te_instala_informacoes_extras.Lines.Add(#13#10+'ATENÇÃO! Não foi possível estabelecer comunicação com o módulo Gerente WEB em "'+v_ip_serv_cacic+'".'); |
1406 | LogDiario('**********************************************************'); | 1559 | LogDiario('**********************************************************'); |
1407 | LogDiario('Oops! Não Foi Possível Comunicar com o Módulo Gerente WEB!'); | 1560 | LogDiario('Oops! Não Foi Possível Comunicar com o Módulo Gerente WEB!'); |
1408 | LogDiario('**********************************************************'); | 1561 | LogDiario('**********************************************************'); |
@@ -1493,64 +1646,64 @@ begin | @@ -1493,64 +1646,64 @@ begin | ||
1493 | Matar(Dir + '\modulos\', 'ger_cols.exe'); | 1646 | Matar(Dir + '\modulos\', 'ger_cols.exe'); |
1494 | End; | 1647 | End; |
1495 | 1648 | ||
1496 | - // Verificação de versão do srcacicsrv.exe e exclusão em caso de versão antiga/diferente da atual | ||
1497 | - If (FileExists(Dir + '\modulos\srcacicsrv.exe')) Then | ||
1498 | - Begin | ||
1499 | - // Pego as informações de dia/mês/ano/horas/minutos/segundos/milésimos que identificam o agente SrCACIC | ||
1500 | - strDataHoraSRCACICSRV_INI := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(Dir + '\modulos\srcacicsrv.exe')); | 1649 | + // Verificação de versão do chksis.exe e exclusão em caso de versão antiga/diferente da atual |
1650 | + If (FileExists(HomeDrive + '\chksis.exe')) Then | ||
1651 | + Begin | ||
1652 | + intAux := ChecaVersoesAgentes(HomeDrive + '\chksis.exe'); | ||
1653 | + // 0 => Arquivo de versões ou informação inexistente | ||
1654 | + // 1 => Versões iguais | ||
1655 | + // 2 => Versões diferentes | ||
1656 | + if (intAux = 0) then | ||
1657 | + Begin | ||
1658 | + v_versao_local := StringReplace(trim(GetVersionInfo(HomeDrive + '\chksis.exe')),'.','',[rfReplaceAll]); | ||
1659 | + v_versao_remota := StringReplace(XML_RetornaValor('CHKSIS' , v_retorno),'0103','',[rfReplaceAll]); | ||
1660 | + End; | ||
1501 | 1661 | ||
1502 | - intAux := ChecaVersoesAgentes(Dir + '\modulos\srcacicsrv.exe'); | ||
1503 | - // 0 => Arquivo de versões ou informação inexistente | ||
1504 | - // 1 => Versões iguais | ||
1505 | - // 2 => Versões diferentes | ||
1506 | - if (intAux = 0) then | ||
1507 | - Begin | ||
1508 | - v_versao_local := StringReplace(trim(GetVersionInfo(Dir + '\modulos\srcacicsrv.exe')),'.','',[rfReplaceAll]); | ||
1509 | - v_versao_remota := StringReplace(XML_RetornaValor('SRCACICSRV' , v_retorno),'0103','',[rfReplaceAll]); | ||
1510 | - End; | 1662 | + if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"... |
1663 | + (v_versao_local ='0000') then // Provavelmente versão muito antiga ou corrompida | ||
1664 | + Matar(HomeDrive,'chksis.exe'); | ||
1665 | + End; | ||
1511 | 1666 | ||
1512 | - if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"... | ||
1513 | - (v_versao_local ='0000') then // Provavelmente versão muito antiga ou corrompida | ||
1514 | - Matar(Dir + '\modulos\', 'srcacicsrv.exe'); | ||
1515 | - End; | 1667 | + // Tento detectar o ChkSis.EXE e copio ou faço FTP caso não exista |
1668 | + verifyAndGet('chksis.exe', | ||
1669 | + XML_RetornaValor('CHKSIS_HASH', v_retorno), | ||
1670 | + HomeDrive, | ||
1671 | + v_te_serv_updates, | ||
1672 | + v_nu_porta_serv_updates, | ||
1673 | + v_nm_usuario_login_serv_updates, | ||
1674 | + v_te_senha_login_serv_updates, | ||
1675 | + v_te_path_serv_updates, | ||
1676 | + v_exibe_informacoes); | ||
1516 | 1677 | ||
1678 | + // Tento detectar o ChkSis.INI e crio-o caso necessário | ||
1679 | + If not FileExists(HomeDrive + '\chksis.ini') Then | ||
1680 | + begin | ||
1681 | + LogDebug('Criando '+HomeDrive + '\chksis.ini'); | ||
1682 | + GravaIni(HomeDrive + '\chksis.ini'); | ||
1683 | + FileSetAttr ( PChar(HomeDrive + '\chksis.ini'),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 | ||
1684 | + end; | ||
1517 | 1685 | ||
1518 | - // Verificação de versão do chksis.exe e exclusão em caso de versão antiga/diferente da atual | ||
1519 | - If (FileExists(HomeDrive + '\chksis.exe')) Then | ||
1520 | - Begin | ||
1521 | - intAux := ChecaVersoesAgentes(HomeDrive + '\chksis.exe'); | ||
1522 | - // 0 => Arquivo de versões ou informação inexistente | ||
1523 | - // 1 => Versões iguais | ||
1524 | - // 2 => Versões diferentes | ||
1525 | - if (intAux = 0) then | ||
1526 | - Begin | ||
1527 | - v_versao_local := StringReplace(trim(GetVersionInfo(HomeDrive + '\chksis.exe')),'.','',[rfReplaceAll]); | ||
1528 | - v_versao_remota := StringReplace(XML_RetornaValor('CHKSIS' , v_retorno),'0103','',[rfReplaceAll]); | ||
1529 | - End; | ||
1530 | 1686 | ||
1531 | - if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"... | ||
1532 | - (v_versao_local ='0000') then // Provavelmente versão muito antiga ou corrompida | ||
1533 | - Matar(HomeDrive,'chksis.exe'); | 1687 | + // Verificação de existência do CacicSvc.exe |
1688 | + If (g_oCacic.isWindowsNTPlataform()) then | ||
1689 | + Begin | ||
1690 | + // Tento detectar o CACICsvc.EXE e copio ou faço FTP caso não exista | ||
1691 | + verifyAndGet('cacicsvc.exe', | ||
1692 | + XML_RetornaValor('CACICSVC_HASH', v_retorno), | ||
1693 | + HomeDrive, | ||
1694 | + v_te_serv_updates, | ||
1695 | + v_nu_porta_serv_updates, | ||
1696 | + v_nm_usuario_login_serv_updates, | ||
1697 | + v_te_senha_login_serv_updates, | ||
1698 | + v_te_path_serv_updates, | ||
1699 | + v_exibe_informacoes); | ||
1700 | + | ||
1701 | + // O CACICsvc usará o arquivo de configurações \Windows\chksis.ini | ||
1702 | + | ||
1703 | + //LogDebug('reCriando '+HomeDrive + '\cacicsvc.ini'); | ||
1704 | + //GravaIni(HomeDrive + '\cacicsvc.ini'); | ||
1534 | End; | 1705 | End; |
1535 | 1706 | ||
1536 | - // Tento detectar o ChkSis.EXE e copio ou faço FTP caso não exista | ||
1537 | - verifyAndGet('chksis.exe', | ||
1538 | - HomeDrive, | ||
1539 | - v_te_serv_updates, | ||
1540 | - v_nu_porta_serv_updates, | ||
1541 | - v_nm_usuario_login_serv_updates, | ||
1542 | - v_te_senha_login_serv_updates, | ||
1543 | - v_te_path_serv_updates, | ||
1544 | - v_exibe_informacoes); | ||
1545 | - | ||
1546 | - // Tento detectar o ChkSis.INI e crio-o caso necessário | ||
1547 | - If not FileExists(HomeDrive + '\chksis.ini') Then | ||
1548 | - begin | ||
1549 | - LogDebug('Criando '+HomeDrive + '\chksis.ini'); | ||
1550 | - GravaIni(HomeDrive + '\chksis.ini'); | ||
1551 | - FileSetAttr ( PChar(HomeDrive + '\chksis.ini'),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 | ||
1552 | - end; | ||
1553 | - | ||
1554 | // Tento detectar o cacic2.INI e crio-o caso necessário | 1707 | // Tento detectar o cacic2.INI e crio-o caso necessário |
1555 | If not FileExists(Dir + '\cacic2.ini') Then | 1708 | If not FileExists(Dir + '\cacic2.ini') Then |
1556 | begin | 1709 | begin |
@@ -1564,6 +1717,7 @@ begin | @@ -1564,6 +1717,7 @@ begin | ||
1564 | 1717 | ||
1565 | // Tento detectar o Agente Principal e copio ou faço FTP caso não exista | 1718 | // Tento detectar o Agente Principal e copio ou faço FTP caso não exista |
1566 | verifyAndGet('cacic2.exe', | 1719 | verifyAndGet('cacic2.exe', |
1720 | + XML_RetornaValor('CACIC2_HASH', v_retorno), | ||
1567 | Dir, | 1721 | Dir, |
1568 | v_te_serv_updates, | 1722 | v_te_serv_updates, |
1569 | v_nu_porta_serv_updates, | 1723 | v_nu_porta_serv_updates, |
@@ -1573,6 +1727,7 @@ begin | @@ -1573,6 +1727,7 @@ begin | ||
1573 | v_exibe_informacoes); | 1727 | v_exibe_informacoes); |
1574 | 1728 | ||
1575 | verifyAndGet('ger_cols.exe', | 1729 | verifyAndGet('ger_cols.exe', |
1730 | + XML_RetornaValor('GER_COLS_HASH', v_retorno), | ||
1576 | Dir + '\modulos', | 1731 | Dir + '\modulos', |
1577 | v_te_serv_updates, | 1732 | v_te_serv_updates, |
1578 | v_nu_porta_serv_updates, | 1733 | v_nu_porta_serv_updates, |
@@ -1581,16 +1736,7 @@ begin | @@ -1581,16 +1736,7 @@ begin | ||
1581 | v_te_path_serv_updates, | 1736 | v_te_path_serv_updates, |
1582 | v_exibe_informacoes); | 1737 | v_exibe_informacoes); |
1583 | 1738 | ||
1584 | - verifyAndGet('srcacicsrv.exe', | ||
1585 | - Dir + '\modulos', | ||
1586 | - v_te_serv_updates, | ||
1587 | - v_nu_porta_serv_updates, | ||
1588 | - v_nm_usuario_login_serv_updates, | ||
1589 | - v_te_senha_login_serv_updates, | ||
1590 | - v_te_path_serv_updates, | ||
1591 | - v_exibe_informacoes); | ||
1592 | - | ||
1593 | - // Caso exista a pasta "modulos", copio todos os executáveis para a pasta Cacic\modulos, exceto cacic2.exe, ger_cols.exe, srcacicsrv.exe e chksis.exe | 1739 | + // Caso exista a pasta "modulos", copio todos os executáveis para a pasta Cacic\modulos, exceto cacic2.exe, ger_cols.exe e chksis.exe |
1594 | if (v_modulos <> '') then | 1740 | if (v_modulos <> '') then |
1595 | Begin | 1741 | Begin |
1596 | v_array_modulos := explode(v_modulos,'#'); | 1742 | v_array_modulos := explode(v_modulos,'#'); |
@@ -1598,7 +1744,6 @@ begin | @@ -1598,7 +1744,6 @@ begin | ||
1598 | Begin | 1744 | Begin |
1599 | if (v_array_modulos[intAux]<>'cacic2.exe') and | 1745 | if (v_array_modulos[intAux]<>'cacic2.exe') and |
1600 | (v_array_modulos[intAux]<>'ger_cols.exe') and | 1746 | (v_array_modulos[intAux]<>'ger_cols.exe') and |
1601 | - (v_array_modulos[intAux]<>'srcacicsrv.exe') and | ||
1602 | (v_array_modulos[intAux]<>'chksis.exe') then | 1747 | (v_array_modulos[intAux]<>'chksis.exe') then |
1603 | Begin | 1748 | Begin |
1604 | LogDiario('Copiando '+v_array_modulos[intAux]+' de '+ExtractFilePath(Application.Exename)+'modulos\'); | 1749 | LogDiario('Copiando '+v_array_modulos[intAux]+' de '+ExtractFilePath(Application.Exename)+'modulos\'); |
@@ -1614,6 +1759,7 @@ begin | @@ -1614,6 +1759,7 @@ begin | ||
1614 | 1759 | ||
1615 | // Tento detectar (de novo) o ChkSis.EXE e copio ou faço FTP caso não exista | 1760 | // Tento detectar (de novo) o ChkSis.EXE e copio ou faço FTP caso não exista |
1616 | verifyAndGet('chksis.exe', | 1761 | verifyAndGet('chksis.exe', |
1762 | + XML_RetornaValor('CHKSIS_HASH', v_retorno), | ||
1617 | HomeDrive, | 1763 | HomeDrive, |
1618 | v_te_serv_updates, | 1764 | v_te_serv_updates, |
1619 | v_nu_porta_serv_updates, | 1765 | v_nu_porta_serv_updates, |
@@ -1624,6 +1770,7 @@ begin | @@ -1624,6 +1770,7 @@ begin | ||
1624 | 1770 | ||
1625 | // Tento detectar (de novo) o Agente Principal e copio ou faço FTP caso não exista | 1771 | // Tento detectar (de novo) o Agente Principal e copio ou faço FTP caso não exista |
1626 | verifyAndGet('cacic2.exe', | 1772 | verifyAndGet('cacic2.exe', |
1773 | + XML_RetornaValor('CACIC2_HASH', v_retorno), | ||
1627 | Dir, | 1774 | Dir, |
1628 | v_te_serv_updates, | 1775 | v_te_serv_updates, |
1629 | v_nu_porta_serv_updates, | 1776 | v_nu_porta_serv_updates, |
@@ -1633,6 +1780,7 @@ begin | @@ -1633,6 +1780,7 @@ begin | ||
1633 | v_exibe_informacoes); | 1780 | v_exibe_informacoes); |
1634 | 1781 | ||
1635 | verifyAndGet('ger_cols.exe', | 1782 | verifyAndGet('ger_cols.exe', |
1783 | + XML_RetornaValor('GER_COLS_HASH', v_retorno), | ||
1636 | Dir + '\modulos', | 1784 | Dir + '\modulos', |
1637 | v_te_serv_updates, | 1785 | v_te_serv_updates, |
1638 | v_nu_porta_serv_updates, | 1786 | v_nu_porta_serv_updates, |
@@ -1641,20 +1789,16 @@ begin | @@ -1641,20 +1789,16 @@ begin | ||
1641 | v_te_path_serv_updates, | 1789 | v_te_path_serv_updates, |
1642 | v_exibe_informacoes); | 1790 | v_exibe_informacoes); |
1643 | 1791 | ||
1644 | - verifyAndGet('srcacicsrv.exe', | ||
1645 | - Dir + '\modulos', | ||
1646 | - v_te_serv_updates, | ||
1647 | - v_nu_porta_serv_updates, | ||
1648 | - v_nm_usuario_login_serv_updates, | ||
1649 | - v_te_senha_login_serv_updates, | ||
1650 | - v_te_path_serv_updates, | ||
1651 | - v_exibe_informacoes); | ||
1652 | 1792 | ||
1793 | + { | ||
1653 | if ((intWinVer <> 0) and (intWinVer >= 8)) or | 1794 | if ((intWinVer <> 0) and (intWinVer >= 8)) or |
1654 | (abstraiCSD(v_te_so) >= 250) then // Se >= WinXP... | 1795 | (abstraiCSD(v_te_so) >= 250) then // Se >= WinXP... |
1796 | + } | ||
1797 | + | ||
1798 | + if (g_oCacic.isWindowsNTPlataform) then | ||
1655 | Begin | 1799 | Begin |
1656 | Try | 1800 | Try |
1657 | - // Acrescento o ChkSis e o Ger_Cols às exceções do FireWall nativo... | 1801 | + // Acrescento o Ger_Cols e srCacicSrv às exceções do FireWall nativo... |
1658 | 1802 | ||
1659 | {chksis} | 1803 | {chksis} |
1660 | LogDebug('Inserindo "'+HomeDrive + '\chksis" nas exceções do FireWall!'); | 1804 | LogDebug('Inserindo "'+HomeDrive + '\chksis" nas exceções do FireWall!'); |
@@ -1674,15 +1818,24 @@ begin | @@ -1674,15 +1818,24 @@ begin | ||
1674 | 1818 | ||
1675 | LogDebug('Gravando registros para auto-execução'); | 1819 | LogDebug('Gravando registros para auto-execução'); |
1676 | 1820 | ||
1677 | - // Crio a chave/valor cacic2 para autoexecução do Cacic, caso não exista esta chave/valor | ||
1678 | - // Crio a chave/valor chksis para autoexecução do ChkSIS, caso não exista esta chave/valor | ||
1679 | - SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\CheckSystemRoutine', HomeDrive + '\chksis.exe'); | 1821 | + // Somente para S.O. NOT NT LIKE |
1822 | + if NOT (g_oCacic.isWindowsNTPlataform) then | ||
1823 | + Begin | ||
1824 | + // Crio a chave/valor cacic2 para autoexecução do Cacic, caso não exista esta chave/valor | ||
1825 | + // Crio a chave/valor chksis para autoexecução do ChkSIS, caso não exista esta chave/valor | ||
1826 | + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\CheckSystemRoutine', HomeDrive + '\chksis.exe'); | ||
1680 | 1827 | ||
1681 | - bool_ExistsAutoRun := false; | ||
1682 | - if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') then | ||
1683 | - bool_ExistsAutoRun := true | 1828 | + bool_ExistsAutoRun := false; |
1829 | + if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') then | ||
1830 | + bool_ExistsAutoRun := true | ||
1831 | + else | ||
1832 | + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2', Dir + '\cacic2.exe'); | ||
1833 | + End | ||
1684 | else | 1834 | else |
1685 | - SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2', Dir + '\cacic2.exe'); | 1835 | + Begin |
1836 | + DelValorReg('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2'); | ||
1837 | + DelValorReg('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\CheckSystemRoutine'); | ||
1838 | + End; | ||
1686 | 1839 | ||
1687 | // Igualo as chaves ip_serv_cacic dos arquivos chksis.ini e cacic2.ini! | 1840 | // Igualo as chaves ip_serv_cacic dos arquivos chksis.ini e cacic2.ini! |
1688 | SetValorDatMemoria('Configs.EnderecoServidor', v_ip_serv_cacic); | 1841 | SetValorDatMemoria('Configs.EnderecoServidor', v_ip_serv_cacic); |
@@ -1707,24 +1860,21 @@ begin | @@ -1707,24 +1860,21 @@ begin | ||
1707 | strDataHoraGERCOLS_FIM := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(Dir + '\modulos\ger_cols.exe')); | 1860 | strDataHoraGERCOLS_FIM := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(Dir + '\modulos\ger_cols.exe')); |
1708 | LogDebug('Inicial => "' + strDataHoraGERCOLS_INI + '" Final => "' + strDataHoraGERCOLS_FIM + '"'); | 1861 | LogDebug('Inicial => "' + strDataHoraGERCOLS_INI + '" Final => "' + strDataHoraGERCOLS_FIM + '"'); |
1709 | 1862 | ||
1710 | - LogDebug('Resgatando informações para identificação de alteração do agente SRCACIC'); | ||
1711 | - strDataHoraSRCACICSRV_FIM := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(Dir + '\modulos\srcacicsrv.exe')); | ||
1712 | - LogDebug('Inicial => "' + strDataHoraSRCACICSRV_INI + '" Final => "' + strDataHoraSRCACICSRV_FIM + '"'); | ||
1713 | - | ||
1714 | // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor | 1863 | // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor |
1715 | if ((strDataHoraCACIC2_INI <> strDataHoraCACIC2_FIM) OR | 1864 | if ((strDataHoraCACIC2_INI <> strDataHoraCACIC2_FIM) OR |
1716 | (strDataHoraGERCOLS_INI <> strDataHoraGERCOLS_FIM)) then | 1865 | (strDataHoraGERCOLS_INI <> strDataHoraGERCOLS_FIM)) then |
1717 | Begin | 1866 | Begin |
1718 | v_te_texto_janela_instalacao := v_te_instala_informacoes_extras; | 1867 | v_te_texto_janela_instalacao := v_te_instala_informacoes_extras; |
1719 | - if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') then | 1868 | + |
1869 | + if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') and | ||
1870 | + (not g_oCacic.isWindowsNTPlataform()) or | ||
1871 | + (g_oCacic.isWindowsNTPlataform()) then | ||
1720 | Begin | 1872 | Begin |
1721 | - if (v_exibe_informacoes = 'S') then | ||
1722 | - MessageDlg(#13#10+#13#10+'Sistema CACIC'+#13#10+#13#10+v_te_instala_frase_sucesso+#13#10+#13#10+#13#10 + '======================================================' + #13#10 + v_te_texto_janela_instalacao+ #13#10 +'======================================================',mtInformation,[mbok],0); | 1873 | + configs.Memo_te_instala_informacoes_extras.Lines.Add(#13#10+#13#10+'Sistema CACIC'+#13#10+#13#10+v_te_instala_frase_sucesso); |
1723 | End | 1874 | End |
1724 | else | 1875 | else |
1725 | Begin | 1876 | Begin |
1726 | - if (v_exibe_informacoes = 'S') then | ||
1727 | - MessageDlg(#13#10+#13#10+'Sistema CACIC'+#13#10+#13#10+v_te_instala_frase_insucesso+#13#10+#13#10+#13#10 + '======================================================' + #13#10 + v_te_texto_janela_instalacao+ #13#10 +'======================================================',mtInformation,[mbok],0); | 1877 | + Configs.Memo_te_instala_informacoes_extras.Lines.Add(#13#10+#13#10+'Sistema CACIC'+#13#10+#13#10+v_te_instala_frase_insucesso); |
1728 | ComunicaInsucesso('1'); // O indicador "1" sinalizará que não foi devido a privilégio na estação | 1878 | ComunicaInsucesso('1'); // O indicador "1" sinalizará que não foi devido a privilégio na estação |
1729 | End; | 1879 | End; |
1730 | End | 1880 | End |
@@ -1735,25 +1885,76 @@ begin | @@ -1735,25 +1885,76 @@ begin | ||
1735 | not bool_ExistsAutoRun or | 1885 | not bool_ExistsAutoRun or |
1736 | (strDataHoraCACIC2_INI <> strDataHoraCACIC2_FIM) then | 1886 | (strDataHoraCACIC2_INI <> strDataHoraCACIC2_FIM) then |
1737 | Begin | 1887 | Begin |
1738 | - LogDebug('Executando '+Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic); | ||
1739 | - | ||
1740 | - // Caso tenha havido download de agentes principais, executar coletas imediatamente... | ||
1741 | - if (strDataHoraCACIC2_INI <> strDataHoraCACIC2_FIM) then | ||
1742 | - WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE) | 1888 | + // Se não for plataforma NT executo o agente principal |
1889 | + if not (g_oCacic.isWindowsNTPlataform()) then | ||
1890 | + Begin | ||
1891 | + LogDebug('Executando '+Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic); | ||
1892 | + if (strDataHoraCACIC2_INI <> strDataHoraCACIC2_FIM) then | ||
1893 | + WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE) | ||
1894 | + else | ||
1895 | + WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic ), SW_HIDE); | ||
1896 | + End | ||
1743 | else | 1897 | else |
1744 | - WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic ), SW_HIDE); | 1898 | + Begin |
1899 | + | ||
1900 | + {*** 1 = SERVICE_STOPPED ***} | ||
1901 | + {*** 2 = SERVICE_START_PENDING ***} | ||
1902 | + {*** 3 = SERVICE_STOP_PENDING ***} | ||
1903 | + {*** 4 = SERVICE_RUNNING ***} | ||
1904 | + {*** 5 = SERVICE_CONTINUE_PENDING ***} | ||
1905 | + {*** 6 = SERVICE_PAUSE_PENDING ***} | ||
1906 | + {*** 7 = SERVICE_PAUSED ***} | ||
1907 | + | ||
1908 | + // Verifico se o serviço está instalado/rodando,etc. | ||
1909 | + wordServiceStatus := ServiceGetStatus(nil,'cacicservice'); | ||
1910 | + if (wordServiceStatus = 0) then | ||
1911 | + Begin | ||
1912 | + // Instalo e Habilito o serviço | ||
1913 | + LogDiario('Instalando CACICservice...'); | ||
1914 | + WinExec(PChar(HomeDrive + '\cacicsvc.exe -install'), SW_NORMAL); | ||
1915 | + End | ||
1916 | + else if ((wordServiceStatus < 4) or | ||
1917 | + (wordServiceStatus > 4)) then | ||
1918 | + Begin | ||
1919 | + LogDiario('Iniciando CACICservice'); | ||
1920 | + WinExec(PChar(HomeDrive + '\cacicsvc.exe -start'), SW_NORMAL); | ||
1921 | + End | ||
1922 | + else | ||
1923 | + LogDiario('Não instalei o CACICservice. Já está rodando...'); | ||
1924 | + End; | ||
1745 | End | 1925 | End |
1746 | else | 1926 | else |
1747 | LogDebug('Chave de Auto-Execução já existente ou Execução já iniciada...'); | 1927 | LogDebug('Chave de Auto-Execução já existente ou Execução já iniciada...'); |
1928 | + End | ||
1929 | + else | ||
1930 | + Begin // Se NT/2000/XP/... | ||
1931 | + if (v_exibe_informacoes = 'S') and not bool_CommandLine then | ||
1932 | + MessageDLG(#13#10+'ATENÇÃO! Essa aplicação requer execução com nível administrativo.',mtError,[mbOK],0); | ||
1933 | + LogDiario('Sem Privilégios: Necessário ser administrador "local" da estação'); | ||
1934 | + ComunicaInsucesso('0'); // O indicador "0" (zero) sinalizará falta de privilégio na estação | ||
1748 | End; | 1935 | End; |
1749 | Except | 1936 | Except |
1750 | LogDiario('Falha na Instalação/Atualização'); | 1937 | LogDiario('Falha na Instalação/Atualização'); |
1751 | End; | 1938 | End; |
1939 | + | ||
1940 | + Application.Terminate; | ||
1941 | + { | ||
1942 | + Considerando-se que o objeto se libera ao fim da aplicação | ||
1752 | try | 1943 | try |
1753 | g_oCacic.Free(); | 1944 | g_oCacic.Free(); |
1754 | except | 1945 | except |
1755 | end; | 1946 | end; |
1756 | - Application.Terminate; | 1947 | + } |
1948 | +end; | ||
1949 | + | ||
1950 | +function ServiceRunning(sMachine, sService: PChar): Boolean; | ||
1951 | +begin | ||
1952 | + Result := SERVICE_RUNNING = ServiceGetStatus(sMachine, sService); | ||
1953 | +end; | ||
1954 | + | ||
1955 | +function ServiceStopped(sMachine, sService: PChar): Boolean; | ||
1956 | +begin | ||
1957 | + Result := SERVICE_STOPPED = ServiceGetStatus(sMachine, sService); | ||
1757 | end; | 1958 | end; |
1758 | 1959 | ||
1759 | function FindWindowByTitle(WindowTitle: string): Hwnd; | 1960 | function FindWindowByTitle(WindowTitle: string): Hwnd; |
@@ -1855,7 +2056,6 @@ end; | @@ -1855,7 +2056,6 @@ end; | ||
1855 | procedure TForm1.FS_SetSecurity(p_Target : String); | 2056 | procedure TForm1.FS_SetSecurity(p_Target : String); |
1856 | var intAux : integer; | 2057 | var intAux : integer; |
1857 | v_FS_Security : TNTFileSecurity; | 2058 | v_FS_Security : TNTFileSecurity; |
1858 | - boolFound : boolean; | ||
1859 | begin | 2059 | begin |
1860 | v_FS_Security := TNTFileSecurity.Create(nil); | 2060 | v_FS_Security := TNTFileSecurity.Create(nil); |
1861 | v_FS_Security.FileName := ''; | 2061 | v_FS_Security.FileName := ''; |
chksis/chksis.dpr
@@ -842,7 +842,7 @@ begin | @@ -842,7 +842,7 @@ begin | ||
842 | v_DatFileName := Dir + '\cacic2.dat'; | 842 | v_DatFileName := Dir + '\cacic2.dat'; |
843 | 843 | ||
844 | // Verifico existência dos dois principais objetos | 844 | // Verifico existência dos dois principais objetos |
845 | - If (not FileExists(Dir + '\cacic2.exe')) or (not FileExists(Dir + '\modulos\ger_cols.exe')) or (not FileExists(Dir + '\modulos\srcacicsrv.exe')) Then | 845 | + If (not FileExists(Dir + '\cacic2.exe')) or (not FileExists(Dir + '\modulos\ger_cols.exe')) Then |
846 | Begin | 846 | Begin |
847 | // Busco as configurações para acesso ao ambiente FTP - Updates | 847 | // Busco as configurações para acesso ao ambiente FTP - Updates |
848 | Request_Config := TStringList.Create; | 848 | Request_Config := TStringList.Create; |
@@ -876,7 +876,6 @@ begin | @@ -876,7 +876,6 @@ begin | ||
876 | log_diario('------------------------------'); | 876 | log_diario('------------------------------'); |
877 | log_diario('Cacic2 - Agente do Systray.........: '+XML_RetornaValor('CACIC2', v_retorno)); | 877 | log_diario('Cacic2 - Agente do Systray.........: '+XML_RetornaValor('CACIC2', v_retorno)); |
878 | log_diario('Ger_Cols - Gerente de Coletas........: '+XML_RetornaValor('GER_COLS', v_retorno)); | 878 | log_diario('Ger_Cols - Gerente de Coletas........: '+XML_RetornaValor('GER_COLS', v_retorno)); |
879 | - log_diario('SrCACIC - Suporte Remoto Seguro.....: '+XML_RetornaValor('SRCACICSRV', v_retorno)); | ||
880 | log_diario('ChkSis - Verificador de Integridade: '+XML_RetornaValor('CHKSIS', v_retorno)); | 879 | log_diario('ChkSis - Verificador de Integridade: '+XML_RetornaValor('CHKSIS', v_retorno)); |
881 | log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); | 880 | log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); |
882 | 881 | ||
@@ -924,81 +923,47 @@ begin | @@ -924,81 +923,47 @@ begin | ||
924 | 923 | ||
925 | End; | 924 | End; |
926 | 925 | ||
927 | - // Verificação de versão do srcacic.exe e exclusão em caso de versão antiga | ||
928 | - If (FileExists(Dir + '\modulos\srcacicsrv.exe')) Then | ||
929 | - Begin | ||
930 | - intAux := ChecaVersoesAgentes(Dir + '\modulos\srcacicsrv.exe'); | ||
931 | - // 0 => Arquivo de versões ou informação inexistente | ||
932 | - // 1 => Versões iguais | ||
933 | - // 2 => Versões diferentes | ||
934 | - if (intAux = 0) then | ||
935 | - Begin | ||
936 | - v_versao_local := StringReplace(trim(GetVersionInfo(Dir + '\modulos\srcacicsrv.exe')),'.','',[rfReplaceAll]); | ||
937 | - v_versao_remota := StringReplace(XML_RetornaValor('SRCACICSRV' , v_retorno),'0103','',[rfReplaceAll]); | ||
938 | - End; | ||
939 | - | ||
940 | - if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"... | ||
941 | - (v_versao_local ='0000') then // Provavelmente versão muito antiga ou corrompida | ||
942 | - Matar(Dir + '\modulos\', 'srcacicsrv.exe'); | ||
943 | 926 | ||
944 | - End; | 927 | + // Tento detectar o Agente Principal e faço FTP caso não exista |
928 | + If not FileExists(Dir + '\cacic2.exe') Then | ||
929 | + begin | ||
930 | + log_diario('Fazendo FTP de cacic2.exe a partir de ' + v_te_serv_updates + '/' + | ||
931 | + v_nu_porta_serv_updates+'/'+ | ||
932 | + v_nm_usuario_login_serv_updates + '/' + | ||
933 | + v_te_path_serv_updates + ' para a pasta ' + Dir); | ||
934 | + FTP(v_te_serv_updates, | ||
935 | + v_nu_porta_serv_updates, | ||
936 | + v_nm_usuario_login_serv_updates, | ||
937 | + v_te_senha_login_serv_updates, | ||
938 | + v_te_path_serv_updates, | ||
939 | + 'cacic2.exe', | ||
940 | + Dir); | ||
941 | + bool_download_CACIC2 := true; | ||
942 | + end; | ||
945 | 943 | ||
946 | - // Tento detectar o Agente Principal e faço FTP caso não exista | ||
947 | - If not FileExists(Dir + '\cacic2.exe') Then | ||
948 | - begin | ||
949 | - log_diario('Fazendo FTP de cacic2.exe a partir de ' + v_te_serv_updates + '/' + | 944 | + // Tento detectar o Gerente de Coletas e faço FTP caso não exista |
945 | + If (not FileExists(Dir + '\modulos\ger_cols.exe')) Then | ||
946 | + begin | ||
947 | + log_diario('Fazendo FTP de ger_cols.exe a partir de ' + v_te_serv_updates + '/' + | ||
950 | v_nu_porta_serv_updates+'/'+ | 948 | v_nu_porta_serv_updates+'/'+ |
951 | v_nm_usuario_login_serv_updates + '/' + | 949 | v_nm_usuario_login_serv_updates + '/' + |
952 | - v_te_path_serv_updates + ' para a pasta ' + Dir); | ||
953 | - FTP(v_te_serv_updates, | ||
954 | - v_nu_porta_serv_updates, | ||
955 | - v_nm_usuario_login_serv_updates, | ||
956 | - v_te_senha_login_serv_updates, | ||
957 | - v_te_path_serv_updates, | ||
958 | - 'cacic2.exe', | ||
959 | - Dir); | ||
960 | - bool_download_CACIC2 := true; | ||
961 | - end; | ||
962 | - | ||
963 | - // Tento detectar o Gerente de Coletas e faço FTP caso não exista | ||
964 | - If (not FileExists(Dir + '\modulos\ger_cols.exe')) Then | ||
965 | - begin | ||
966 | - log_diario('Fazendo FTP de ger_cols.exe a partir de ' + v_te_serv_updates + '/' + | ||
967 | - v_nu_porta_serv_updates+'/'+ | ||
968 | - v_nm_usuario_login_serv_updates + '/' + | ||
969 | - v_te_path_serv_updates + ' para a pasta ' + Dir + '\modulos'); | ||
970 | - | ||
971 | - FTP(v_te_serv_updates, | ||
972 | - v_nu_porta_serv_updates, | ||
973 | - v_nm_usuario_login_serv_updates, | ||
974 | - v_te_senha_login_serv_updates, | ||
975 | - v_te_path_serv_updates, | ||
976 | - 'ger_cols.exe', | ||
977 | - Dir + '\modulos'); | ||
978 | - end; | ||
979 | - | ||
980 | - // Tento detectar o Suporte Remoto Seguro e faço FTP caso não exista | ||
981 | - If (not FileExists(Dir + '\modulos\srcacicsrv.exe')) Then | ||
982 | - begin | ||
983 | - log_diario('Fazendo FTP de srcacicsrv.exe a partir de ' + v_te_serv_updates + '/' + | ||
984 | - v_nu_porta_serv_updates+'/'+ | ||
985 | - v_nm_usuario_login_serv_updates + '/' + | ||
986 | - v_te_path_serv_updates + ' para a pasta ' + Dir + '\modulos'); | ||
987 | - | ||
988 | - FTP(v_te_serv_updates, | ||
989 | - v_nu_porta_serv_updates, | ||
990 | - v_nm_usuario_login_serv_updates, | ||
991 | - v_te_senha_login_serv_updates, | ||
992 | - v_te_path_serv_updates, | ||
993 | - 'srcacicsrv.exe', | ||
994 | - Dir + '\modulos'); | ||
995 | - end; | 950 | + v_te_path_serv_updates + ' para a pasta ' + Dir + '\modulos'); |
951 | + | ||
952 | + FTP(v_te_serv_updates, | ||
953 | + v_nu_porta_serv_updates, | ||
954 | + v_nm_usuario_login_serv_updates, | ||
955 | + v_te_senha_login_serv_updates, | ||
956 | + v_te_path_serv_updates, | ||
957 | + 'ger_cols.exe', | ||
958 | + Dir + '\modulos'); | ||
959 | + end; | ||
960 | + | ||
996 | 961 | ||
997 | End; | 962 | End; |
998 | 963 | ||
999 | // 5 segundos para espera de possível FTP... | 964 | // 5 segundos para espera de possível FTP... |
1000 | Sleep(5000); | 965 | Sleep(5000); |
1001 | - | 966 | + { |
1002 | Try | 967 | Try |
1003 | // Crio a chave/valor chksis para autoexecução do Cacic, caso não exista esta chave/valor | 968 | // Crio a chave/valor chksis para autoexecução do Cacic, caso não exista esta chave/valor |
1004 | log_diario('Setando chave HLM../Run com ' + HomeDrive + '\chksis.exe'); | 969 | log_diario('Setando chave HLM../Run com ' + HomeDrive + '\chksis.exe'); |
@@ -1006,6 +971,7 @@ begin | @@ -1006,6 +971,7 @@ begin | ||
1006 | Except | 971 | Except |
1007 | End; | 972 | End; |
1008 | 973 | ||
974 | + | ||
1009 | bool_ExistsAutoRun := false; | 975 | bool_ExistsAutoRun := false; |
1010 | if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') then | 976 | if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') then |
1011 | bool_ExistsAutoRun := true | 977 | bool_ExistsAutoRun := true |
@@ -1018,7 +984,7 @@ begin | @@ -1018,7 +984,7 @@ begin | ||
1018 | Except | 984 | Except |
1019 | End; | 985 | End; |
1020 | End; | 986 | End; |
1021 | - | 987 | + } |
1022 | // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor | 988 | // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor |
1023 | if Posso_Rodar_CACIC or not bool_ExistsAutoRun then | 989 | if Posso_Rodar_CACIC or not bool_ExistsAutoRun then |
1024 | Begin | 990 | Begin |
@@ -1030,7 +996,6 @@ begin | @@ -1030,7 +996,6 @@ begin | ||
1030 | else | 996 | else |
1031 | WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic ), SW_HIDE); | 997 | WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic ), SW_HIDE); |
1032 | End; | 998 | End; |
1033 | - log_diario('Não Executei. Chave de AutoExecução já existente...'); | ||
1034 | end; | 999 | end; |
1035 | 1000 | ||
1036 | const | 1001 | const |
chksis/chksis.res
No preview for this file type
col_anvi/col_anvi.res
No preview for this file type
col_comp/col_comp.res
No preview for this file type
col_hard/col_hard.res
No preview for this file type
col_moni/col_moni.res
No preview for this file type
col_patr/col_patr.res
No preview for this file type
col_soft/col_soft.res
No preview for this file type
col_undi/col_undi.res
No preview for this file type
ger_cols/ger_cols.dpr
@@ -67,7 +67,7 @@ var p_path_cacic, | @@ -67,7 +67,7 @@ var p_path_cacic, | ||
67 | v_DatFileName, | 67 | v_DatFileName, |
68 | v_ResultCompress, | 68 | v_ResultCompress, |
69 | v_ResultUnCompress, | 69 | v_ResultUnCompress, |
70 | - v_te_so : string; | 70 | + g_te_so : string; |
71 | 71 | ||
72 | var v_Aguarde : TextFile; | 72 | var v_Aguarde : TextFile; |
73 | 73 | ||
@@ -1177,19 +1177,16 @@ Begin | @@ -1177,19 +1177,16 @@ Begin | ||
1177 | strAux := 'A.B.C.D'; // Apenas para forçar que o Gerente extraia via _SERVER[REMOTE_ADDR] | 1177 | strAux := 'A.B.C.D'; // Apenas para forçar que o Gerente extraia via _SERVER[REMOTE_ADDR] |
1178 | 1178 | ||
1179 | // Tratamentos de valores para tráfego POST: | 1179 | // Tratamentos de valores para tráfego POST: |
1180 | - // v_te_so => transformar ' ' em <ESPACE> Razão: o mmcrypt se perde quando encontra ' ' (espaço) | ||
1181 | - v_te_so := StringReplace(v_te_so,' ','<ESPACE>',[rfReplaceAll]); | ||
1182 | - | ||
1183 | v_AuxRequest.Values['te_node_address'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | 1180 | v_AuxRequest.Values['te_node_address'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); |
1184 | - v_AuxRequest.Values['id_so'] := StringReplace(EnCrypt(g_oCacic.getWindowsStrId() , l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | ||
1185 | - v_AuxRequest.Values['te_so'] := StringReplace(EnCrypt(v_te_so ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | 1181 | + v_AuxRequest.Values['id_so'] := StringReplace(EnCrypt(g_oCacic.getWindowsStrId() ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]); |
1182 | + v_AuxRequest.Values['te_so'] := StringReplace(EnCrypt(g_te_so ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | ||
1186 | v_AuxRequest.Values['te_ip'] := StringReplace(EnCrypt(strAux ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | 1183 | v_AuxRequest.Values['te_ip'] := StringReplace(EnCrypt(strAux ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]); |
1187 | v_AuxRequest.Values['id_ip_rede'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | 1184 | v_AuxRequest.Values['id_ip_rede'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); |
1188 | v_AuxRequest.Values['te_workgroup'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | 1185 | v_AuxRequest.Values['te_workgroup'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); |
1189 | v_AuxRequest.Values['te_nome_computador']:= StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | 1186 | v_AuxRequest.Values['te_nome_computador']:= StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); |
1190 | - v_AuxRequest.Values['id_ip_estacao'] := StringReplace(EnCrypt(GetIP,l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | ||
1191 | - v_AuxRequest.Values['te_versao_cacic'] := StringReplace(EnCrypt(getVersionInfo(p_path_cacic + 'cacic2.exe'),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | ||
1192 | - v_AuxRequest.Values['te_versao_gercols'] := StringReplace(EnCrypt(getVersionInfo(ParamStr(0)),l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | 1187 | + v_AuxRequest.Values['id_ip_estacao'] := StringReplace(EnCrypt(GetIP ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]); |
1188 | + v_AuxRequest.Values['te_versao_cacic'] := StringReplace(EnCrypt(getVersionInfo(p_path_cacic + 'cacic2.exe') ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | ||
1189 | + v_AuxRequest.Values['te_versao_gercols'] := StringReplace(EnCrypt(getVersionInfo(ParamStr(0)) ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]); | ||
1193 | 1190 | ||
1194 | v_Endereco_WS := GetValorDatMemoria('Configs.Endereco_WS', v_tstrCipherOpened); | 1191 | v_Endereco_WS := GetValorDatMemoria('Configs.Endereco_WS', v_tstrCipherOpened); |
1195 | v_Endereco_Servidor := GetValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened); | 1192 | v_Endereco_Servidor := GetValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened); |
@@ -1243,7 +1240,7 @@ Begin | @@ -1243,7 +1240,7 @@ Begin | ||
1243 | 1240 | ||
1244 | if v_Debugs then | 1241 | if v_Debugs then |
1245 | Begin | 1242 | Begin |
1246 | - Log_Debug('te_so => '+v_te_so); | 1243 | + Log_Debug('te_so => '+g_te_so); |
1247 | Log_Debug('Valores de REQUEST para envio ao Gerente WEB:'); | 1244 | Log_Debug('Valores de REQUEST para envio ao Gerente WEB:'); |
1248 | for intAux := 0 to v_AuxRequest.count -1 do | 1245 | for intAux := 0 to v_AuxRequest.count -1 do |
1249 | Log_Debug('#'+inttostr(intAux)+': '+v_AuxRequest[intAux]); | 1246 | Log_Debug('#'+inttostr(intAux)+': '+v_AuxRequest[intAux]); |
@@ -1267,9 +1264,11 @@ Begin | @@ -1267,9 +1264,11 @@ Begin | ||
1267 | log_diario('Endereço: ' + strEndereco); | 1264 | log_diario('Endereço: ' + strEndereco); |
1268 | log_diario('Mensagem: ' + Response_CS.DataString); | 1265 | log_diario('Mensagem: ' + Response_CS.DataString); |
1269 | result := '0'; | 1266 | result := '0'; |
1267 | + setValorDatMemoria('Configs.ConexaoOK','N',v_tstrCipherOpened); | ||
1270 | end | 1268 | end |
1271 | Else | 1269 | Else |
1272 | Begin | 1270 | Begin |
1271 | + setValorDatMemoria('Configs.ConexaoOK','S',v_tstrCipherOpened); | ||
1273 | result := Response_CS.DataString; | 1272 | result := Response_CS.DataString; |
1274 | end; | 1273 | end; |
1275 | Response_CS.Free; | 1274 | Response_CS.Free; |
@@ -2081,9 +2080,12 @@ Begin | @@ -2081,9 +2080,12 @@ Begin | ||
2081 | Ver_UPD(StringReplace(v_scripter,'.exe','',[rfReplaceAll]),'Interpretador VBS' ,p_path_cacic + 'modulos\','',false); | 2080 | Ver_UPD(StringReplace(v_scripter,'.exe','',[rfReplaceAll]),'Interpretador VBS' ,p_path_cacic + 'modulos\','',false); |
2082 | Ver_UPD('chksis' ,'Verificador de Integridade do Sistema',PegaWinDir(nil)+'\' ,'',false); | 2081 | Ver_UPD('chksis' ,'Verificador de Integridade do Sistema',PegaWinDir(nil)+'\' ,'',false); |
2083 | 2082 | ||
2083 | + // O módulo de Suporte Remoto é opcional, através da opção Administração / Módulos | ||
2084 | + { | ||
2084 | log_diario('Verificando nova versão para módulo Suporte Remoto Seguro.'); | 2085 | log_diario('Verificando nova versão para módulo Suporte Remoto Seguro.'); |
2085 | // Caso encontre nova versão de srCACICsrv esta será gravada em modulos. | 2086 | // Caso encontre nova versão de srCACICsrv esta será gravada em modulos. |
2086 | Ver_UPD('srcacicsrv','Suporte Remoto Seguro',p_path_cacic + 'modulos\','',false); | 2087 | Ver_UPD('srcacicsrv','Suporte Remoto Seguro',p_path_cacic + 'modulos\','',false); |
2088 | + } | ||
2087 | 2089 | ||
2088 | // Verifico existência do chksis.ini | 2090 | // Verifico existência do chksis.ini |
2089 | if not (FileExists(PegaWinDir(nil) + 'chksis.ini')) then | 2091 | if not (FileExists(PegaWinDir(nil) + 'chksis.ini')) then |
@@ -2423,6 +2425,25 @@ Begin | @@ -2423,6 +2425,25 @@ Begin | ||
2423 | strAux := GeraPalavraChave; | 2425 | strAux := GeraPalavraChave; |
2424 | 2426 | ||
2425 | SetValorDatMemoria('Configs.te_palavra_chave',strAux, v_tstrCipherOpened); | 2427 | SetValorDatMemoria('Configs.te_palavra_chave',strAux, v_tstrCipherOpened); |
2428 | + | ||
2429 | + // Verifico se srCACIC está em execução e em caso positivo entrego a chave atualizada | ||
2430 | + Matar(p_path_cacic+'Temp\','aguarde_SRCACIC.txt'); | ||
2431 | + sleep(2000); | ||
2432 | + if (FileExists(p_path_cacic + 'Temp\aguarde_SRCACIC.txt')) then | ||
2433 | + Begin | ||
2434 | + // Alguns cuidados necessários ao tráfego e recepção de valores pelo Gerente WEB | ||
2435 | + // Some cares about send and receive at Gerente WEB | ||
2436 | + v_Aux := StringReplace(strAux ,' ' ,'<ESPACE>' ,[rfReplaceAll]); | ||
2437 | + v_Aux := StringReplace(v_Aux ,'"' ,'<AD>' ,[rfReplaceAll]); | ||
2438 | + v_Aux := StringReplace(v_Aux ,'''','<AS>' ,[rfReplaceAll]); | ||
2439 | + v_Aux := StringReplace(v_Aux ,'\' ,'<BarrInv>' ,[rfReplaceAll]); | ||
2440 | + v_Aux := StringReplace(EnCrypt(v_Aux,l_cs_compress) ,'+' ,'<MAIS>' ,[rfReplaceAll]); | ||
2441 | + | ||
2442 | + log_DEBUG('Invocando "'+p_path_cacic + 'modulos\srcacicsrv.exe -update [' + v_Aux + ']' ); | ||
2443 | + WinExec(PChar(p_path_cacic + 'modulos\srcacicsrv.exe -update [' + v_Aux + ']'),SW_NORMAL); | ||
2444 | + End; | ||
2445 | + | ||
2446 | + | ||
2426 | Request_SVG.Values['te_palavra_chave'] := EnCrypt(strAux,l_cs_compress); | 2447 | Request_SVG.Values['te_palavra_chave'] := EnCrypt(strAux,l_cs_compress); |
2427 | v_te_serv_cacic := GetValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened); | 2448 | v_te_serv_cacic := GetValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened); |
2428 | 2449 | ||
@@ -2512,6 +2533,7 @@ Begin | @@ -2512,6 +2533,7 @@ Begin | ||
2512 | SetValorDatMemoria('Configs.CS_COLETA_COMPARTILHAMENTOS' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_compart' , strRetorno),true)), v_tstrCipherOpened); | 2533 | SetValorDatMemoria('Configs.CS_COLETA_COMPARTILHAMENTOS' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_compart' , strRetorno),true)), v_tstrCipherOpened); |
2513 | SetValorDatMemoria('Configs.CS_COLETA_UNID_DISC' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_unid_disc' , strRetorno),true)), v_tstrCipherOpened); | 2534 | SetValorDatMemoria('Configs.CS_COLETA_UNID_DISC' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_unid_disc' , strRetorno),true)), v_tstrCipherOpened); |
2514 | SetValorDatMemoria('Configs.CS_COLETA_PATRIMONIO' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_patrimonio' , strRetorno),true)), v_tstrCipherOpened); | 2535 | SetValorDatMemoria('Configs.CS_COLETA_PATRIMONIO' ,UpperCase(DeCrypt(XML_RetornaValor('cs_coleta_patrimonio' , strRetorno),true)), v_tstrCipherOpened); |
2536 | + SetValorDatMemoria('Configs.CS_SUPORTE_REMOTO' ,UpperCase(DeCrypt(XML_RetornaValor('cs_suporte_remoto' , strRetorno),true)), v_tstrCipherOpened); | ||
2515 | SetValorDatMemoria('Configs.DT_VERSAO_CACIC2_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_cacic2_disponivel' , strRetorno),true) , v_tstrCipherOpened); | 2537 | SetValorDatMemoria('Configs.DT_VERSAO_CACIC2_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_cacic2_disponivel' , strRetorno),true) , v_tstrCipherOpened); |
2516 | SetValorDatMemoria('Configs.TE_HASH_CACIC2' ,DeCrypt(XML_RetornaValor('te_hash_cacic2' , strRetorno),true) , v_tstrCipherOpened); | 2538 | SetValorDatMemoria('Configs.TE_HASH_CACIC2' ,DeCrypt(XML_RetornaValor('te_hash_cacic2' , strRetorno),true) , v_tstrCipherOpened); |
2517 | SetValorDatMemoria('Configs.DT_VERSAO_GER_COLS_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_ger_cols_disponivel' , strRetorno),true) , v_tstrCipherOpened); | 2539 | SetValorDatMemoria('Configs.DT_VERSAO_GER_COLS_DISPONIVEL' ,DeCrypt(XML_RetornaValor('dt_versao_ger_cols_disponivel' , strRetorno),true) , v_tstrCipherOpened); |
@@ -2746,9 +2768,13 @@ Begin | @@ -2746,9 +2768,13 @@ Begin | ||
2746 | // Caso encontre nova versão de Ger_Cols esta será gravada em temp e ocorrerá o autoupdate. | 2768 | // Caso encontre nova versão de Ger_Cols esta será gravada em temp e ocorrerá o autoupdate. |
2747 | Ver_UPD('ger_cols','Gerente de Coletas',p_path_cacic + 'modulos\','Temp',false); | 2769 | Ver_UPD('ger_cols','Gerente de Coletas',p_path_cacic + 'modulos\','Temp',false); |
2748 | 2770 | ||
2749 | - log_diario('Verificando nova versão para módulo Suporte Remoto Seguro.'); | ||
2750 | - // Caso encontre nova versão de srCACICsrv esta será gravada em modulos. | ||
2751 | - Ver_UPD('srcacicsrv','Suporte Remoto Seguro',p_path_cacic + 'modulos\','Modulos',false); | 2771 | + // O módulo de Suporte Remoto é opcional... |
2772 | + if (GetValorDatMemoria('Configs.CS_SUPORTE_REMOTO' , v_tstrCipherOpened) = 'S') then | ||
2773 | + Begin | ||
2774 | + log_diario('Verificando nova versão para módulo Suporte Remoto Seguro.'); | ||
2775 | + // Caso encontre nova versão de srCACICsrv esta será gravada em modulos. | ||
2776 | + Ver_UPD('srcacicsrv','Suporte Remoto Seguro',p_path_cacic + 'modulos\','Modulos',false); | ||
2777 | + End; | ||
2752 | 2778 | ||
2753 | if (FileExists(p_path_cacic + 'Temp\ger_cols.exe')) or | 2779 | if (FileExists(p_path_cacic + 'Temp\ger_cols.exe')) or |
2754 | (FileExists(p_path_cacic + 'Temp\cacic2.exe')) then | 2780 | (FileExists(p_path_cacic + 'Temp\cacic2.exe')) then |
@@ -3359,7 +3385,7 @@ Begin | @@ -3359,7 +3385,7 @@ Begin | ||
3359 | else begin | 3385 | else begin |
3360 | // Atualiza a data de última coleta | 3386 | // Atualiza a data de última coleta |
3361 | SetValorDatMemoria('Configs.DT_HR_ULTIMA_COLETA',FormatDateTime('YYYYmmddHHnnss', Now), v_tstrCipherOpened); | 3387 | SetValorDatMemoria('Configs.DT_HR_ULTIMA_COLETA',FormatDateTime('YYYYmmddHHnnss', Now), v_tstrCipherOpened); |
3362 | - log_diario('Todos os dados coletados foram enviados ao Gerente WEB.'); | 3388 | + log_diario('Os dados coletados - e não redundantes - foram enviados ao Gerente WEB.'); |
3363 | end; | 3389 | end; |
3364 | end; | 3390 | end; |
3365 | Except | 3391 | Except |
@@ -3387,11 +3413,6 @@ begin | @@ -3387,11 +3413,6 @@ begin | ||
3387 | For intAux := 0 to tstrTripa1.Count -2 do | 3413 | For intAux := 0 to tstrTripa1.Count -2 do |
3388 | p_path_cacic := p_path_cacic + tstrTripa1[intAux] + '\'; | 3414 | p_path_cacic := p_path_cacic + tstrTripa1[intAux] + '\'; |
3389 | 3415 | ||
3390 | - g_oCacic.setCacicPath(p_path_cacic); | ||
3391 | - | ||
3392 | - // Obtem a string de identificação do SO (v_te_so), para uso nas comunicações com o Gerente WEB. | ||
3393 | - v_te_so := g_oCacic.getWindowsStrId(); | ||
3394 | - | ||
3395 | v_Debugs := false; | 3416 | v_Debugs := false; |
3396 | if DirectoryExists(p_path_cacic + 'Temp\Debugs') then | 3417 | if DirectoryExists(p_path_cacic + 'Temp\Debugs') then |
3397 | if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then | 3418 | if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then |
@@ -3400,6 +3421,8 @@ begin | @@ -3400,6 +3421,8 @@ begin | ||
3400 | log_DEBUG('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); | 3421 | log_DEBUG('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); |
3401 | End; | 3422 | End; |
3402 | 3423 | ||
3424 | + g_oCacic.setCacicPath(p_path_cacic); | ||
3425 | + | ||
3403 | For intAux := 1 to ParamCount do | 3426 | For intAux := 1 to ParamCount do |
3404 | if LowerCase(Copy(ParamStr(intAux),1,13)) = '/p_cipherkey=' then | 3427 | if LowerCase(Copy(ParamStr(intAux),1,13)) = '/p_cipherkey=' then |
3405 | Begin | 3428 | Begin |
@@ -3429,8 +3452,13 @@ begin | @@ -3429,8 +3452,13 @@ begin | ||
3429 | v_tstrCipherOpened := TStrings.Create; | 3452 | v_tstrCipherOpened := TStrings.Create; |
3430 | v_tstrCipherOpened := CipherOpen(v_DatFileName); | 3453 | v_tstrCipherOpened := CipherOpen(v_DatFileName); |
3431 | 3454 | ||
3455 | + // Obtem a string de identificação do SO (g_te_so), para uso nas comunicações com o Gerente WEB. | ||
3456 | + g_te_so := g_oCacic.getWindowsStrId(); | ||
3457 | + | ||
3432 | // Não tirar desta posição | 3458 | // Não tirar desta posição |
3433 | - SetValorDatMemoria('Configs.ID_SO',g_oCacic.getWindowsStrId(), v_tstrCipherOpened); | 3459 | + SetValorDatMemoria('Configs.ID_SO',g_te_so, v_tstrCipherOpened); |
3460 | + | ||
3461 | + log_DEBUG('Te_So obtido: "' + g_te_so +'"'); | ||
3434 | 3462 | ||
3435 | v_scripter := 'wscript.exe'; | 3463 | v_scripter := 'wscript.exe'; |
3436 | // A existência e bloqueio do arquivo abaixo evitará que Cacic2.exe chame o Ger_Cols quando este estiver em funcionamento | 3464 | // A existência e bloqueio do arquivo abaixo evitará que Cacic2.exe chame o Ger_Cols quando este estiver em funcionamento |
ger_cols/ger_cols.res
No preview for this file type
ini_cols/ini_cols.res
No preview for this file type
main.dfm
1 | object FormularioGeral: TFormularioGeral | 1 | object FormularioGeral: TFormularioGeral |
2 | - Left = 300 | ||
3 | - Top = 107 | 2 | + Left = 301 |
3 | + Top = 108 | ||
4 | HorzScrollBar.Visible = False | 4 | HorzScrollBar.Visible = False |
5 | VertScrollBar.Visible = False | 5 | VertScrollBar.Visible = False |
6 | BiDiMode = bdLeftToRight | 6 | BiDiMode = bdLeftToRight |
@@ -143,10 +143,10 @@ object FormularioGeral: TFormularioGeral | @@ -143,10 +143,10 @@ object FormularioGeral: TFormularioGeral | ||
143 | TextHeight = 13 | 143 | TextHeight = 13 |
144 | object Panel3: TPanel | 144 | object Panel3: TPanel |
145 | Left = 648 | 145 | Left = 648 |
146 | - Top = 3 | 146 | + Top = -1 |
147 | Width = 68 | 147 | Width = 68 |
148 | - Height = 593 | ||
149 | - Color = clCaptionText | 148 | + Height = 597 |
149 | + Color = clGray | ||
150 | TabOrder = 3 | 150 | TabOrder = 3 |
151 | object pnVersao: TPanel | 151 | object pnVersao: TPanel |
152 | Left = 6 | 152 | Left = 6 |
@@ -168,8 +168,8 @@ object FormularioGeral: TFormularioGeral | @@ -168,8 +168,8 @@ object FormularioGeral: TFormularioGeral | ||
168 | object bt_Fechar_Infos_Gerais: TBitBtn | 168 | object bt_Fechar_Infos_Gerais: TBitBtn |
169 | Left = 6 | 169 | Left = 6 |
170 | Top = 252 | 170 | Top = 252 |
171 | - Width = 60 | ||
172 | - Height = 27 | 171 | + Width = 61 |
172 | + Height = 33 | ||
173 | Caption = 'Fechar' | 173 | Caption = 'Fechar' |
174 | Font.Charset = DEFAULT_CHARSET | 174 | Font.Charset = DEFAULT_CHARSET |
175 | Font.Color = clWindowText | 175 | Font.Color = clWindowText |
@@ -1339,9 +1339,9 @@ object FormularioGeral: TFormularioGeral | @@ -1339,9 +1339,9 @@ object FormularioGeral: TFormularioGeral | ||
1339 | end | 1339 | end |
1340 | object Panel1: TPanel | 1340 | object Panel1: TPanel |
1341 | Left = 645 | 1341 | Left = 645 |
1342 | - Top = 2 | 1342 | + Top = 0 |
1343 | Width = 5 | 1343 | Width = 5 |
1344 | - Height = 591 | 1344 | + Height = 597 |
1345 | Color = clGreen | 1345 | Color = clGreen |
1346 | TabOrder = 1 | 1346 | TabOrder = 1 |
1347 | end | 1347 | end |
@@ -1367,11 +1367,11 @@ object FormularioGeral: TFormularioGeral | @@ -1367,11 +1367,11 @@ object FormularioGeral: TFormularioGeral | ||
1367 | Left = 674 | 1367 | Left = 674 |
1368 | Top = 2 | 1368 | Top = 2 |
1369 | end | 1369 | end |
1370 | - object PopupMenu1: TPopupMenu | 1370 | + object Popup_Menu_Contexto: TPopupMenu |
1371 | MenuAnimation = [maLeftToRight, maRightToLeft, maTopToBottom, maBottomToTop] | 1371 | MenuAnimation = [maLeftToRight, maRightToLeft, maTopToBottom, maBottomToTop] |
1372 | - OnPopup = PopupMenu1Popup | 1372 | + OnPopup = Popup_Menu_ContextoPopup |
1373 | Left = 674 | 1373 | Left = 674 |
1374 | - Top = 58 | 1374 | + Top = 86 |
1375 | object Mnu_LogAtividades: TMenuItem | 1375 | object Mnu_LogAtividades: TMenuItem |
1376 | Caption = 'Log de Atividades' | 1376 | Caption = 'Log de Atividades' |
1377 | OnClick = ExibirLogAtividades | 1377 | OnClick = ExibirLogAtividades |
@@ -1401,4 +1401,154 @@ object FormularioGeral: TFormularioGeral | @@ -1401,4 +1401,154 @@ object FormularioGeral: TFormularioGeral | ||
1401 | OnClick = Sair | 1401 | OnClick = Sair |
1402 | end | 1402 | end |
1403 | end | 1403 | end |
1404 | + object Timer_InicializaTray: TTimer | ||
1405 | + Interval = 60000 | ||
1406 | + OnTimer = Timer_InicializaTrayTimer | ||
1407 | + Left = 674 | ||
1408 | + Top = 58 | ||
1409 | + end | ||
1410 | + object imgList_Icones: TImageList | ||
1411 | + ShareImages = True | ||
1412 | + Left = 674 | ||
1413 | + Top = 114 | ||
1414 | + Bitmap = { | ||
1415 | + 494C010103000400040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 | ||
1416 | + 0000000000003600000028000000400000001000000001002000000000000010 | ||
1417 | + 00000000000000000000000000000000000000000000021C7800000000000000 | ||
1418 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1419 | + 0000000000000000000000125B000000000000000000C0C4D7FF000000000000 | ||
1420 | + 00001E1E1EFF0000000000000000000000000000000000000000000000000000 | ||
1421 | + 00000000000000000000F0F1F5FF0000000000000000C0C4D7FF000000000000 | ||
1422 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1423 | + 00000000000000000000F0F1F5FF000000000000000000000000000000000000 | ||
1424 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1425 | + 000000000000000000000000000000000000000000000032FD00000000000000 | ||
1426 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1427 | + 000000000000000000000032FD0000000000404B7BFF0032FDFF000000000000 | ||
1428 | + 00001E1E1EFFB9B9B9FF00000000000000000000000000000000000000000000 | ||
1429 | + 000000000000405EDCFF002BDCFF00000000404B7BFF0032FDFF000000000000 | ||
1430 | + 00000000000000000000000000001E1E1EFF1E1E1EFF1E1E1EFF000000000000 | ||
1431 | + 000000000000405EDCFF002BDCFF000000000000000000000000000000000000 | ||
1432 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1433 | + 000000000000000000000000000000000000305159000032FD00163886000000 | ||
1434 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1435 | + 000000000000163886000032FD001E333A000C32A8FF0131F6FFC0C7E3FF0000 | ||
1436 | + 00001E1E1EFF1E1E1EFFC0C0C0FF000000000000000000000000000000000000 | ||
1437 | + 000000000000032FDBFF002EF0FFC0C3CCFF0C32A8FF0131F6FFC0C7E3FF0000 | ||
1438 | + 000000000000000000001E1E1EFF0000FFFF0000FFFF1E1E1EFF000000000000 | ||
1439 | + 000000000000032FDBFF002EF0FFC0C3CCFF0000000000000000000000000000 | ||
1440 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1441 | + 00000000000000000000000000000000000083DADC009DFFFE0083DADC000000 | ||
1442 | + 00000000000025375E005078C900679AFE00679AFE004B71BB00000000000000 | ||
1443 | + 00000000000092F3F3009DFFFE005F9DA00098F8F7FF6AB1B3FFB8D3D3FF0000 | ||
1444 | + 00001E1E1EFF62F6FFFF1E1E1EFF2E4065FFAFBFDEFFD0D7E8FF000000000000 | ||
1445 | + 000000000000A6FCFCFF88E3E3FFD7E9EAFF98F8F7FF6AB1B3FFB8D3D3FF0000 | ||
1446 | + 000000000000CCD2DDFF1E1E1EFF0000FFFF0000FFFF1E1E1EFF000000000000 | ||
1447 | + 000000000000A6FCFCFF88E3E3FFD7E9EAFF0000000000000000000000000000 | ||
1448 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1449 | + 0000000000000000000000000000000000001126080098FDFC0030554500354F | ||
1450 | + 85006DA2FF00679AFE00679AFE0039558E004262A400679AFE00679AFE006DA2 | ||
1451 | + FF0000000000345951008FEEEB0011211100487E6AFF9BFEFDFFA8B9B8FFD2DB | ||
1452 | + EEFF1E1E1EFF4AE9F4FF5EEDFFFF1E1E1EFF5074B9FF679AFEFF6BA0FFFF3B59 | ||
1453 | + 95FF000000008FE6E7FF8AE5E4FFC4C9C6FF487E6AFF9BFEFDFFA8B9B8FFD2DB | ||
1454 | + EEFF689CFAFF679AFEFF6394F3FF2F4673FF334C7DFF679AFEFF6BA0FFFF3B59 | ||
1455 | + 95FF000000008FE6E7FF8AE5E4FFC4C9C6FF0000000000000000000000000000 | ||
1456 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1457 | + 0000000000000000000000000000000000000000000070E136001D2C49002EB8 | ||
1458 | + E700679AFE00679AFE002A3F6900679AFE00679AFE002F477700679AFE00679A | ||
1459 | + FE002EB8E7001E333A0070E1360000000000587251FF51A42AFF41639EFF5097 | ||
1460 | + E8FF1E1E1EFF45E8F2FF5EEAFFFF5FEEFFFF1E1E1EFF4F72B0FF679AFEFF6498 | ||
1461 | + FAFF4B93DFFF468F25FF61C330FF00000000587251FF51A42AFF41639EFF5097 | ||
1462 | + E8FF679AFEFF679AFEFF1E1E1EFF0000FFFF0000FFFF1E1E1EFF679AFEFF6498 | ||
1463 | + FAFF4B93DFFF468F25FF61C330FF000000000000000000000000000000000000 | ||
1464 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1465 | + 000000000000000000000000000000000000000000004262A400679AFE0030C0 | ||
1466 | + F00030C0F0006494F800679AFE00679AFE00679AFE00679AFE005F91F0002EB8 | ||
1467 | + E70030C8F9006DA2FF004B71BB0000000000D2D2D4FF2F5B1EFF3FA2E2FF3F99 | ||
1468 | + D9FF42A0E3FF1E1E1EFF5EEAFFFF5EEAFFFF61F2FFFF1E1E1EFF4E72B8FF33B5 | ||
1469 | + E9FF33B9EDFF36577FFFA3AEB5FF00000000D2D2D4FF2F5B1EFF3FA2E2FF3F99 | ||
1470 | + D9FF42A0E3FF679AFEFF1E1E1EFF0000FFFF0000FFFF1E1E1EFF5F95F3FF33B5 | ||
1471 | + E9FF33B9EDFF36577FFFA3AEB5FF000000000000000000000000000000000000 | ||
1472 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1473 | + 000000000000000000000000000000000000679AFE00679AFE00679AFE00679A | ||
1474 | + FE005F91F000679AFE00679AFE00679AFE00679AFE00679AFE00679AFE005690 | ||
1475 | + E600679AFE00679AFE00679AFE005A88E2006090EEFF679AFEFF679AFEFF40A1 | ||
1476 | + E1FF5C93EFFF1E1E1EFF5FEDFFFF5EEAFFFF5EEAFFFF60F1FFFF1E1E1EFF2C8D | ||
1477 | + B1FF6498FAFF679AFEFF679AFEFFCBD0DAFF6090EEFF679AFEFF679AFEFF40A1 | ||
1478 | + E1FF5C93EFFF679AFEFF1E1E1EFF0000FFFF0000FFFF1E1E1EFF679AFEFF38B0 | ||
1479 | + EAFF6498FAFF679AFEFF679AFEFFCBD0DAFF0000000000000000000000000000 | ||
1480 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1481 | + 0000000000000000000000000000000000004262A400679AFE00679AFE00679A | ||
1482 | + FE005A88E2005078C9004262A400679AFE00679AFE005781D9004B71BB005781 | ||
1483 | + D900679AFE00679AFE00679AFE004669B0006597F9FF679AFEFF679AFEFF1E1E | ||
1484 | + 1EFF55EBFFFF55EAFFFF5EEAFFFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E | ||
1485 | + 1EFF5F8DE7FF679AFEFF679AFEFF526385FF6597F9FF679AFEFF679AFEFF679A | ||
1486 | + FEFF6394F6FF6090EFFF1E1E1EFF0000FFFF0000FFFF0000FFFF1E1E1EFF6395 | ||
1487 | + F7FF679AFEFF679AFEFF679AFEFF526385FF0000000000000000000000000000 | ||
1488 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1489 | + 000000000000000000000000000000000000000000003D5C99005E8DE900679A | ||
1490 | + FE00679AFE00679AFE00679AFE00679AFE00679AFE00679AFE00679AFE00679A | ||
1491 | + FE00679AFE005A88E20025375E000000000004070BFF6190F0FF6698FCFF1E1E | ||
1492 | + 1EFF4FE9F5FF5EEAFFFF5EEAFFFF5FEEFFFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E | ||
1493 | + 1EFF1E1E1EFF6496F7FF263A5EFFD0D0D0FF04070BFF6190F0FF6698FCFF679A | ||
1494 | + FEFF6BA0FFFF679AFEFF679AFEFF2F4F90FF0000FFFF0000FFFF0000FFFF1E1E | ||
1495 | + 1EFF6699FDFF6496F7FF263A5EFFD0D0D0FF0000000000000000000000000000 | ||
1496 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1497 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1498 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1499 | + 000000000000000000000000000000000000404040FF000000FF000000FF0203 | ||
1500 | + 03FF034F5EFF5EEBFFFF5EEAFFFF5EEAFFFF23E2F8FF1F2228FF0F1626FF0206 | ||
1501 | + 0CFF000000FF000000FF000000FF00000000404040FF000000FF000000FF0203 | ||
1502 | + 03FF0000FFFF0000FFFF1E1E1EFF476BB2FF2A3F6AFF0000FFFF0000FFFF1E1E | ||
1503 | + 1EFF000000FF000000FF000000FF000000000000000000000000000000000000 | ||
1504 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1505 | + 0000000000000000000000000000000000000000000000092E00000724000007 | ||
1506 | + 2400000724000007240000072400000724000007240000072400000724000007 | ||
1507 | + 2400000724000007240000092E000000000000000000000109FF000109FF0001 | ||
1508 | + 09FF1E1E1EFF5AEFFDFF5EEAFFFF5EEAFFFF5EEAFFFF149DADFF0D0D0EFF0001 | ||
1509 | + 09FF000109FF000109FF000105FF0000000000000000000109FF000109FF0001 | ||
1510 | + 09FF0000FFFF0000FFFF1E1E1EFF1E1E1EFF000109FF1E1E1EFF0000FFFF1E1E | ||
1511 | + 1EFF000109FF000109FF000105FF000000000000000000000000000000000000 | ||
1512 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1513 | + 00000000000000000000000000000000000000000000000000004DBCB1004DBC | ||
1514 | + B1004DBCB1004DBCB1004DBCB1004DBCB1004DBCB1004DBCB1004DBCB1004DBC | ||
1515 | + B1004DBCB1004DBCB1000000000000000000000000001B3C7DFF144486FF1444 | ||
1516 | + 86FF1E1E1EFF0AA2B7FF5EEAFFFF5EEAFFFF5EEAFFFF5EEAFFFF10353AFF1E1E | ||
1517 | + 1EFF144486FF134081FFD0D2E0FF00000000000000001B3C7DFF144486FF1444 | ||
1518 | + 86FF0000FFFF0000FFFF0000FFFF1E1E1EFF1E1E1EFF0000FFFF0000FFFF1E1E | ||
1519 | + 1EFF1E1E1EFF134081FFD0D2E0FF000000000000000000000000000000000000 | ||
1520 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1521 | + 0000000000000000000000000000000000000000000000000000296355002757 | ||
1522 | + BC006DC1830027636C00325B7F0034662900113562003C6C960060B150001247 | ||
1523 | + A1005693AB0000000000000000000000000000000000000000005E8A57FF061C | ||
1524 | + 62FF355B54FF1D311FFF5DEEFFFF5EEAFFFF5EEAFFFF5EEAFFFF2AC4D5FF1D1F | ||
1525 | + 1CFF0B165DFFE9FAF5FF000000000000000000000000000000005E8A57FF061C | ||
1526 | + 62FF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF1E1E | ||
1527 | + 1EFF1E1E1EFFE9FAF5FF00000000000000000000000000000000000000000000 | ||
1528 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1529 | + 00000000000000000000000000000000000000000000000000001854B8006ABD | ||
1530 | + FE006ECE4F000B3AB70073C1D4005AB32B000333EE0089E9FF006BD335000026 | ||
1531 | + C10077C7CB004E9F2A00000000000000000000000000D0D7F5FF54AE4DFF1946 | ||
1532 | + E0FF88ECB6FF418E54FF54F0FFFF5EEAFFFF5EEAFFFF5EEAFFFF5EEAFFFF1768 | ||
1533 | + 74FF1E1E1EFF78D39AFF000000000000000000000000D0D7F5FF54AE4DFF1946 | ||
1534 | + E0FF5FA87CFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E | ||
1535 | + 1EFF1E1E1EFF78D39AFF00000000000000000000000000000000000000000000 | ||
1536 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1537 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1538 | + 000075CD91003B855B000000000000000000000000000000000063B55900205C | ||
1539 | + 8E000000000000000000000000000000000000000000000000006BC061FF1E4A | ||
1540 | + CFFF77CBC0FF639D64FF1E1E1EFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E | ||
1541 | + 1EFF555555FF1E1E1EFF000000000000000000000000000000006BC061FF1E4A | ||
1542 | + CFFF77CBC0FF639D64FF1E1E1EFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E1EFF1E1E | ||
1543 | + 1EFF557FEFFF88E1B9FF00000000000000000000000000000000000000000000 | ||
1544 | + 0000000000000000000000000000000000000000000000000000000000000000 | ||
1545 | + 000000000000000000000000000000000000424D3E000000000000003E000000 | ||
1546 | + 2800000040000000100000000100010000000000800000000000000000000000 | ||
1547 | + 000000000000000000000000FFFFFF00BFFDB7FDBFFD0000BFFD33F93E390000 | ||
1548 | + 1FF811F81C380000183810381838000000080008000800008001000100010000 | ||
1549 | + 8001000100010000000000000000000000000000000000000001000000000000 | ||
1550 | + 80010001000100008001800180010000C003800180010000C007C003C0030000 | ||
1551 | + C003800380030000F3CFC003C003000000000000000000000000000000000000 | ||
1552 | + 000000000000} | ||
1553 | + end | ||
1404 | end | 1554 | end |
main.pas
@@ -37,8 +37,11 @@ uses Windows, | @@ -37,8 +37,11 @@ uses Windows, | ||
37 | DCPbase64, | 37 | DCPbase64, |
38 | ComCtrls, | 38 | ComCtrls, |
39 | IdBaseComponent, | 39 | IdBaseComponent, |
40 | - IdComponent, Buttons, | ||
41 | - CACIC_Library; | 40 | + IdComponent, |
41 | + Buttons, | ||
42 | + CACIC_Library, | ||
43 | + ImgList, | ||
44 | + Graphics; | ||
42 | //IdTCPServer; | 45 | //IdTCPServer; |
43 | //IdFTPServer; | 46 | //IdFTPServer; |
44 | 47 | ||
@@ -49,16 +52,16 @@ var p_path_cacic, | @@ -49,16 +52,16 @@ var p_path_cacic, | ||
49 | p_path_cacic_ini, | 52 | p_path_cacic_ini, |
50 | p_Shell_Command, | 53 | p_Shell_Command, |
51 | p_Shell_Path, | 54 | p_Shell_Path, |
52 | - v_versao : string; | ||
53 | - BatchFile : TStringList; | 55 | + v_versao, |
56 | + g_te_so, | ||
54 | v_CipherKey, | 57 | v_CipherKey, |
55 | v_SeparatorKey, | 58 | v_SeparatorKey, |
56 | v_IV, | 59 | v_IV, |
57 | v_DatFileName, | 60 | v_DatFileName, |
58 | v_DataCacic2DAT, | 61 | v_DataCacic2DAT, |
59 | v_Tamanho_Arquivo, | 62 | v_Tamanho_Arquivo, |
60 | - v_te_so, | ||
61 | strConfigsPatrimonio : string; | 63 | strConfigsPatrimonio : string; |
64 | + BatchFile : TStringList; | ||
62 | v_tstrCipherOpened : TStrings; | 65 | v_tstrCipherOpened : TStrings; |
63 | boolCrypt, | 66 | boolCrypt, |
64 | boolDebugs : Boolean; | 67 | boolDebugs : Boolean; |
@@ -106,7 +109,7 @@ type | @@ -106,7 +109,7 @@ type | ||
106 | Pn_Linha5_TCPIP: TPanel; | 109 | Pn_Linha5_TCPIP: TPanel; |
107 | Timer_Nu_Intervalo: TTimer; | 110 | Timer_Nu_Intervalo: TTimer; |
108 | Timer_Nu_Exec_Apos: TTimer; | 111 | Timer_Nu_Exec_Apos: TTimer; |
109 | - PopupMenu1: TPopupMenu; | 112 | + Popup_Menu_Contexto: TPopupMenu; |
110 | Mnu_LogAtividades: TMenuItem; | 113 | Mnu_LogAtividades: TMenuItem; |
111 | Mnu_Configuracoes: TMenuItem; | 114 | Mnu_Configuracoes: TMenuItem; |
112 | Mnu_ExecutarAgora: TMenuItem; | 115 | Mnu_ExecutarAgora: TMenuItem; |
@@ -161,6 +164,8 @@ type | @@ -161,6 +164,8 @@ type | ||
161 | Panel3: TPanel; | 164 | Panel3: TPanel; |
162 | pnVersao: TPanel; | 165 | pnVersao: TPanel; |
163 | bt_Fechar_Infos_Gerais: TBitBtn; | 166 | bt_Fechar_Infos_Gerais: TBitBtn; |
167 | + Timer_InicializaTray: TTimer; | ||
168 | + imgList_Icones: TImageList; | ||
164 | procedure RemoveIconesMortos; | 169 | procedure RemoveIconesMortos; |
165 | procedure ChecaCONFIGS; | 170 | procedure ChecaCONFIGS; |
166 | procedure CriaFormSenha(Sender: TObject); | 171 | procedure CriaFormSenha(Sender: TObject); |
@@ -178,6 +183,7 @@ type | @@ -178,6 +183,7 @@ type | ||
178 | procedure Mnu_InfosPatrimoniaisClick(Sender: TObject); | 183 | procedure Mnu_InfosPatrimoniaisClick(Sender: TObject); |
179 | procedure HabilitaTCP; | 184 | procedure HabilitaTCP; |
180 | procedure HabilitaPatrimonio; | 185 | procedure HabilitaPatrimonio; |
186 | + procedure HabilitaSuporteRemoto; | ||
181 | procedure Matar(v_dir,v_files: string); | 187 | procedure Matar(v_dir,v_files: string); |
182 | Procedure DelValorReg(Chave: String); | 188 | Procedure DelValorReg(Chave: String); |
183 | 189 | ||
@@ -198,13 +204,13 @@ type | @@ -198,13 +204,13 @@ type | ||
198 | const AUsername, APassword: String; var AAuthenticated: Boolean); | 204 | const AUsername, APassword: String; var AAuthenticated: Boolean); |
199 | } | 205 | } |
200 | procedure Mnu_SuporteRemotoClick(Sender: TObject); | 206 | procedure Mnu_SuporteRemotoClick(Sender: TObject); |
201 | -// procedure StartVNCServer; | ||
202 | - procedure PopupMenu1Popup(Sender: TObject); | 207 | + procedure Popup_Menu_ContextoPopup(Sender: TObject); |
208 | + procedure Timer_InicializaTrayTimer(Sender: TObject); | ||
203 | private | 209 | private |
204 | ShutdownEmExecucao : Boolean; | 210 | ShutdownEmExecucao : Boolean; |
205 | IsMenuOpen : Boolean; | 211 | IsMenuOpen : Boolean; |
206 | NotifyStruc : TNotifyIconData; {Estrutura do tray icon} | 212 | NotifyStruc : TNotifyIconData; {Estrutura do tray icon} |
207 | - procedure InicializaTray(v_Hint:string); | 213 | + procedure InicializaTray; |
208 | procedure Finaliza; | 214 | procedure Finaliza; |
209 | procedure VerificaDebugs; | 215 | procedure VerificaDebugs; |
210 | procedure MontaVetoresPatrimonio(p_strConfigs : String); | 216 | procedure MontaVetoresPatrimonio(p_strConfigs : String); |
@@ -220,7 +226,6 @@ type | @@ -220,7 +226,6 @@ type | ||
220 | // Shutdown do Windows e "derrubar" o Cacic. | 226 | // Shutdown do Windows e "derrubar" o Cacic. |
221 | procedure WMQueryEndSession(var Msg : TWMQueryEndSession); Message WM_QUERYENDSESSION; | 227 | procedure WMQueryEndSession(var Msg : TWMQueryEndSession); Message WM_QUERYENDSESSION; |
222 | procedure WMMENUSELECT(var msg: TWMMENUSELECT); message WM_MENUSELECT; | 228 | procedure WMMENUSELECT(var msg: TWMMENUSELECT); message WM_MENUSELECT; |
223 | - function GetFileHash(strFileName : String) : String; | ||
224 | public | 229 | public |
225 | Function Implode(p_Array : TStrings ; p_Separador : String) : String; | 230 | Function Implode(p_Array : TStrings ; p_Separador : String) : String; |
226 | function HomeDrive : string; | 231 | function HomeDrive : string; |
@@ -239,15 +244,6 @@ type | @@ -239,15 +244,6 @@ type | ||
239 | 244 | ||
240 | var FormularioGeral : TFormularioGeral; | 245 | var FormularioGeral : TFormularioGeral; |
241 | boolServerON : Boolean; | 246 | boolServerON : Boolean; |
242 | - handleStartServerThreadID, | ||
243 | - handleStartVNCThreadID, | ||
244 | - handleCacicRC : THandle; | ||
245 | - dwordStartServerID, | ||
246 | - dwordStartVNCID : dword; | ||
247 | - procStartServer : procedure; stdcall; | ||
248 | - procStopServer : procedure; stdcall; | ||
249 | - threadCacicRC : TThread; | ||
250 | - | ||
251 | 247 | ||
252 | // Some constants that are dependant on the cipher being used | 248 | // Some constants that are dependant on the cipher being used |
253 | // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) | 249 | // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) |
@@ -260,7 +256,7 @@ implementation | @@ -260,7 +256,7 @@ implementation | ||
260 | {$R *.dfm} | 256 | {$R *.dfm} |
261 | 257 | ||
262 | Uses StrUtils, Inifiles, frmConfiguracoes, frmSenha, frmLog, | 258 | Uses StrUtils, Inifiles, frmConfiguracoes, frmSenha, frmLog, |
263 | - Math,md5,LibXmlParser,WinVNC; | 259 | + Math,LibXmlParser,WinVNC; |
264 | 260 | ||
265 | // Estruturas de dados para armazenar os itens da uon1, uon1a e uon2 | 261 | // Estruturas de dados para armazenar os itens da uon1, uon1a e uon2 |
266 | type | 262 | type |
@@ -291,16 +287,6 @@ var VetorUON1 : TVetorUON1; | @@ -291,16 +287,6 @@ var VetorUON1 : TVetorUON1; | ||
291 | VetorUON1a : TVetorUON1a; | 287 | VetorUON1a : TVetorUON1a; |
292 | VetorUON2 : TVetorUON2; | 288 | VetorUON2 : TVetorUON2; |
293 | 289 | ||
294 | -// Para cálculo de HASH de determinado arquivo. | ||
295 | -// Objetivo principal: Verificar autenticidade de agentes quando em trabalho cooperativo | ||
296 | -// Anderson Peterle - Dataprev/ES - 08/Maio/2008 | ||
297 | -function TFormularioGeral.GetFileHash(strFileName : String) : String; | ||
298 | -Begin | ||
299 | - Result := 'Arquivo "'+strFileName+'" Inexistente!'; | ||
300 | - if (FileExists(strFileName)) then | ||
301 | - Result := MD5Print(MD5File(strFileName)); | ||
302 | -End; | ||
303 | - | ||
304 | // Pad a string with zeros so that it is a multiple of size | 290 | // Pad a string with zeros so that it is a multiple of size |
305 | function TFormularioGeral.PadWithZeros(const str : string; size : integer) : string; | 291 | function TFormularioGeral.PadWithZeros(const str : string; size : integer) : string; |
306 | var | 292 | var |
@@ -930,7 +916,6 @@ end; | @@ -930,7 +916,6 @@ end; | ||
930 | 916 | ||
931 | // Verifico a existência do Gerente de Coletas, caso não exista, o chksis.exe fará download! | 917 | // Verifico a existência do Gerente de Coletas, caso não exista, o chksis.exe fará download! |
932 | function TFormularioGeral.ChecaGERCOLS : boolean; | 918 | function TFormularioGeral.ChecaGERCOLS : boolean; |
933 | -var strFraseVersao : String; | ||
934 | Begin | 919 | Begin |
935 | Result := true; | 920 | Result := true; |
936 | 921 | ||
@@ -945,11 +930,8 @@ Begin | @@ -945,11 +930,8 @@ Begin | ||
945 | 930 | ||
946 | Matar(p_path_cacic + 'modulos\','ger_cols.exe'); | 931 | Matar(p_path_cacic + 'modulos\','ger_cols.exe'); |
947 | 932 | ||
948 | - strFraseVersao := 'CACIC V:' + getVersionInfo(ParamStr(0)); | ||
949 | - if not (getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened) = '') then | ||
950 | - strFraseVersao := strFraseVersao + #13#10 + 'IP: '+getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened); | 933 | + InicializaTray; |
951 | 934 | ||
952 | - InicializaTray(strFraseVersao); | ||
953 | log_diario('Acionando recuperador de Módulo Gerente de Coletas.'); | 935 | log_diario('Acionando recuperador de Módulo Gerente de Coletas.'); |
954 | log_DEBUG('Recuperador de Módulo Gerente de Coletas: '+HomeDrive + '\chksis.exe'); | 936 | log_DEBUG('Recuperador de Módulo Gerente de Coletas: '+HomeDrive + '\chksis.exe'); |
955 | WinExec(PChar(HomeDrive + '\chksis.exe'),SW_HIDE); | 937 | WinExec(PChar(HomeDrive + '\chksis.exe'),SW_HIDE); |
@@ -959,7 +941,7 @@ Begin | @@ -959,7 +941,7 @@ Begin | ||
959 | if not(v_Tamanho_Arquivo = '0') and not(v_Tamanho_Arquivo = '-1') then | 941 | if not(v_Tamanho_Arquivo = '0') and not(v_Tamanho_Arquivo = '-1') then |
960 | Begin | 942 | Begin |
961 | log_diario('Módulo Gerente de Coletas RECUPERADO COM SUCESSO!'); | 943 | log_diario('Módulo Gerente de Coletas RECUPERADO COM SUCESSO!'); |
962 | - InicializaTray(''); | 944 | + InicializaTray; |
963 | Result := True; | 945 | Result := True; |
964 | End | 946 | End |
965 | else | 947 | else |
@@ -1099,6 +1081,13 @@ Begin | @@ -1099,6 +1081,13 @@ Begin | ||
1099 | if (getValorDatMemoria('Configs.CS_COLETA_PATRIMONIO',v_tstrCipherOpened) = 'S') then Mnu_InfosPatrimoniais.Enabled := True; | 1081 | if (getValorDatMemoria('Configs.CS_COLETA_PATRIMONIO',v_tstrCipherOpened) = 'S') then Mnu_InfosPatrimoniais.Enabled := True; |
1100 | End; | 1082 | End; |
1101 | 1083 | ||
1084 | +procedure TFormularioGeral.HabilitaSuporteRemoto; | ||
1085 | +Begin | ||
1086 | + // Desabilita/Habilita a opção de Suporte Remoto | ||
1087 | + Mnu_SuporteRemoto.Enabled := False; | ||
1088 | + if (getValorDatMemoria('Configs.CS_SUPORTE_REMOTO',v_tstrCipherOpened) = 'S') then Mnu_SuporteRemoto.Enabled := True; | ||
1089 | +End; | ||
1090 | + | ||
1102 | 1091 | ||
1103 | //Para buscar do Arquivo INI... | 1092 | //Para buscar do Arquivo INI... |
1104 | // Marreta devido a limitações do KERNEL w9x no tratamento de arquivos texto e suas seções | 1093 | // Marreta devido a limitações do KERNEL w9x no tratamento de arquivos texto e suas seções |
@@ -1184,7 +1173,7 @@ begin | @@ -1184,7 +1173,7 @@ begin | ||
1184 | // Não mostrar o formulário... | 1173 | // Não mostrar o formulário... |
1185 | Application.ShowMainForm:=false; | 1174 | Application.ShowMainForm:=false; |
1186 | g_oCacic := TCACIC.Create; | 1175 | g_oCacic := TCACIC.Create; |
1187 | - g_oCacic.showTrayIcon(false); | 1176 | + //g_oCacic.showTrayIcon(false); |
1188 | boolCrypt := true; | 1177 | boolCrypt := true; |
1189 | 1178 | ||
1190 | Try | 1179 | Try |
@@ -1329,12 +1318,7 @@ begin | @@ -1329,12 +1318,7 @@ begin | ||
1329 | log_diario('PROBLEMAS SETANDO VARIÁVEIS GLOBAIS!'); | 1318 | log_diario('PROBLEMAS SETANDO VARIÁVEIS GLOBAIS!'); |
1330 | End; | 1319 | End; |
1331 | 1320 | ||
1332 | - // Envia o ícone para a bandeja com HINT mostrando Versão... | ||
1333 | - strFraseVersao := 'CACIC v:' + getVersionInfo(ParamStr(0)); | ||
1334 | - if not (getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened) = '') then | ||
1335 | - strFraseVersao := strFraseVersao + char(13) + char(10) + 'IP: '+ getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened); | ||
1336 | - pnVersao.Caption := 'V. ' + getVersionInfo(ParamStr(0)); | ||
1337 | - InicializaTray(strFraseVersao); | 1321 | + InicializaTray; |
1338 | CipherClose; | 1322 | CipherClose; |
1339 | End | 1323 | End |
1340 | else | 1324 | else |
@@ -1391,6 +1375,8 @@ Begin | @@ -1391,6 +1375,8 @@ Begin | ||
1391 | // Desabilita/Habilita a opção de Informações Gerais | 1375 | // Desabilita/Habilita a opção de Informações Gerais |
1392 | HabilitaTCP; | 1376 | HabilitaTCP; |
1393 | 1377 | ||
1378 | + // Desabilita/Habilita a opção de Suporte Remoto | ||
1379 | + HabilitaSuporteRemoto; | ||
1394 | Except | 1380 | Except |
1395 | log_diario('PROBLEMAS NA INICIALIZAÇÃO (1)'); | 1381 | log_diario('PROBLEMAS NA INICIALIZAÇÃO (1)'); |
1396 | End; | 1382 | End; |
@@ -1515,6 +1501,8 @@ begin | @@ -1515,6 +1501,8 @@ begin | ||
1515 | 1501 | ||
1516 | CipherOpen; | 1502 | CipherOpen; |
1517 | 1503 | ||
1504 | + SetValorDatMemoria('Configs.TE_SO',g_te_so,v_tstrCipherOpened); | ||
1505 | + | ||
1518 | try | 1506 | try |
1519 | if FindCmdLineSwitch('execute', True) or | 1507 | if FindCmdLineSwitch('execute', True) or |
1520 | FindCmdLineSwitch('atualizacao', True) or | 1508 | FindCmdLineSwitch('atualizacao', True) or |
@@ -1546,7 +1534,7 @@ begin | @@ -1546,7 +1534,7 @@ begin | ||
1546 | intContaExec := 2; | 1534 | intContaExec := 2; |
1547 | 1535 | ||
1548 | // Muda HINT | 1536 | // Muda HINT |
1549 | - InicializaTray(''); | 1537 | + InicializaTray; |
1550 | 1538 | ||
1551 | // Loop para possível necessidade de updates de Agente Principal e/ou Gerente de Coletas | 1539 | // Loop para possível necessidade de updates de Agente Principal e/ou Gerente de Coletas |
1552 | For intAux := intContaExec to 2 do | 1540 | For intAux := intContaExec to 2 do |
@@ -1575,11 +1563,14 @@ begin | @@ -1575,11 +1563,14 @@ begin | ||
1575 | Invoca_GerCols(nil,'coletas'); | 1563 | Invoca_GerCols(nil,'coletas'); |
1576 | sleep(3000); // Pausa para início do Gerente de Coletas e criação do arquivo temp\aguarde_GER.txt | 1564 | sleep(3000); // Pausa para início do Gerente de Coletas e criação do arquivo temp\aguarde_GER.txt |
1577 | 1565 | ||
1578 | - // Pausas de 10 segundos para o caso de ser(em) baixada(s) nova(s) versão(ões) de Ger_Cols e/ou Cacic2. | 1566 | + InicializaTray; |
1567 | + | ||
1568 | + // Pausas de 15 segundos para o caso de ser(em) baixada(s) nova(s) versão(ões) de Ger_Cols e/ou Cacic2. | ||
1579 | while not Pode_Coletar do | 1569 | while not Pode_Coletar do |
1580 | Begin | 1570 | Begin |
1581 | log_DEBUG('Aguardando mais 15 segundos...'); | 1571 | log_DEBUG('Aguardando mais 15 segundos...'); |
1582 | sleep(15000); | 1572 | sleep(15000); |
1573 | + InicializaTray; | ||
1583 | End; | 1574 | End; |
1584 | Mnu_InfosPatrimoniais.Caption := v_Aux1; | 1575 | Mnu_InfosPatrimoniais.Caption := v_Aux1; |
1585 | Mnu_InfosTCP.Caption := v_Aux2; | 1576 | Mnu_InfosTCP.Caption := v_Aux2; |
@@ -1633,6 +1624,9 @@ begin | @@ -1633,6 +1624,9 @@ begin | ||
1633 | // Desabilita/Habilita a opção de Informações de TCP/IP | 1624 | // Desabilita/Habilita a opção de Informações de TCP/IP |
1634 | HabilitaTCP; | 1625 | HabilitaTCP; |
1635 | 1626 | ||
1627 | + // Desabilita/Habilita a opção de Suporte Remoto | ||
1628 | + HabilitaSuporteRemoto; | ||
1629 | + | ||
1636 | // Para evitar uma reexecução de Ger_Cols sem necessidade... | 1630 | // Para evitar uma reexecução de Ger_Cols sem necessidade... |
1637 | intContaExec := 3; | 1631 | intContaExec := 3; |
1638 | End; | 1632 | End; |
@@ -1692,12 +1686,8 @@ begin | @@ -1692,12 +1686,8 @@ begin | ||
1692 | 1686 | ||
1693 | End; | 1687 | End; |
1694 | End; | 1688 | End; |
1695 | - // Volta a mostrar a versão no HINT... | ||
1696 | - strFraseVersao := 'CACIC V:' + getVersionInfo(ParamStr(0)); | ||
1697 | - if not (getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened) = '') then | ||
1698 | - strFraseVersao := strFraseVersao + #13#10 + 'IP: '+getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened); | ||
1699 | 1689 | ||
1700 | - InicializaTray(strFraseVersao); | 1690 | + InicializaTray; |
1701 | 1691 | ||
1702 | except | 1692 | except |
1703 | log_diario('PROBLEMAS AO TENTAR ATIVAR COLETAS.'); | 1693 | log_diario('PROBLEMAS AO TENTAR ATIVAR COLETAS.'); |
@@ -1768,35 +1758,77 @@ end; | @@ -1768,35 +1758,77 @@ end; | ||
1768 | // Todo o código deste ponto em diante está relacionado às rotinas de | 1758 | // Todo o código deste ponto em diante está relacionado às rotinas de |
1769 | // de inclusão do ícone do programa na bandeja do sistema | 1759 | // de inclusão do ícone do programa na bandeja do sistema |
1770 | //======================================================================= | 1760 | //======================================================================= |
1771 | -procedure TFormularioGeral.InicializaTray(v_Hint:string); | 1761 | +procedure TFormularioGeral.InicializaTray; |
1762 | +var Icon : TIcon; | ||
1763 | + v_intStatus : integer; | ||
1764 | + v_strHint : String; | ||
1765 | +const NORMAL = 0; | ||
1766 | + OCUPADO = 1; | ||
1767 | + DESCONFIGURADO = 2; | ||
1772 | begin | 1768 | begin |
1769 | + Icon := TIcon.Create; | ||
1773 | 1770 | ||
1774 | - {Estrutura do tray icon sendo criada.} | ||
1775 | - NotifyStruc.cbSize := SizeOf(NotifyStruc); | ||
1776 | - NotifyStruc.Wnd := Handle; | ||
1777 | - NotifyStruc.uID := 1; | ||
1778 | - NotifyStruc.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; | ||
1779 | - NotifyStruc.uCallbackMessage := WM_MYMESSAGE; {User defined message} | ||
1780 | - NotifyStruc.hIcon := Application.Icon.Handle; | 1771 | + // Monto a frase a ser colocada no Hint |
1772 | + v_strHint := 'CACIC v:' + getVersionInfo(ParamStr(0)); | ||
1773 | + if not (getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened) = '') then | ||
1774 | + v_strHint := v_strHint + char(13) + char(10); | ||
1775 | + v_strHint := v_strHint + 'IP: '+ getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened); | ||
1781 | 1776 | ||
1782 | - if (v_Hint = '') then | ||
1783 | - v_Hint := 'Aguarde...'; | 1777 | + // Mostro a versão no painel de Informações Gerais |
1778 | + pnVersao.Caption := 'V. ' + getVersionInfo(ParamStr(0)); | ||
1784 | 1779 | ||
1785 | - log_DEBUG('Setando o HINT do Systray para: "'+v_Hint+'"'); | 1780 | + // Estrutura do tray icon sendo criada. |
1781 | + NotifyStruc.cbSize := SizeOf(NotifyStruc); | ||
1782 | + NotifyStruc.Wnd := Handle; | ||
1783 | + NotifyStruc.uID := 1; | ||
1784 | + NotifyStruc.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; | ||
1785 | + NotifyStruc.uCallbackMessage := WM_MYMESSAGE; //User defined message | ||
1786 | + | ||
1787 | + // Tento apagar os arquivos indicadores de ações de coletas | ||
1788 | + FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_GER.txt'); | ||
1789 | + FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_INI.txt'); | ||
1786 | 1790 | ||
1787 | - // Atualiza o conteúdo do tip da bandeja | ||
1788 | - StrPCopy(NotifyStruc.szTip, v_Hint); | 1791 | + v_intStatus := NORMAL; |
1789 | 1792 | ||
1790 | - if (getValorDatMemoria('Configs.IN_EXIBE_BANDEJA',v_tstrCipherOpened) <> 'N') Then | 1793 | + // Caso os indicadores de ações de coletas não existam, ativo o ícone normal/desconectado... |
1794 | + if not FileExists(p_path_cacic+'temp\aguarde_GER.txt') and | ||
1795 | + not FileExists(p_path_cacic+'temp\aguarde_INI.txt') then | ||
1791 | Begin | 1796 | Begin |
1792 | - Shell_NotifyIcon(NIM_ADD, @NotifyStruc); | 1797 | + if not (FormularioGeral.getValorDatMemoria('Configs.ConexaoOK',v_tstrCipherOpened)='S') then |
1798 | + Begin | ||
1799 | + v_strHint := v_strHint + ' SERVIDOR NÃO ENCONTRADO!'; | ||
1800 | + v_intStatus := DESCONFIGURADO; | ||
1801 | + End; | ||
1793 | End | 1802 | End |
1794 | - else | 1803 | + else |
1795 | Begin | 1804 | Begin |
1796 | - Shell_NotifyIcon(HIDE_WINDOW,@NotifyStruc); | ||
1797 | - Shell_NotifyIcon(NIM_Delete,@NotifyStruc); | 1805 | + v_intStatus := OCUPADO; |
1806 | + v_strHint := 'Aguarde...'; | ||
1798 | End; | 1807 | End; |
1799 | - Shell_NotifyIcon(nim_Modify,@NotifyStruc); | 1808 | + |
1809 | + imgList_Icones.GetIcon(v_intStatus,Icon); | ||
1810 | + | ||
1811 | + NotifyStruc.hIcon := Icon.Handle; | ||
1812 | + | ||
1813 | + log_DEBUG('Setando o HINT do Systray para: "'+v_strHint+'"'); | ||
1814 | + | ||
1815 | + // Atualiza o conteúdo do tip da bandeja | ||
1816 | + StrPCopy(NotifyStruc.szTip, v_strHint); | ||
1817 | + | ||
1818 | + if (getValorDatMemoria('Configs.IN_EXIBE_BANDEJA',v_tstrCipherOpened) <> 'N') Then | ||
1819 | + Begin | ||
1820 | + Shell_NotifyIcon(NIM_ADD, @NotifyStruc); | ||
1821 | + End | ||
1822 | + else | ||
1823 | + Begin | ||
1824 | + Shell_NotifyIcon(HIDE_WINDOW,@NotifyStruc); | ||
1825 | + Shell_NotifyIcon(NIM_Delete,@NotifyStruc); | ||
1826 | + End; | ||
1827 | + Shell_NotifyIcon(nim_Modify,@NotifyStruc); | ||
1828 | + | ||
1829 | + Application.ProcessMessages; | ||
1830 | + | ||
1831 | + Icon.Free; | ||
1800 | end; | 1832 | end; |
1801 | 1833 | ||
1802 | procedure TFormularioGeral.WMSysCommand; | 1834 | procedure TFormularioGeral.WMSysCommand; |
@@ -1817,9 +1849,13 @@ begin | @@ -1817,9 +1849,13 @@ begin | ||
1817 | Mnu_InfosPatrimoniais.Enabled := False; | 1849 | Mnu_InfosPatrimoniais.Enabled := False; |
1818 | // Habilita a opção de menu caso a coleta de patrimonio esteja habilitado. | 1850 | // Habilita a opção de menu caso a coleta de patrimonio esteja habilitado. |
1819 | HabilitaPatrimonio; | 1851 | HabilitaPatrimonio; |
1852 | + | ||
1853 | + // Habilita a opção de menu caso o suporte remoto esteja habilitado. | ||
1854 | + HabilitaSuporteRemoto; | ||
1855 | + | ||
1820 | SetForegroundWindow(Handle); | 1856 | SetForegroundWindow(Handle); |
1821 | GetCursorPos(Posicao); | 1857 | GetCursorPos(Posicao); |
1822 | - PopupMenu1.Popup(Posicao.X, Posicao.Y); | 1858 | + Popup_Menu_Contexto.Popup(Posicao.X, Posicao.Y); |
1823 | end; | 1859 | end; |
1824 | 1860 | ||
1825 | end; | 1861 | end; |
@@ -2235,7 +2271,7 @@ begin | @@ -2235,7 +2271,7 @@ begin | ||
2235 | (strCmd = 'Exit') then | 2271 | (strCmd = 'Exit') then |
2236 | AResponseinfo.ContentText := 'OK' | 2272 | AResponseinfo.ContentText := 'OK' |
2237 | else | 2273 | else |
2238 | - AResponseinfo.ContentText := 'COMANDO NÃO PERMITIDO!'; | 2274 | + AResponseinfo.ContentText := 'COMANDO NÃO RECONHECIDO!'; |
2239 | End | 2275 | End |
2240 | else | 2276 | else |
2241 | AResponseinfo.ContentText := 'ACESSO NÃO PERMITIDO!'; | 2277 | AResponseinfo.ContentText := 'ACESSO NÃO PERMITIDO!'; |
@@ -2276,7 +2312,6 @@ begin | @@ -2276,7 +2312,6 @@ begin | ||
2276 | End | 2312 | End |
2277 | else | 2313 | else |
2278 | Begin | 2314 | Begin |
2279 | - GetWinVer; | ||
2280 | log_DEBUG('Invocando "'+p_path_cacic + 'modulos\srcacicsrv.exe"...'); | 2315 | log_DEBUG('Invocando "'+p_path_cacic + 'modulos\srcacicsrv.exe"...'); |
2281 | Log_Diario('Ativando Suporte Remoto Seguro.'); | 2316 | Log_Diario('Ativando Suporte Remoto Seguro.'); |
2282 | boolAux := boolCrypt; | 2317 | boolAux := boolCrypt; |
@@ -2291,7 +2326,7 @@ begin | @@ -2291,7 +2326,7 @@ begin | ||
2291 | strPalavraChave := StringReplace(strPalavraChave,'\' ,'<BarrInv>' ,[rfReplaceAll]); | 2326 | strPalavraChave := StringReplace(strPalavraChave,'\' ,'<BarrInv>' ,[rfReplaceAll]); |
2292 | strPalavraChave := StringReplace(EnCrypt(strPalavraChave),'+','<MAIS>',[rfReplaceAll]); | 2327 | strPalavraChave := StringReplace(EnCrypt(strPalavraChave),'+','<MAIS>',[rfReplaceAll]); |
2293 | 2328 | ||
2294 | - strTeSO := StringReplace(v_te_so ,' ' ,'<ESPACE>' ,[rfReplaceAll]); | 2329 | + strTeSO := StringReplace(FormularioGeral.getValorDatMemoria('Configs.TE_SO', v_tstrCipherOpened),' ','<ESPACE>',[rfReplaceAll]); |
2295 | strTeSO := StringReplace(EnCrypt(strTeSO),'+','<MAIS>',[rfReplaceAll]); | 2330 | strTeSO := StringReplace(EnCrypt(strTeSO),'+','<MAIS>',[rfReplaceAll]); |
2296 | 2331 | ||
2297 | strTeNodeAddress := StringReplace(FormularioGeral.getValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),' ','<ESPACE>' ,[rfReplaceAll]); | 2332 | strTeNodeAddress := StringReplace(FormularioGeral.getValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),' ','<ESPACE>' ,[rfReplaceAll]); |
@@ -2333,48 +2368,13 @@ begin | @@ -2333,48 +2368,13 @@ begin | ||
2333 | BoolServerON := true; | 2368 | BoolServerON := true; |
2334 | End; | 2369 | End; |
2335 | 2370 | ||
2336 | - { | ||
2337 | - //handleCacicRC := LoadLibrary('modulos\cacicrc.dll'); | ||
2338 | - threadCacicRC := WinVNCThread.Create(false); | ||
2339 | - | ||
2340 | -// if (handleCacicRC > 0) then | ||
2341 | - if (threadCacicRC.Handle > 0) then | ||
2342 | - Begin | ||
2343 | - //procStartServer := GetProcAddress(handleCacicRC,'StartServer'); | ||
2344 | - WinVNCThread.Synchronize(threadCacicRC,StartVNCServer); | ||
2345 | - if not boolServerON then | ||
2346 | - begin | ||
2347 | - handleStartVNCThreadID := CreateThread(nil, 0, @TFormularioGeral.StartVNCServer, nil, 0, dwordStartVNCID); | ||
2348 | - if (handleStartVNCThreadID <> 0) then | ||
2349 | - boolServerON := true; | ||
2350 | - end | ||
2351 | - else | ||
2352 | - begin | ||
2353 | - procStopServer := GetProcAddress(handleCacicRC,'StopServer'); | ||
2354 | - procStopServer; | ||
2355 | - TerminateThread(dwordStartServerID, 0); | ||
2356 | - TerminateThread(handleStartServerThreadID, 0); | ||
2357 | - FreeProcInstance(@procStartServer); | ||
2358 | - FreeProcInstance(@procStopServer); | ||
2359 | - FreeLibrary(handleCacicRC); | ||
2360 | - boolServerON := false; | ||
2361 | - end; | ||
2362 | - End | ||
2363 | - else | ||
2364 | - MessageBox(0, 'Não foi possivel carregar a biblioteca de acesso remoto!', 'Erro', MB_ICONERROR); | ||
2365 | - | ||
2366 | - } | ||
2367 | -end; | ||
2368 | -{ | ||
2369 | -procedure TFormularioGeral.StartVNCServer; | ||
2370 | -begin | ||
2371 | - handleStartServerThreadID := CreateThread(nil, 0, @procStartServer, nil, 0, dwordStartServerID); | ||
2372 | end; | 2371 | end; |
2373 | -} | ||
2374 | -procedure TFormularioGeral.PopupMenu1Popup(Sender: TObject); | 2372 | + |
2373 | +procedure TFormularioGeral.Popup_Menu_ContextoPopup(Sender: TObject); | ||
2375 | begin | 2374 | begin |
2376 | VerificaDebugs; | 2375 | VerificaDebugs; |
2377 | - if FileExists(p_path_cacic + 'modulos\srcacicsrv.exe') then | 2376 | + if (getValorDatMemoria('Configs.CS_SUPORTE_REMOTO',v_tstrCipherOpened) = 'S') and |
2377 | + (FileExists(p_path_cacic + 'modulos\srcacicsrv.exe')) then | ||
2378 | Mnu_SuporteRemoto.Enabled := true | 2378 | Mnu_SuporteRemoto.Enabled := true |
2379 | else | 2379 | else |
2380 | Mnu_SuporteRemoto.Enabled := false; | 2380 | Mnu_SuporteRemoto.Enabled := false; |
@@ -2391,4 +2391,11 @@ begin | @@ -2391,4 +2391,11 @@ begin | ||
2391 | 2391 | ||
2392 | end; | 2392 | end; |
2393 | 2393 | ||
2394 | +procedure TFormularioGeral.Timer_InicializaTrayTimer(Sender: TObject); | ||
2395 | +begin | ||
2396 | + Timer_InicializaTray.Enabled := false; | ||
2397 | + InicializaTray; | ||
2398 | + Timer_InicializaTray.Enabled := true; | ||
2399 | +end; | ||
2400 | + | ||
2394 | end. | 2401 | end. |
mapa/mapacacic.res
No preview for this file type
testacrypt/testacrypt.res
No preview for this file type
vaca/vaca.res
No preview for this file type
vacon/vacon.res
No preview for this file type