Commit 873da8f1b38c7f8aa15a65a6baf42830c41f9db1

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

O ChkCacic passa a interpretar as opcoes "/serv=" e "/dir=" em linha de comando.

git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@102 fecfc0c7-e812-0410-ae72-849f08638ee7
chkcacic/FormConfig.dcu
No preview for this file type
chkcacic/FormConfig.dfm
1 object Configs: TConfigs 1 object Configs: TConfigs
2 - Left = 258  
3 - Top = 175 2 + Left = 260
  3 + Top = 102
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 = 331  
8 - ClientWidth = 453 7 + ClientHeight = 382
  8 + ClientWidth = 490
9 Color = clBtnFace 9 Color = clBtnFace
10 Font.Charset = DEFAULT_CHARSET 10 Font.Charset = DEFAULT_CHARSET
11 Font.Color = clWindowText 11 Font.Color = clWindowText
@@ -16,24 +16,11 @@ object Configs: TConfigs @@ -16,24 +16,11 @@ object Configs: TConfigs
16 Position = poScreenCenter 16 Position = poScreenCenter
17 PixelsPerInch = 96 17 PixelsPerInch = 96
18 TextHeight = 13 18 TextHeight = 13
19 - object Label2: TLabel  
20 - Left = 402  
21 - Top = 312  
22 - Width = 27  
23 - Height = 12  
24 - Caption = 'Label1'  
25 - Font.Charset = DEFAULT_CHARSET  
26 - Font.Color = clWindowText  
27 - Font.Height = -9  
28 - Font.Name = 'Arial'  
29 - Font.Style = []  
30 - ParentFont = False  
31 - end  
32 - object GroupBox2: TGroupBox 19 + object gbOpcional: TGroupBox
33 Left = 5 20 Left = 5
34 Top = 83 21 Top = 83
35 - Width = 444  
36 - Height = 202 22 + Width = 480
  23 + Height = 219
37 Caption = 'Opcional' 24 Caption = 'Opcional'
38 Font.Charset = DEFAULT_CHARSET 25 Font.Charset = DEFAULT_CHARSET
39 Font.Color = clWindowText 26 Font.Color = clWindowText
@@ -43,8 +30,8 @@ object Configs: TConfigs @@ -43,8 +30,8 @@ object Configs: TConfigs
43 ParentFont = False 30 ParentFont = False
44 TabOrder = 3 31 TabOrder = 3
45 object Label1: TLabel 32 object Label1: TLabel
46 - Left = 63  
47 - Top = -1 33 + Left = 265
  34 + Top = 25
48 Width = 200 35 Width = 200
49 Height = 13 36 Height = 13
50 Caption = '(N'#227'o aplic'#225'vel ao ChkCacic do NetLogon)' 37 Caption = '(N'#227'o aplic'#225'vel ao ChkCacic do NetLogon)'
@@ -71,8 +58,8 @@ object Configs: TConfigs @@ -71,8 +58,8 @@ object Configs: TConfigs
71 object Memo_te_instala_informacoes_extras: TMemo 58 object Memo_te_instala_informacoes_extras: TMemo
72 Left = 9 59 Left = 9
73 Top = 65 60 Top = 65
74 - Width = 426  
75 - Height = 127 61 + Width = 462
  62 + Height = 144
76 Color = clInactiveBorder 63 Color = clInactiveBorder
77 Enabled = False 64 Enabled = False
78 Font.Charset = DEFAULT_CHARSET 65 Font.Charset = DEFAULT_CHARSET
@@ -96,7 +83,7 @@ object Configs: TConfigs @@ -96,7 +83,7 @@ object Configs: TConfigs
96 object ckboxExibeInformacoes: TCheckBox 83 object ckboxExibeInformacoes: TCheckBox
97 Left = 9 84 Left = 9
98 Top = 23 85 Top = 23
99 - Width = 424 86 + Width = 256
100 Height = 17 87 Height = 17
101 Caption = 'Exibe informa'#231#245'es sobre o processo de instala'#231#227'o' 88 Caption = 'Exibe informa'#231#245'es sobre o processo de instala'#231#227'o'
102 Font.Charset = DEFAULT_CHARSET 89 Font.Charset = DEFAULT_CHARSET
@@ -109,10 +96,10 @@ object Configs: TConfigs @@ -109,10 +96,10 @@ object Configs: TConfigs
109 OnClick = ckboxExibeInformacoesClick 96 OnClick = ckboxExibeInformacoesClick
110 end 97 end
111 end 98 end
112 - object GroupBox1: TGroupBox 99 + object gbObrigatorio: TGroupBox
113 Left = 5 100 Left = 5
114 Top = 8 101 Top = 8
115 - Width = 444 102 + Width = 480
116 Height = 64 103 Height = 64
117 Caption = 'Obrigat'#243'rio' 104 Caption = 'Obrigat'#243'rio'
118 Font.Charset = DEFAULT_CHARSET 105 Font.Charset = DEFAULT_CHARSET
@@ -136,7 +123,7 @@ object Configs: TConfigs @@ -136,7 +123,7 @@ object Configs: TConfigs
136 ParentFont = False 123 ParentFont = False
137 end 124 end
138 object Label_cacic_dir: TLabel 125 object Label_cacic_dir: TLabel
139 - Left = 236 126 + Left = 271
140 Top = 19 127 Top = 19
141 Width = 103 128 Width = 103
142 Height = 13 129 Height = 13
@@ -158,7 +145,7 @@ object Configs: TConfigs @@ -158,7 +145,7 @@ object Configs: TConfigs
158 TabOrder = 0 145 TabOrder = 0
159 end 146 end
160 object Edit_cacic_dir: TEdit 147 object Edit_cacic_dir: TEdit
161 - Left = 241 148 + Left = 276
162 Top = 42 149 Top = 42
163 Width = 200 150 Width = 200
164 Height = 21 151 Height = 21
@@ -167,10 +154,10 @@ object Configs: TConfigs @@ -167,10 +154,10 @@ object Configs: TConfigs
167 Text = 'Cacic' 154 Text = 'Cacic'
168 end 155 end
169 object Button_Gravar: TButton 156 object Button_Gravar: TButton
170 - Left = 62  
171 - Top = 292 157 + Left = 74
  158 + Top = 325
172 Width = 150 159 Width = 150
173 - Height = 30 160 + Height = 35
174 Caption = 'Gravar Configura'#231#245'es' 161 Caption = 'Gravar Configura'#231#245'es'
175 Font.Charset = DEFAULT_CHARSET 162 Font.Charset = DEFAULT_CHARSET
176 Font.Color = clWindowText 163 Font.Color = clWindowText
@@ -182,10 +169,10 @@ object Configs: TConfigs @@ -182,10 +169,10 @@ object Configs: TConfigs
182 OnClick = Button_GravarClick 169 OnClick = Button_GravarClick
183 end 170 end
184 object btSair: TButton 171 object btSair: TButton
185 - Left = 242  
186 - Top = 292 172 + Left = 265
  173 + Top = 325
187 Width = 150 174 Width = 150
188 - Height = 30 175 + Height = 35
189 Caption = 'Sair' 176 Caption = 'Sair'
190 Font.Charset = DEFAULT_CHARSET 177 Font.Charset = DEFAULT_CHARSET
191 Font.Color = clWindowText 178 Font.Color = clWindowText
@@ -196,8 +183,31 @@ object Configs: TConfigs @@ -196,8 +183,31 @@ object Configs: TConfigs
196 TabOrder = 5 183 TabOrder = 5
197 OnClick = btSairClick 184 OnClick = btSairClick
198 end 185 end
  186 + object pnVersao: TPanel
  187 + Left = 426
  188 + Top = 302
  189 + Width = 58
  190 + Height = 14
  191 + BevelOuter = bvLowered
  192 + TabOrder = 6
  193 + object lbVersao: TLabel
  194 + Left = 4
  195 + Top = 1
  196 + Width = 53
  197 + Height = 12
  198 + Alignment = taCenter
  199 + AutoSize = False
  200 + Caption = 'V:2.00.00.00'
  201 + Font.Charset = DEFAULT_CHARSET
  202 + Font.Color = clWindowText
  203 + Font.Height = -9
  204 + Font.Name = 'Arial'
  205 + Font.Style = []
  206 + ParentFont = False
  207 + end
  208 + end
199 object PJVersionInfo1: TPJVersionInfo 209 object PJVersionInfo1: TPJVersionInfo
200 Left = 5 210 Left = 5
201 - Top = 293 211 + Top = 323
202 end 212 end
203 end 213 end
chkcacic/FormConfig.pas
@@ -21,24 +21,25 @@ interface @@ -21,24 +21,25 @@ interface
21 21
22 uses 22 uses
23 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 23 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
24 - Dialogs, StdCtrls,main, PJVersionInfo, NTFileSecurity; 24 + Dialogs, StdCtrls,main, PJVersionInfo, NTFileSecurity, Buttons, ExtCtrls;
25 25
26 type 26 type
27 TConfigs = class(TForm) 27 TConfigs = class(TForm)
28 Edit_ip_serv_cacic: TEdit; 28 Edit_ip_serv_cacic: TEdit;
29 Edit_cacic_dir: TEdit; 29 Edit_cacic_dir: TEdit;
30 - GroupBox1: TGroupBox; 30 + gbObrigatorio: TGroupBox;
31 Label_ip_serv_cacic: TLabel; 31 Label_ip_serv_cacic: TLabel;
32 Label_cacic_dir: TLabel; 32 Label_cacic_dir: TLabel;
33 - GroupBox2: TGroupBox; 33 + gbOpcional: TGroupBox;
34 Label1: TLabel; 34 Label1: 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;
38 PJVersionInfo1: TPJVersionInfo; 38 PJVersionInfo1: TPJVersionInfo;
39 - Label2: TLabel;  
40 ckboxExibeInformacoes: TCheckBox; 39 ckboxExibeInformacoes: TCheckBox;
41 btSair: TButton; 40 btSair: TButton;
  41 + pnVersao: TPanel;
  42 + lbVersao: TLabel;
42 procedure Button_GravarClick(Sender: TObject); 43 procedure Button_GravarClick(Sender: TObject);
43 procedure ckboxExibeInformacoesClick(Sender: TObject); 44 procedure ckboxExibeInformacoesClick(Sender: TObject);
44 procedure btSairClick(Sender: TObject); 45 procedure btSairClick(Sender: TObject);
chkcacic/MAIN.PAS
@@ -14,8 +14,38 @@ Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LIC @@ -14,8 +14,38 @@ Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LIC
14 Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 14 Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 15
16 --------------------------------------------------------------------------------------------------------------------------------------------------------------- 16 ---------------------------------------------------------------------------------------------------------------------------------------------------------------
  17 +=====================================================================================================
  18 +ChkCacic.exe : Verificador/Instalador dos agentes principais Cacic2.exe e Ger_Cols.exe
  19 +=====================================================================================================
  20 +
  21 +v 2.2.0.17
  22 ++ Acrescentado o tratamento da passagem de opções em linha de comando
  23 + * chkcacic /serv=<ip_server> /dir=<local_path>c:\%windir%\cacic
  24 + Exemplo de uso: chkcacic /serv=UXbra001 /dir=Cacic
  25 +
  26 +v 2.2.0.16
  27 +* Corrigido o fechamento do arquivo de configurações de ChkSis
  28 +
  29 +v 2.2.0.15
  30 +* Substituída a mensagem "File System diferente de "NTFS" por 'File System: "<NomeFileSystem>" - Ok!'
  31 +
  32 +v 2.2.0.14
  33 ++ Críticas/mensagens:
  34 + "ATENÇÃO! Não foi possível estabelecer comunicação com o módulo Gerente WEB em <servidor>." e
  35 + "ATENÇÃO: Não foi possível efetuar FTP para <agente>. Verifique o Servidor de Updates."
  36 ++ Opção checkbox "Exibe informações sobre o processo de instalação" ao formulário de configuração;
  37 ++ Botão "Sair" ao formulário de configuração;
  38 ++ Execução automática do Agente Principal ao fim da instalação quando a unidade origem do ChkCacic não
  39 + for mapeamento de rede ou unidade inválida.
  40 +
  41 +- Retirados os campos "Frase para Sucesso na Instalação" e "Frase para Insucesso na Instalação"
  42 + do formulário de configuração, passando essas frases a serem fixas na aplicação.
  43 +- Retirada a opção radiobutton "Remove Versão Anterior?";
  44 +
  45 +=====================================================================================================
17 *) 46 *)
18 47
  48 +
19 unit main; 49 unit main;
20 50
21 interface 51 interface
@@ -31,7 +61,6 @@ uses Windows, @@ -31,7 +61,6 @@ uses Windows,
31 XML, 61 XML,
32 LibXmlParser, 62 LibXmlParser,
33 IdHTTP, 63 IdHTTP,
34 - dialogs,  
35 PJVersionInfo, 64 PJVersionInfo,
36 Controls, 65 Controls,
37 StdCtrls, 66 StdCtrls,
@@ -44,14 +73,16 @@ uses Windows, @@ -44,14 +73,16 @@ uses Windows,
44 DCPrijndael, 73 DCPrijndael,
45 DCPbase64, 74 DCPbase64,
46 NTFileSecurity, IdFTP, 75 NTFileSecurity, IdFTP,
47 - Tlhelp32; 76 + Tlhelp32,
  77 + dialogs;
48 78
49 var v_ip_serv_cacic, 79 var v_ip_serv_cacic,
50 v_cacic_dir, 80 v_cacic_dir,
51 - v_rem_cacic_v0x, 81 +// v_rem_cacic_v0x,
52 v_te_instala_frase_sucesso, 82 v_te_instala_frase_sucesso,
53 v_te_instala_frase_insucesso, 83 v_te_instala_frase_insucesso,
54 v_te_instala_informacoes_extras, 84 v_te_instala_informacoes_extras,
  85 + v_exibe_informacoes,
55 v_versao_local, 86 v_versao_local,
56 v_versao_remota_inteira, 87 v_versao_remota_inteira,
57 v_versao_remota_capada, 88 v_versao_remota_capada,
@@ -80,22 +111,24 @@ Procedure MostraFormConfigura; @@ -80,22 +111,24 @@ Procedure MostraFormConfigura;
80 Procedure GravaConfiguracoes; 111 Procedure GravaConfiguracoes;
81 Procedure DelValorReg(Chave: String); 112 Procedure DelValorReg(Chave: String);
82 procedure log_diario(strMsg : String); 113 procedure log_diario(strMsg : String);
  114 +procedure KillProcess(hWindowHandle: HWND); // 2.2.0.15
  115 +procedure Matar(v_dir,v_files: string); // 2.2.0.16
83 Function ListFileDir(Path: string):string; 116 Function ListFileDir(Path: string):string;
84 Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean; 117 Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean;
85 Function Explode(Texto, Separador : String) : TStrings; 118 Function Explode(Texto, Separador : String) : TStrings;
86 Function GetRootKey(strRootKey: String): HKEY; 119 Function GetRootKey(strRootKey: String): HKEY;
87 Function SetValorChaveRegEdit(Chave: String; Dado: Variant): Variant; 120 Function SetValorChaveRegEdit(Chave: String; Dado: Variant): Variant;
88 Function GetValorChaveRegEdit(Chave: String): Variant; 121 Function GetValorChaveRegEdit(Chave: String): Variant;
89 -function SetValorChaveRegIni(p_Secao, p_Chave, p_Valor, p_File : String): String;  
90 -function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String;  
91 -function HomeDrive : string; 122 +Function SetValorChaveRegIni(p_Secao, p_Chave, p_Valor, p_File : String): String;
  123 +Function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String;
  124 +Function HomeDrive : string;
92 Function RemoveCaracteresEspeciais(Texto : String) : String; 125 Function RemoveCaracteresEspeciais(Texto : String) : String;
93 -function FindWindowByTitle(WindowTitle: string): Hwnd;  
94 -function GetVersionInfo(p_File: string):string;  
95 -function VerFmt(const MS, LS: DWORD): string;  
96 -function GetWinVer: Integer;  
97 -function KillTask(ExeFileName: string): Integer;  
98 -procedure KillProcess(hWindowHandle: HWND); 126 +Function FindWindowByTitle(WindowTitle: string): Hwnd;
  127 +Function GetVersionInfo(p_File: string):string;
  128 +Function VerFmt(const MS, LS: DWORD): string;
  129 +Function GetWinVer: Integer;
  130 +Function KillTask(ExeFileName: string): Integer;
  131 +Function ChecaVersoesAgentes(p_strNomeAgente : String) : integer; // 2.2.0.16
99 132
100 type 133 type
101 TForm1 = class(TForm) 134 TForm1 = class(TForm)
@@ -115,6 +148,7 @@ implementation @@ -115,6 +148,7 @@ implementation
115 uses FormConfig; 148 uses FormConfig;
116 149
117 {$R *.dfm} 150 {$R *.dfm}
  151 +
118 function IsAdmin: Boolean; 152 function IsAdmin: Boolean;
119 var hAccessToken: THandle; 153 var hAccessToken: THandle;
120 ptgGroups: PTokenGroups; 154 ptgGroups: PTokenGroups;
@@ -629,7 +663,7 @@ end; @@ -629,7 +663,7 @@ end;
629 Procedure CriaFormConfigura; 663 Procedure CriaFormConfigura;
630 begin 664 begin
631 Application.CreateForm(TConfigs, FormConfig.Configs); 665 Application.CreateForm(TConfigs, FormConfig.Configs);
632 - FormConfig.Configs.Label2.Caption := 'v: ' + getVersionInfo(ParamStr(0)); 666 + FormConfig.Configs.lbVersao.Caption := 'v: ' + getVersionInfo(ParamStr(0));
633 end; 667 end;
634 668
635 Procedure MostraFormConfigura; 669 Procedure MostraFormConfigura;
@@ -722,28 +756,23 @@ begin @@ -722,28 +756,23 @@ begin
722 Writeln(chkcacic_ini,'# CHAVES E VALORES OBRIGATÓRIOS PARA USO DO CHKCACIC.EXE'); 756 Writeln(chkcacic_ini,'# CHAVES E VALORES OBRIGATÓRIOS PARA USO DO CHKCACIC.EXE');
723 Writeln(chkcacic_ini,'# ==================================================================================='); 757 Writeln(chkcacic_ini,'# ===================================================================================');
724 Writeln(chkcacic_ini,'# ip_serv_cacic'); 758 Writeln(chkcacic_ini,'# ip_serv_cacic');
725 - Writeln(chkcacic_ini,'# Endereço IP do servidor onde o Módulo Gerente do CACIC foi instalado');  
726 - Writeln(chkcacic_ini,'# Ex.: ip_serv_cacic=10.xxx.yyy.zzz'); 759 + Writeln(chkcacic_ini,'# Endereço IP ou Nome(DNS) do servidor onde o Módulo Gerente do CACIC foi instalado');
  760 + Writeln(chkcacic_ini,'# Ex1.: ip_serv_cacic=10.xxx.yyy.zzz');
  761 + Writeln(chkcacic_ini,'# Ex2.: ip_serv_cacic=uxesa001');
727 Writeln(chkcacic_ini,'# cacic_dir'); 762 Writeln(chkcacic_ini,'# cacic_dir');
728 Writeln(chkcacic_ini,'# Pasta a ser criada na estação para instalação do CACIC agente'); 763 Writeln(chkcacic_ini,'# Pasta a ser criada na estação para instalação do CACIC agente');
729 Writeln(chkcacic_ini,'# Ex.: cacic_dir=Cacic'); 764 Writeln(chkcacic_ini,'# Ex.: cacic_dir=Cacic');
730 - Writeln(chkcacic_ini,'# rem_cacic_v0x');  
731 - Writeln(chkcacic_ini,'# Indicador de desligamento do CACIC versão antiga (anterior à versão 2)');  
732 - Writeln(chkcacic_ini,'# Ex.: rem_cacic_v0x=S'); 765 + Writeln(chkcacic_ini,'# exibe_informacoes');
  766 + Writeln(chkcacic_ini,'# Indicador de exibicao de informações sobre o processo de instalação');
  767 + Writeln(chkcacic_ini,'# Ex.: exibe_informacoes=N');
733 Writeln(chkcacic_ini,''); 768 Writeln(chkcacic_ini,'');
734 Writeln(chkcacic_ini,''); 769 Writeln(chkcacic_ini,'');
735 Writeln(chkcacic_ini,'# CHAVES E VALORES OPCIONAIS PARA USO DO CHKCACIC.EXE'); 770 Writeln(chkcacic_ini,'# CHAVES E VALORES OPCIONAIS PARA USO DO CHKCACIC.EXE');
736 Writeln(chkcacic_ini,'# (ATENÇÃO: NÃO PREENCHER EM CASO DE CHKCACIC.INI PARA O NETLOGON!)'); 771 Writeln(chkcacic_ini,'# (ATENÇÃO: NÃO PREENCHER EM CASO DE CHKCACIC.INI PARA O NETLOGON!)');
737 Writeln(chkcacic_ini,'# ==================================================================================='); 772 Writeln(chkcacic_ini,'# ===================================================================================');
738 - Writeln(chkcacic_ini,'# te_instala_frase_sucesso');  
739 - Writeln(chkcacic_ini,'# Frase a ser mostrada quando instalação/recuperação efetuada com sucesso');  
740 - Writeln(chkcacic_ini,'# Ex.: te_instala_frase_sucesso=Instalação/Recuperação do CACIC efetuada com sucesso! Obrigado!');  
741 - Writeln(chkcacic_ini,'# te_instala_frase_insucesso');  
742 - Writeln(chkcacic_ini,'# Frase a ser mostrada quando instalação/recuperação efetuada sem sucesso');  
743 - Writeln(chkcacic_ini,'# Ex.: te_instala_frase_insucesso=Instalação/Recuperação do CACIC efetuada sem sucesso! Por favor, entre em contato com:');  
744 Writeln(chkcacic_ini,'# te_instala_informacoes_extras'); 773 Writeln(chkcacic_ini,'# te_instala_informacoes_extras');
745 Writeln(chkcacic_ini,'# Informações a serem mostradas na janela de Instalação/Recuperação'); 774 Writeln(chkcacic_ini,'# Informações a serem mostradas na janela de Instalação/Recuperação');
746 - Writeln(chkcacic_ini,'# Ex.: Dataprev-UF / Suporte Técnico'); 775 + Writeln(chkcacic_ini,'# Ex.: Empresa-UF / Suporte Técnico');
747 Writeln(chkcacic_ini,'# Emails: email_do_suporte@xxxxxx.yyy.zz, outro_email@outro_dominio.xxx.yy'); 776 Writeln(chkcacic_ini,'# Emails: email_do_suporte@xxxxxx.yyy.zz, outro_email@outro_dominio.xxx.yy');
748 Writeln(chkcacic_ini,'# Telefones: (xx) yyyy-zzzz / (xx) yyyy-zzzz'); 777 Writeln(chkcacic_ini,'# Telefones: (xx) yyyy-zzzz / (xx) yyyy-zzzz');
749 Writeln(chkcacic_ini,'# Endereço: Rua Nome_da_Rua, Nº 99999'); 778 Writeln(chkcacic_ini,'# Endereço: Rua Nome_da_Rua, Nº 99999');
@@ -797,20 +826,21 @@ begin @@ -797,20 +826,21 @@ begin
797 // Atribuição dos valores do form FormConfig às variáveis... 826 // Atribuição dos valores do form FormConfig às variáveis...
798 v_ip_serv_cacic := Configs.Edit_ip_serv_cacic.text; 827 v_ip_serv_cacic := Configs.Edit_ip_serv_cacic.text;
799 v_cacic_dir := Configs.Edit_cacic_dir.text; 828 v_cacic_dir := Configs.Edit_cacic_dir.text;
800 - v_rem_cacic_v0x := 'S';  
801 - v_te_instala_frase_sucesso := Configs.Edit_te_instala_frase_sucesso.text;  
802 - v_te_instala_frase_insucesso := Configs.Edit_te_instala_frase_insucesso.text; 829 + if Configs.ckboxExibeInformacoes.Checked then
  830 + v_exibe_informacoes := 'S'
  831 + else
  832 + v_exibe_informacoes := 'N';
  833 +
803 v_te_instala_informacoes_extras := Configs.Memo_te_instala_informacoes_extras.Text; 834 v_te_instala_informacoes_extras := Configs.Memo_te_instala_informacoes_extras.Text;
804 835
805 // Escrita dos parâmetros obrigatórios 836 // Escrita dos parâmetros obrigatórios
806 Writeln(chkcacic_ini,'ip_serv_cacic='+v_ip_serv_cacic); 837 Writeln(chkcacic_ini,'ip_serv_cacic='+v_ip_serv_cacic);
807 Writeln(chkcacic_ini,'cacic_dir='+v_cacic_dir); 838 Writeln(chkcacic_ini,'cacic_dir='+v_cacic_dir);
808 - Writeln(chkcacic_ini,'rem_cacic_v0x='+v_rem_cacic_v0x); 839 + Writeln(chkcacic_ini,'exibe_informacoes='+v_exibe_informacoes);
809 840
810 // Escrita dos valores opcionais quando existirem 841 // Escrita dos valores opcionais quando existirem
811 - if (v_te_instala_frase_sucesso <>'') then Writeln(chkcacic_ini,'te_instala_frase_sucesso='+ v_te_instala_frase_sucesso);  
812 - if (v_te_instala_frase_insucesso <>'') then Writeln(chkcacic_ini,'te_instala_frase_insucesso='+ v_te_instala_frase_insucesso);  
813 - if (v_te_instala_informacoes_extras <>'') then Writeln(chkcacic_ini,'te_instala_informacoes_extras='+ StringReplace(v_te_instala_informacoes_extras,#13#10,'*13*10',[rfReplaceAll])); 842 + if (v_te_instala_informacoes_extras <>'') then
  843 + Writeln(chkcacic_ini,'te_instala_informacoes_extras='+ StringReplace(v_te_instala_informacoes_extras,#13#10,'*13*10',[rfReplaceAll]));
814 CloseFile(chkcacic_ini); {Fecha o arquivo texto} 844 CloseFile(chkcacic_ini); {Fecha o arquivo texto}
815 except 845 except
816 end; 846 end;
@@ -849,11 +879,88 @@ begin @@ -849,11 +879,88 @@ begin
849 879
850 end; 880 end;
851 881
  882 +// Dica obtida em http://www.webmundi.com/delphi/dfuncaof.asp?SubTipo=Sistema
  883 +Function DriveType(Unidade: String):String;
  884 +Var StrDrive,
  885 + StrDriveType : String;
  886 + intDriveType : Integer;
  887 +begin
  888 + StrDrive := Unidade;
  889 + If StrDrive[Length(StrDrive)] <> '\' Then
  890 + StrDrive := StrDrive + ':\';
  891 +
  892 + intDriveType := GetDriveType(PChar(StrDrive));
  893 + Case intDriveType Of
  894 + 0 : StrDriveType := 'ERRO';
  895 + 1 : StrDriveType := 'ERRO';
  896 + DRIVE_REMOVABLE : StrDriveType := 'FLOPPY';
  897 + DRIVE_FIXED : StrDriveType := 'HD';
  898 + DRIVE_REMOTE : StrDriveType := 'REDE';
  899 + DRIVE_CDROM : StrDriveType := 'CDROM';
  900 + DRIVE_RAMDISK : StrDriveType := 'RAM';
  901 + end;
  902 + Result := StrDriveType;
  903 +End;
  904 +
  905 +Function ChecaVersoesAgentes(p_strNomeAgente : String) : integer; // 2.2.0.16
  906 +var v_versao_INI,
  907 + v_versao_EXE,
  908 + strNomeAgente : String;
  909 + v_array_NomeAgente : TStrings;
  910 + intAux : integer;
  911 +Begin
  912 + v_array_NomeAgente := explode(p_strNomeAgente,'\');
  913 + intAux := v_array_NomeAgente.Count;
  914 + // V: 2.2.0.16
  915 + // Verifico existência do arquivo "versoes_agentes.ini" para comparação das versões dos agentes principais
  916 + if FileExists(ExtractFilePath(Application.Exename)+'versoes_agentes.ini') then
  917 + if (GetValorChaveRegIni('versoes_agentes',v_array_NomeAgente[intAux-1],ExtractFilePath(Application.Exename)+'versoes_agentes.ini')<>'') then
  918 + Begin
  919 + v_versao_INI := GetValorChaveRegIni('versoes_agentes',v_array_NomeAgente[intAux-1],ExtractFilePath(Application.Exename)+'versoes_agentes.ini');
  920 + v_versao_EXE := GetVersionInfo(p_strNomeAgente);
  921 + if (v_versao_INI = v_versao_EXE) then
  922 + Result := 1
  923 + else
  924 + Result := 2;
  925 + End
  926 + else
  927 + Result := 0;
  928 +End;
  929 +// Dica baixada de http://procedure.blig.ig.com.br/
  930 +// Adaptada por Anderson Peterle - v:2.2.0.16 - 03/2007
  931 +procedure Matar(v_dir,v_files: string);
  932 +var SearchRec: TSearchRec;
  933 + Result: Integer;
  934 +begin
  935 + Result:=FindFirst(v_dir+v_files, faAnyFile, SearchRec);
  936 + while result=0 do
  937 + begin
  938 + log_diario('Excluindo: '+v_dir + SearchRec.Name);
  939 + if DeleteFile(v_dir+'\'+SearchRec.Name) then
  940 + log_diario('Exclusão de ' + v_dir + '\' + SearchRec.Name + ' efetuada com sucesso!')
  941 + else
  942 + Begin
  943 + log_diario('Exclusão não efetuada! Provavelmente já esteja sendo executado...');
  944 + log_diario('Tentarei finalizar Tarefa/Processo...');
  945 + if (GetWinVer <= 5) then // Até
  946 + KillTask(SearchRec.Name)
  947 + else
  948 + KillProcess(FindWindow(PChar(SearchRec.Name),nil));
  949 +
  950 + if DeleteFile(v_dir+'\'+SearchRec.Name) then
  951 + log_diario('Exclusão Impossibilitada de ' + v_dir + '\' + SearchRec.Name + '!');
  952 + End;
  953 +
  954 + Result:=FindNext(SearchRec);
  955 + end;
  956 +end;
  957 +
852 procedure chkcacic; 958 procedure chkcacic;
853 var bool_download_CACIC2, 959 var bool_download_CACIC2,
854 bool_download_GER_COLS, 960 bool_download_GER_COLS,
855 bool_configura, 961 bool_configura,
856 - bool_ExistsAutoRun : boolean; 962 + bool_ExistsAutoRun,
  963 + bool_CommandLine : boolean;
857 964
858 v_te_serv_updates, 965 v_te_serv_updates,
859 v_nu_porta_serv_updates, 966 v_nu_porta_serv_updates,
@@ -862,7 +969,8 @@ var bool_download_CACIC2, @@ -862,7 +969,8 @@ var bool_download_CACIC2,
862 v_te_path_serv_updates, 969 v_te_path_serv_updates,
863 v_te_texto_janela_instalacao, 970 v_te_texto_janela_instalacao,
864 v_modulos, 971 v_modulos,
865 - v_retorno : String; 972 + v_retorno,
  973 + strAux : String;
866 974
867 Request_Config : TStringList; 975 Request_Config : TStringList;
868 v_array_modulos : TStrings; 976 v_array_modulos : TStrings;
@@ -870,31 +978,60 @@ var bool_download_CACIC2, @@ -870,31 +978,60 @@ var bool_download_CACIC2,
870 IdHTTP1: TIdHTTP; 978 IdHTTP1: TIdHTTP;
871 intAux : integer; 979 intAux : integer;
872 begin 980 begin
  981 + v_te_instala_frase_sucesso := 'INSTALAÇÃO/ATUALIZAÇÃO EFETUADA COM SUCESSO!';
  982 + v_te_instala_frase_insucesso := '***** INSTALAÇÃO/ATUALIZAÇÃO NÃO EFETUADA COM SUCESSO *****';
  983 + bool_CommandLine := false;
  984 +
873 Try 985 Try
874 v_home_drive := MidStr(HomeDrive,1,3); //x:\ 986 v_home_drive := MidStr(HomeDrive,1,3); //x:\
875 987
876 - If not (FileExists(ExtractFilePath(Application.Exename) + '\chkcacic.ini')) then  
877 - Begin  
878 - log_diario('Abrindo formulário de configurações');  
879 - CriaFormConfigura;  
880 - MostraFormConfigura;  
881 - End; 988 + // 2.2.0.17 - Tratamento de opções passados em linha de comando
  989 + // Grande dica do grande Cláudio Filho (OpenOffice.org)
  990 + if (ParamCount > 0) then
  991 + Begin
  992 + For intAux := 1 to ParamCount do
  993 + Begin
  994 + if LowerCase(Copy(ParamStr(intAux),1,6)) = '/serv=' then
  995 + begin
  996 + strAux := Trim(Copy(ParamStr(intAux),7,Length((ParamStr(intAux)))));
  997 + v_ip_serv_cacic := Trim(Copy(strAux,0,Pos('/', strAux) - 1));
  998 + If v_ip_serv_cacic = '' Then v_ip_serv_cacic := strAux;
  999 + end;
  1000 + if LowerCase(Copy(ParamStr(intAux),1,5)) = '/dir=' then
  1001 + begin
  1002 + strAux := Trim(Copy(ParamStr(intAux),6,Length((ParamStr(intAux)))));
  1003 + v_cacic_dir := Trim(Copy(strAux,0,Pos('/', strAux) - 1));
  1004 + If v_cacic_dir = '' Then v_cacic_dir := strAux;
  1005 + end;
  1006 +
  1007 + end;
  1008 + if not(v_ip_serv_cacic='') and
  1009 + not(v_cacic_dir='')then
  1010 + bool_CommandLine := true;
  1011 + End;
  1012 +
  1013 + if not bool_CommandLine then
  1014 + Begin
  1015 + If not (FileExists(ExtractFilePath(Application.Exename) + '\chkcacic.ini')) then
  1016 + Begin
  1017 + log_diario('Abrindo formulário de configurações');
  1018 + CriaFormConfigura;
  1019 + MostraFormConfigura;
  1020 + End;
  1021 +
  1022 + bool_download_CACIC2 := false;
  1023 + bool_download_GER_COLS := false;
  1024 + v_ip_serv_cacic := GetValorChaveRegIni('Cacic2', 'ip_serv_cacic' , ExtractFilePath(Application.Exename) + '\chkcacic.ini');
  1025 + v_cacic_dir := GetValorChaveRegIni('Cacic2', 'cacic_dir' , ExtractFilePath(Application.Exename) + '\chkcacic.ini');
  1026 + v_exibe_informacoes := GetValorChaveRegIni('Cacic2', 'exibe_informacoes', ExtractFilePath(Application.Exename) + '\chkcacic.ini');
  1027 + v_te_instala_informacoes_extras := StringReplace(GetValorChaveRegIni('Cacic2', 'te_instala_informacoes_extras', ExtractFilePath(Application.Exename) + '\chkcacic.ini'),'*13*10',#13#10,[rfReplaceAll]);
  1028 + End;
882 1029
883 - bool_download_CACIC2 := false;  
884 - bool_download_GER_COLS := false;  
885 - v_ip_serv_cacic := GetValorChaveRegIni('Cacic2', 'ip_serv_cacic', ExtractFilePath(Application.Exename) + '\chkcacic.ini');  
886 - v_cacic_dir := GetValorChaveRegIni('Cacic2', 'cacic_dir', ExtractFilePath(Application.Exename) + '\chkcacic.ini');  
887 - v_rem_cacic_v0x := GetValorChaveRegIni('Cacic2', 'rem_cacic_v0x', ExtractFilePath(Application.Exename) + '\chkcacic.ini');  
888 - v_te_instala_frase_sucesso := GetValorChaveRegIni('Cacic2', 'te_instala_frase_sucesso', ExtractFilePath(Application.Exename) + '\chkcacic.ini');  
889 - v_te_instala_frase_insucesso := GetValorChaveRegIni('Cacic2', 'te_instala_frase_insucesso', ExtractFilePath(Application.Exename) + '\chkcacic.ini');  
890 - v_te_instala_informacoes_extras := StringReplace(GetValorChaveRegIni('Cacic2', 'te_instala_informacoes_extras', ExtractFilePath(Application.Exename) + '\chkcacic.ini'),'*13*10',#13#10,[rfReplaceAll]);  
891 Dir := v_home_drive + v_cacic_dir; // Ex.: c:\cacic\ 1030 Dir := v_home_drive + v_cacic_dir; // Ex.: c:\cacic\
892 1031
893 // Verifico se o S.O. é NT Like e se o Usuário está com privilégio administrativo... 1032 // Verifico se o S.O. é NT Like e se o Usuário está com privilégio administrativo...
894 if (GetWinVer >= 6) and 1033 if (GetWinVer >= 6) and
895 - not (v_te_instala_frase_sucesso +  
896 - v_te_instala_frase_insucesso +  
897 - v_te_instala_informacoes_extras = '') and 1034 + (v_exibe_informacoes = 'S') and
898 not IsAdmin then // Se NT/2000/XP/... 1035 not IsAdmin then // Se NT/2000/XP/...
899 Begin 1036 Begin
900 MessageDLG(#13#10+'ATENÇÃO! Essa aplicação requer execução com nível administrativo.',mtError,[mbOK],0); 1037 MessageDLG(#13#10+'ATENÇÃO! Essa aplicação requer execução com nível administrativo.',mtError,[mbOK],0);
@@ -938,15 +1075,18 @@ begin @@ -938,15 +1075,18 @@ begin
938 1075
939 1076
940 if (ParamCount > 0) and (LowerCase(Copy(ParamStr(1),1,7)) = '/config') then bool_configura := true; 1077 if (ParamCount > 0) and (LowerCase(Copy(ParamStr(1),1,7)) = '/config') then bool_configura := true;
941 - while (v_ip_serv_cacic = '') or (v_cacic_dir = '') or (v_rem_cacic_v0x = '') or bool_configura do 1078 +
  1079 + while (v_ip_serv_cacic = '') or (v_cacic_dir = '') or bool_configura do
942 Begin 1080 Begin
943 log_diario('Abrindo formulário de configurações'); 1081 log_diario('Abrindo formulário de configurações');
944 bool_configura := false; 1082 bool_configura := false;
945 CriaFormConfigura; 1083 CriaFormConfigura;
946 Configs.Edit_ip_serv_cacic.text := v_ip_serv_cacic; 1084 Configs.Edit_ip_serv_cacic.text := v_ip_serv_cacic;
947 Configs.Edit_cacic_dir.text := v_cacic_dir; 1085 Configs.Edit_cacic_dir.text := v_cacic_dir;
948 - Configs.Edit_te_instala_frase_sucesso.text := v_te_instala_frase_sucesso;  
949 - Configs.Edit_te_instala_frase_insucesso.text := v_te_instala_frase_insucesso; 1086 + if v_exibe_informacoes = 'S' then
  1087 + Configs.ckboxExibeInformacoes.Checked := true
  1088 + else
  1089 + Configs.ckboxExibeInformacoes.Checked := false;
950 Configs.Memo_te_instala_informacoes_extras.text := v_te_instala_informacoes_extras; 1090 Configs.Memo_te_instala_informacoes_extras.text := v_te_instala_informacoes_extras;
951 MostraFormConfigura; 1091 MostraFormConfigura;
952 End; 1092 End;
@@ -954,8 +1094,8 @@ begin @@ -954,8 +1094,8 @@ begin
954 if (ParamCount > 0) and (LowerCase(Copy(ParamStr(1),1,7)) = '/config') then application.Terminate; 1094 if (ParamCount > 0) and (LowerCase(Copy(ParamStr(1),1,7)) = '/config') then application.Terminate;
955 1095
956 // Caso o parâmetro rem_cacic_v0x seja "S/s" removo a chave/valor de execução do Cacic antigo 1096 // Caso o parâmetro rem_cacic_v0x seja "S/s" removo a chave/valor de execução do Cacic antigo
957 - if (LowerCase(v_rem_cacic_v0x)='s') then  
958 - DelValorReg('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic'); 1097 + //if (LowerCase(v_rem_cacic_v0x)='s') then
  1098 + // DelValorReg('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic');
959 1099
960 // Verifico a existência do diretório configurado para o Cacic, normalmente CACIC 1100 // Verifico a existência do diretório configurado para o Cacic, normalmente CACIC
961 if not DirectoryExists(Dir) then 1101 if not DirectoryExists(Dir) then
@@ -967,6 +1107,8 @@ begin @@ -967,6 +1107,8 @@ begin
967 // Para eliminar versão 20014 e anteriores que provavelmente não fazem corretamente o AutoUpdate 1107 // Para eliminar versão 20014 e anteriores que provavelmente não fazem corretamente o AutoUpdate
968 if not DirectoryExists(Dir+'\modulos') then 1108 if not DirectoryExists(Dir+'\modulos') then
969 begin 1109 begin
  1110 + Matar(Dir, '\cacic2.exe');
  1111 + {
970 if DeleteFile(Dir + '\cacic2.exe') then 1112 if DeleteFile(Dir + '\cacic2.exe') then
971 log_diario('Exclusão de '+Dir + '\cacic2.exe' + ' efetuada com sucesso!') 1113 log_diario('Exclusão de '+Dir + '\cacic2.exe' + ' efetuada com sucesso!')
972 else 1114 else
@@ -980,7 +1122,7 @@ begin @@ -980,7 +1122,7 @@ begin
980 if DeleteFile(Dir + '\cacic2.exe') then 1122 if DeleteFile(Dir + '\cacic2.exe') then
981 log_diario('Exclusão Impossibilitada de '+Dir + '\cacic2.exe' + '!'); 1123 log_diario('Exclusão Impossibilitada de '+Dir + '\cacic2.exe' + '!');
982 End; 1124 End;
983 - 1125 + }
984 ForceDirectories(Dir + '\modulos'); 1126 ForceDirectories(Dir + '\modulos');
985 log_diario('Criando pasta '+Dir+'\modulos'); 1127 log_diario('Criando pasta '+Dir+'\modulos');
986 end; 1128 end;
@@ -1042,6 +1184,8 @@ begin @@ -1042,6 +1184,8 @@ begin
1042 log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); 1184 log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
1043 Except 1185 Except
1044 Begin 1186 Begin
  1187 + if v_exibe_informacoes = 'S' then
  1188 + 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);
1045 log_diario('**********************************************************'); 1189 log_diario('**********************************************************');
1046 log_diario('Oops! Não Foi Possível Comunicar com o Módulo Gerente WEB!'); 1190 log_diario('Oops! Não Foi Possível Comunicar com o Módulo Gerente WEB!');
1047 log_diario('**********************************************************'); 1191 log_diario('**********************************************************');
@@ -1050,104 +1194,79 @@ begin @@ -1050,104 +1194,79 @@ begin
1050 Request_Config.Free; 1194 Request_Config.Free;
1051 Response_Config.Free; 1195 Response_Config.Free;
1052 1196
1053 - // Verificação de versão do cacic2.exe e exclusão em caso de versão antiga 1197 + // Verificação de versão do cacic2.exe e exclusão em caso de versão antiga/diferente da atual
1054 If (FileExists(Dir + '\cacic2.exe')) Then 1198 If (FileExists(Dir + '\cacic2.exe')) Then
1055 Begin 1199 Begin
1056 - v_versao_local := trim(GetVersionInfo(Dir + '\cacic2.exe'));  
1057 - v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);  
1058 -  
1059 - v_versao_remota_inteira := XML_RetornaValor('CACIC2' , v_retorno);  
1060 - v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4); 1200 + intAux := ChecaVersoesAgentes(Dir + '\cacic2.exe');
  1201 + // 0 => Arquivo de versões inexistente
  1202 + // 1 => Versões iguais
  1203 + // 2 => Versões diferentes
  1204 + if (intAux = 0) then
  1205 + Begin
  1206 + v_versao_local := trim(GetVersionInfo(Dir + '\cacic2.exe'));
  1207 + v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);
1061 1208
1062 - if not (v_versao_remota_inteira = '') then  
1063 - log_diario('Versão remota de "cacic2.exe": '+v_versao_remota_capada + '('+v_versao_remota_inteira+')'); 1209 + v_versao_remota_inteira := XML_RetornaValor('CACIC2' , v_retorno);
  1210 + v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4);
1064 1211
1065 - if (v_versao_local ='0000') or // Provavelmente versão muito antiga ou corrompida  
1066 - (v_versao_local ='2208') or  
1067 - (v_versao_local <> v_versao_remota_capada) then  
1068 - Begin  
1069 - log_diario('Excluindo versão "'+v_versao_local+'" de Cacic2.exe');  
1070 - if DeleteFile(Dir + '\cacic2.exe') then  
1071 - log_diario('Exclusão de '+Dir + '\cacic2.exe'+' efetuada com sucesso!')  
1072 - else  
1073 - Begin  
1074 - log_diario('Exclusão não efetuada! Provavelmente já esteja sendo executado...');  
1075 - log_diario('Tentarei finalizar Tarefa/Processo...');  
1076 - if (GetWinVer <= 5) then // Até  
1077 - KillTask('cacic2.exe')  
1078 - else  
1079 - KillProcess(FindWindow('cacic2.exe',nil));  
1080 - if DeleteFile(Dir + '\cacic2.exe') then  
1081 - log_diario('Exclusão Impossibilitada de '+Dir + '\cacic2.exe' + '!');  
1082 - End; 1212 + if not (v_versao_remota_inteira = '') then
  1213 + log_diario('Versão remota de "cacic2.exe": '+v_versao_remota_capada + '('+v_versao_remota_inteira+')');
1083 End; 1214 End;
  1215 +
  1216 + if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"...
  1217 + (v_versao_local ='0000') or // Provavelmente versão muito antiga ou corrompida
  1218 + (v_versao_local ='2208') then
  1219 + Matar(Dir, '\cacic2.exe');
1084 End; 1220 End;
1085 1221
1086 - // Verificação de versão do ger_cols.exe e exclusão em caso de versão antiga 1222 + // Verificação de versão do ger_cols.exe e exclusão em caso de versão antiga/diferente da atual
1087 If (FileExists(Dir + '\modulos\ger_cols.exe')) Then 1223 If (FileExists(Dir + '\modulos\ger_cols.exe')) Then
1088 - Begin  
1089 - v_versao_local := trim(GetVersionInfo(Dir + '\modulos\ger_cols.exe'));  
1090 - v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]); 1224 + Begin
  1225 + intAux := ChecaVersoesAgentes(Dir + '\cacic2.exe');
  1226 + // 0 => Arquivo de versões inexistente
  1227 + // 1 => Versões iguais
  1228 + // 2 => Versões diferentes
  1229 + if (intAux = 0) then
  1230 + Begin
  1231 + v_versao_local := trim(GetVersionInfo(Dir + '\modulos\ger_cols.exe'));
  1232 + v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);
1091 1233
1092 - v_versao_remota_inteira := XML_RetornaValor('GER_COLS' , v_retorno);  
1093 - v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4); 1234 + v_versao_remota_inteira := XML_RetornaValor('GER_COLS' , v_retorno);
  1235 + v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4);
1094 1236
1095 - if not (v_versao_remota_inteira = '') then  
1096 - log_diario('Versão remota de "ger_cols.exe": '+v_versao_remota_capada+ '('+v_versao_remota_inteira+')'); 1237 + if not (v_versao_remota_inteira = '') then
  1238 + log_diario('Versão remota de "ger_cols.exe": '+v_versao_remota_capada+ '('+v_versao_remota_inteira+')');
  1239 + End;
1097 1240
1098 - if (v_versao_local ='0000') or // Provavelmente versão muito antiga ou corrompida  
1099 - (v_versao_local <> v_versao_remota_capada) then  
1100 - Begin  
1101 - log_diario('Excluindo versão "'+v_versao_local+'" de Ger_Cols.exe');  
1102 - if DeleteFile(Dir + '\modulos\ger_cols.exe') then  
1103 - log_diario('Exclusão de '+Dir + '\modulos\ger_cols.exe'+' efetuada com sucesso!')  
1104 - else  
1105 - Begin  
1106 - log_diario('Exclusão não efetuada! Provavelmente já esteja sendo executado...');  
1107 - log_diario('Tentarei finalizar Tarefa/Processo...');  
1108 - if (GetWinVer <= 5) then // Até  
1109 - KillTask('ger_cols.exe')  
1110 - else  
1111 - KillProcess(FindWindow('ger_cols.exe',nil));  
1112 - if DeleteFile(Dir + '\modulos\ger_cols.exe') then  
1113 - log_diario('Exclusão Impossibilitada de '+Dir + '\modulos\ger_cols.exe' + '!');  
1114 - End;  
1115 - End;  
1116 - End; 1241 + if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"...
  1242 + (v_versao_local ='0000') then // Provavelmente versão muito antiga ou corrompida
  1243 + Matar(Dir + '\modulos\', 'ger_cols.exe');
  1244 + End;
1117 1245
1118 1246
1119 - // Verificação de versão do chksis.exe e exclusão em caso de versão antiga 1247 + // Verificação de versão do chksis.exe e exclusão em caso de versão antiga/diferente da atual
1120 If (FileExists(HomeDrive + '\chksis.exe')) Then 1248 If (FileExists(HomeDrive + '\chksis.exe')) Then
1121 - Begin  
1122 - v_versao_local := trim(GetVersionInfo(HomeDrive + '\chksis.exe'));  
1123 - v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);  
1124 -  
1125 - v_versao_remota_inteira := XML_RetornaValor('CHKSIS' , v_retorno);  
1126 - v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4); 1249 + Begin
  1250 + intAux := ChecaVersoesAgentes(HomeDrive + '\chksis.exe');
  1251 + // 0 => Arquivo de versões inexistente
  1252 + // 1 => Versões iguais
  1253 + // 2 => Versões diferentes
  1254 + if (intAux = 0) then
  1255 + Begin
  1256 + v_versao_local := trim(GetVersionInfo(HomeDrive + '\chksis.exe'));
  1257 + v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);
1127 1258
1128 - if not (v_versao_remota_inteira = '') then  
1129 - log_diario('Versão remota de "chksis.exe": '+v_versao_remota_capada+ '('+v_versao_remota_inteira+')'); 1259 + v_versao_remota_inteira := XML_RetornaValor('CHKSIS' , v_retorno);
  1260 + v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4);
1130 1261
1131 - if (v_versao_local ='0000') or // Provavelmente versão muito antiga ou corrompida  
1132 - (v_versao_local <> v_versao_remota_capada) then  
1133 - Begin  
1134 - log_diario('Excluindo versão "'+v_versao_local+'" de ChkSis.exe');  
1135 - if DeleteFile(HomeDrive + '\chksis.exe') then  
1136 - log_diario('Exclusão de '+HomeDrive + '\chksis.exe'+' efetuada com sucesso!')  
1137 - else  
1138 - Begin  
1139 - log_diario('Exclusão não efetuada! Provavelmente já esteja sendo executado...');  
1140 - log_diario('Tentarei finalizar Tarefa/Processo...');  
1141 - if (GetWinVer <= 5) then // Até  
1142 - KillTask('chksis.exe')  
1143 - else  
1144 - KillProcess(FindWindow('chksis.exe',nil));  
1145 - if DeleteFile(HomeDrive + '\chksis.exe') then  
1146 - log_diario('Exclusão Impossibilitada de '+HomeDrive + '\chksis.exe' + '!');  
1147 - End; 1262 + if not (v_versao_remota_inteira = '') then
  1263 + log_diario('Versão remota de "chksis.exe": '+v_versao_remota_capada+ '('+v_versao_remota_inteira+')');
  1264 + End;
1148 1265
1149 - End;  
1150 - End; 1266 + if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"...
  1267 + (v_versao_local ='0000') then // Provavelmente versão muito antiga ou corrompida
  1268 + Matar(HomeDrive,'chksis.exe');
  1269 + End;
1151 1270
1152 // Tento detectar o ChkSis.EXE e copio ou faço FTP caso não exista 1271 // Tento detectar o ChkSis.EXE e copio ou faço FTP caso não exista
1153 If not FileExists(HomeDrive + '\chksis.exe') Then 1272 If not FileExists(HomeDrive + '\chksis.exe') Then
@@ -1160,14 +1279,15 @@ begin @@ -1160,14 +1279,15 @@ begin
1160 End 1279 End
1161 else 1280 else
1162 Begin 1281 Begin
  1282 + if not FTP(v_te_serv_updates,
  1283 + v_nu_porta_serv_updates,
  1284 + v_nm_usuario_login_serv_updates,
  1285 + v_te_senha_login_serv_updates,
  1286 + v_te_path_serv_updates,
  1287 + 'chksis.exe',
  1288 + HomeDrive) and (v_exibe_informacoes = 'S') then
  1289 + MessageDLG(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+HomeDrive + '\chksis.exe".'+#13#10+'Verifique o Servidor de Updates.',mtError,[mbOK],0);
1163 1290
1164 - FTP(v_te_serv_updates,  
1165 - v_nu_porta_serv_updates,  
1166 - v_nm_usuario_login_serv_updates,  
1167 - v_te_senha_login_serv_updates,  
1168 - v_te_path_serv_updates,  
1169 - 'chksis.exe',  
1170 - HomeDrive);  
1171 If not FileExists(HomeDrive + '\chksis.exe') Then 1291 If not FileExists(HomeDrive + '\chksis.exe') Then
1172 Begin 1292 Begin
1173 log_diario('Problemas Efetuando Download de ChkSis.exe(FTP):'); 1293 log_diario('Problemas Efetuando Download de ChkSis.exe(FTP):');
@@ -1212,13 +1332,14 @@ begin @@ -1212,13 +1332,14 @@ begin
1212 End 1332 End
1213 else 1333 else
1214 begin 1334 begin
1215 - FTP(v_te_serv_updates,  
1216 - v_nu_porta_serv_updates,  
1217 - v_nm_usuario_login_serv_updates,  
1218 - v_te_senha_login_serv_updates,  
1219 - v_te_path_serv_updates,  
1220 - 'cacic2.exe',  
1221 - Dir); 1335 + if not FTP(v_te_serv_updates,
  1336 + v_nu_porta_serv_updates,
  1337 + v_nm_usuario_login_serv_updates,
  1338 + v_te_senha_login_serv_updates,
  1339 + v_te_path_serv_updates,
  1340 + 'cacic2.exe',
  1341 + Dir) and (v_exibe_informacoes = 'S') then
  1342 + MessageDLG(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+Dir + '\cacic2.exe".'+#13#10+'Verifique o Servidor de Updates.',mtError,[mbOK],0);
1222 1343
1223 bool_download_CACIC2 := true; 1344 bool_download_CACIC2 := true;
1224 1345
@@ -1248,13 +1369,14 @@ begin @@ -1248,13 +1369,14 @@ begin
1248 End 1369 End
1249 else 1370 else
1250 begin 1371 begin
1251 - FTP(v_te_serv_updates,  
1252 - v_nu_porta_serv_updates,  
1253 - v_nm_usuario_login_serv_updates,  
1254 - v_te_senha_login_serv_updates,  
1255 - v_te_path_serv_updates,  
1256 - 'ger_cols.exe',  
1257 - Dir + '\modulos'); 1372 + if not FTP(v_te_serv_updates,
  1373 + v_nu_porta_serv_updates,
  1374 + v_nm_usuario_login_serv_updates,
  1375 + v_te_senha_login_serv_updates,
  1376 + v_te_path_serv_updates,
  1377 + 'ger_cols.exe',
  1378 + Dir + '\modulos') and (v_exibe_informacoes = 'S') then
  1379 + MessageDLG(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+Dir + '\modulos\ger_cols.exe".'+#13#10+'Verifique o Servidor de Updates.',mtError,[mbOK],0);
1258 1380
1259 bool_download_GER_COLS := true; 1381 bool_download_GER_COLS := true;
1260 If (not FileExists(Dir + '\modulos\ger_cols.exe')) Then 1382 If (not FileExists(Dir + '\modulos\ger_cols.exe')) Then
@@ -1303,13 +1425,16 @@ begin @@ -1303,13 +1425,16 @@ begin
1303 1425
1304 // Igualo as chaves ip_serv_cacic dos arquivos chksis.ini e cacic2.ini! 1426 // Igualo as chaves ip_serv_cacic dos arquivos chksis.ini e cacic2.ini!
1305 SetValorDatMemoria('Configs.EnderecoServidor', v_ip_serv_cacic); 1427 SetValorDatMemoria('Configs.EnderecoServidor', v_ip_serv_cacic);
1306 - log_diario('Fechando Arquivo de Configurações do CACIC'); 1428 + log_diario('Fechando Arquivo de Configurações do Cacic');
1307 CipherClose(v_DatFileName); 1429 CipherClose(v_DatFileName);
1308 - log_diario('Abrindo Arquivo de Configurações do CHKSIS'); 1430 +
  1431 + log_diario('Abrindo Arquivo de Configurações do ChkSis');
1309 CipherOpen(HomeDrive + '\chksis.dat'); 1432 CipherOpen(HomeDrive + '\chksis.dat');
1310 SetValorDatMemoria('Cacic2.ip_serv_cacic', v_ip_serv_cacic); 1433 SetValorDatMemoria('Cacic2.ip_serv_cacic', v_ip_serv_cacic);
1311 - // SetValorChaveRegIni('Cacic2', 'ip_serv_cacic', v_ip_serv_cacic, HomeDrive + '\chksis.ini');  
1312 - 1434 + CipherClose(HomeDrive + '\chksis.dat');
  1435 + // Volto a gravar o chksis.ini para o difícil caso de leitura por versões antigas
  1436 + SetValorChaveRegIni('Cacic2', 'ip_serv_cacic', v_ip_serv_cacic, HomeDrive + '\chksis.ini');
  1437 + log_diario('Fechando Arquivo de Configurações do ChkSis');
1313 1438
1314 // Se NT/2K/XP... 1439 // Se NT/2K/XP...
1315 // If NT Like... 1440 // If NT Like...
@@ -1344,15 +1469,19 @@ begin @@ -1344,15 +1469,19 @@ begin
1344 v_te_texto_janela_instalacao := v_te_instala_informacoes_extras; 1469 v_te_texto_janela_instalacao := v_te_instala_informacoes_extras;
1345 if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') then 1470 if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') then
1346 Begin 1471 Begin
1347 - if (v_te_instala_frase_sucesso<>'') then  
1348 - Begin  
1349 - MessageDlg(#13#10+#13#10+v_te_instala_frase_sucesso+#13#10+#13#10+v_te_texto_janela_instalacao,mtInformation,[mbok],0);  
1350 - End; 1472 + if (v_exibe_informacoes = 'S') then
  1473 + MessageDlg(#13#10+#13#10+v_te_instala_frase_sucesso+#13#10+#13#10+#13#10 + '======================================================' + #13#10 + v_te_texto_janela_instalacao+ '======================================================',mtInformation,[mbok],0);
1351 End 1474 End
1352 - else if (v_te_instala_frase_insucesso<>'') then  
1353 - MessageDlg(#13#10+#13#10+v_te_instala_frase_insucesso+#13#10+#13#10 + v_te_texto_janela_instalacao,mtInformation,[mbok],0);  
1354 -  
1355 - if not bool_ExistsAutoRun then 1475 + else if (v_exibe_informacoes = 'S') then
  1476 + MessageDlg(#13#10+#13#10+v_te_instala_frase_insucesso+#13#10+#13#10+#13#10 + '======================================================' + #13#10 + v_te_texto_janela_instalacao+ '======================================================',mtInformation,[mbok],0);
  1477 +
  1478 + // Se eu não encontrei a chave de autoexecução ou
  1479 + // Se a unidade origem de chamada ao ChkCacic refere-se a Floppy, CDROM ou Flash
  1480 + // Eu executo o agente principal
  1481 + strAux := DriveType(Copy(ExtractFilePath(Application.Exename),1,1));
  1482 + if not bool_ExistsAutoRun or
  1483 + (not(strAux = 'ERRO') and
  1484 + not(strAux = 'REDE')) then
1356 Begin 1485 Begin
1357 log_diario('Executando '+Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic); 1486 log_diario('Executando '+Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic);
1358 WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE); 1487 WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE);
@@ -1362,7 +1491,7 @@ begin @@ -1362,7 +1491,7 @@ begin
1362 1491
1363 End 1492 End
1364 else 1493 else
1365 - log_diario('ATENÇÃO: A Instalação NÃO Foi Realizada com Sucesso!'); 1494 + log_diario('ATENÇÃO: A Instalação NÃO Foi Realizada com Sucesso ou Atualização Desnecessária!');
1366 End; 1495 End;
1367 Except 1496 Except
1368 log_diario('Falha na instalação'); 1497 log_diario('Falha na instalação');
@@ -1502,7 +1631,7 @@ begin @@ -1502,7 +1631,7 @@ begin
1502 // Set total permissions to local groups 1631 // Set total permissions to local groups
1503 v_FS_Security.SetSecurity; 1632 v_FS_Security.SetSecurity;
1504 end 1633 end
1505 - else Log_diario('File System diferente de "NTFS"'); 1634 + else Log_diario('File System: "' + v_FS_Security.FileSystemName+'" - Ok!');
1506 1635
1507 v_FS_Security.Free; 1636 v_FS_Security.Free;
1508 end; 1637 end;
chkcacic/chkcacic.dof
@@ -115,7 +115,7 @@ AutoIncBuild=0 @@ -115,7 +115,7 @@ AutoIncBuild=0
115 MajorVer=2 115 MajorVer=2
116 MinorVer=2 116 MinorVer=2
117 Release=0 117 Release=0
118 -Build=15 118 +Build=17
119 Debug=0 119 Debug=0
120 PreRelease=0 120 PreRelease=0
121 Special=0 121 Special=0
@@ -126,7 +126,7 @@ CodePage=1252 @@ -126,7 +126,7 @@ CodePage=1252
126 [Version Info Keys] 126 [Version Info Keys]
127 CompanyName=Dataprev-ES 127 CompanyName=Dataprev-ES
128 FileDescription= 128 FileDescription=
129 -FileVersion=2.2.0.15 129 +FileVersion=2.2.0.17
130 InternalName= 130 InternalName=
131 LegalCopyright= 131 LegalCopyright=
132 LegalTrademarks= 132 LegalTrademarks=
chkcacic/chkcacic.res
No preview for this file type
chkcacic/main.dcu
No preview for this file type
chkcacic/main.dfm
1 object Form1: TForm1 1 object Form1: TForm1
2 - Left = 248  
3 - Top = 186 2 + Left = 250
  3 + Top = 187
4 Width = 123 4 Width = 123
5 Height = 157 5 Height = 157
6 Caption = 'chkcacic' 6 Caption = 'chkcacic'