Commit 683da8ded99c65272b9c757641f791416b508ae0

Authored by Adriano Vieira
1 parent bca7e201
Exists in master

- merge de branch (2.4) revisão [709:726]


git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@729 fecfc0c7-e812-0410-ae72-849f08638ee7
CACIC_Library.pas
... ... @@ -23,6 +23,7 @@
23 23 - start with "g" character for global
24 24 - start with "v" character for local
25 25 - start with "p" character for methods parameters
  26 + - start with "P" character for pointers
26 27 - use underscore for better read
27 28 e.g.
28 29 var g_global : string;
... ... @@ -49,6 +50,25 @@ uses
49 50 Windows, SysUtils, StrUtils;
50 51  
51 52 type
  53 +
  54 +{ ------------------------------------------------------------------------------
  55 + Tipo de dados para obter informacoes extendidas dos Sistema Operacional
  56 + ver MSDN: http://msdn.microsoft.com/en-us/library/ms724833(VS.85).aspx
  57 +-------------------------------------------------------------------------------}
  58 + TOSVersionInfoEx = packed record
  59 + dwOSVersionInfoSize: DWORD;
  60 + dwMajorVersion: DWORD;
  61 + dwMinorVersion: DWORD;
  62 + dwBuildNumber: DWORD;
  63 + dwPlatformId: DWORD;
  64 + szCSDVersion: array[0..127] of AnsiChar;
  65 + wServicePackMajor: WORD;
  66 + wServicePackMinor: WORD;
  67 + wSuiteMask: WORD;
  68 + wProductType: Byte;
  69 + wReserved: Byte;
  70 + end;
  71 +
52 72 {*------------------------------------------------------------------------------
53 73 Classe para obter informações do sistema windows
54 74 -------------------------------------------------------------------------------}
... ... @@ -57,7 +77,11 @@ type
57 77  
58 78 protected
59 79 /// Mantem a identificação do sistema operacional
60   - g_osVerInfo: TOSVersionInfo;
  80 + g_osVersionInfo: TOSVersionInfo;
  81 + /// Mantem a identificação extendida do sistema operacional
  82 + g_osVersionInfoEx: TOSVersionInfoEx;
  83 + /// TRUE se houver informação extendida do SO, FALSE caso contrário
  84 + g_osVersionInfoExtended: boolean;
61 85  
62 86 public
63 87 function isWindowsVista() : boolean;
... ... @@ -94,6 +118,7 @@ type
94 118 -------------------------------------------------------------------------------}
95 119 TCACIC = class(TCACIC_Windows)
96 120 constructor Create();
  121 + destructor Destroy; override;
97 122 private
98 123  
99 124 protected
... ... @@ -112,6 +137,8 @@ type
112 137 // Declaração de constantes para a biblioteca
113 138 const CACIC_PROCESS_WAIT = true; // aguardar fim do processo
114 139 const CACIC_PROCESS_NOWAIT = false; // não aguardar o fim do processo
  140 +var
  141 + P_OSVersionInfo: POSVersionInfo;
115 142  
116 143 implementation
117 144  
... ... @@ -123,13 +150,33 @@ implementation
123 150 -------------------------------------------------------------------------------}
124 151 constructor TCACIC.Create();
125 152 begin
126   - Self.g_osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
127   - GetVersionEx(Self.g_osVerInfo);
  153 + FillChar(Self.g_osVersionInfoEx, SizeOf(Self.g_osVersionInfoEx), 0);
  154 + {$TYPEDADDRESS OFF}
  155 + P_OSVersionInfo := @Self.g_osVersionInfoEx;
  156 + {$TYPEDADDRESS ON}
  157 +
  158 + Self.g_osVersionInfoEx.dwOSVersionInfoSize:= SizeOf(TOSVersionInfoEx);
  159 + Self.g_osVersionInfoExtended := GetVersionEx(P_OSVersionInfo^);
  160 + if (not Self.g_osVersionInfoExtended) then begin
  161 + Self.g_osVersionInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
  162 + GetVersionEx(Self.g_osVersionInfo);
  163 + end;
128 164 Self.Windows := TCACIC_Windows.Create();
129 165 Self.Debug := TCACIC_Debug.Create();
130 166 end;
131 167  
132 168 {*------------------------------------------------------------------------------
  169 + Destrutor para a classe
  170 +
  171 + Objetiva finalizar valores usados pelos objetos da classe.
  172 +-------------------------------------------------------------------------------}
  173 +destructor TCACIC.Destroy();
  174 +begin
  175 + FreeMemory(P_OSVersionInfo);
  176 + inherited;
  177 +end;
  178 +
  179 +{*------------------------------------------------------------------------------
133 180 Elimina espacos excedentes na string
134 181  
135 182 @param p_str String a excluir espacos
... ... @@ -219,8 +266,13 @@ end;
219 266 function TCACIC_Windows.isWindowsGEVista() : boolean;
220 267 begin
221 268 Result := false;
222   - if((g_osVerInfo.dwMajorVersion >= 6) and (g_osVerInfo.dwMinorVersion >= 0)) then
223   - Result := true;
  269 + if(Self.g_osVersionInfoExtended) then begin
  270 + if((g_osVersionInfoEx.dwMajorVersion >= 6) and (g_osVersionInfoEx.dwMinorVersion >= 0)) then
  271 + Result := true;
  272 + end
  273 + else
  274 + if((g_osVersionInfo.dwMajorVersion >= 6) and (g_osVersionInfo.dwMinorVersion >= 0)) then
  275 + Result := true;
224 276 end;
225 277  
226 278 {*------------------------------------------------------------------------------
... ... @@ -233,8 +285,13 @@ end;
233 285 function TCACIC_Windows.isWindowsVista() : boolean;
234 286 begin
235 287 Result := false;
236   - if((g_osVerInfo.dwMajorVersion = 6) and (g_osVerInfo.dwMinorVersion = 0)) then
237   - Result := true;
  288 + if(Self.g_osVersionInfoExtended) then begin
  289 + if((g_osVersionInfoEx.dwMajorVersion = 6) and (g_osVersionInfoEx.dwMinorVersion = 0)) then
  290 + Result := true;
  291 + end
  292 + else
  293 + if((g_osVersionInfo.dwMajorVersion = 6) and (g_osVersionInfo.dwMinorVersion = 0)) then
  294 + Result := true;
238 295 end;
239 296  
240 297 {*------------------------------------------------------------------------------
... ... @@ -247,8 +304,13 @@ end;
247 304 function TCACIC_Windows.isWindowsGEXP() : boolean;
248 305 begin
249 306 Result := false;
250   - if((g_osVerInfo.dwMajorVersion >= 5) and (g_osVerInfo.dwMinorVersion >= 1)) then
251   - Result := true;
  307 + if(Self.g_osVersionInfoExtended) then begin
  308 + if((g_osVersionInfoEx.dwMajorVersion >= 5) and (g_osVersionInfoEx.dwMinorVersion >= 1)) then
  309 + Result := true;
  310 + end
  311 + else
  312 + if((g_osVersionInfo.dwMajorVersion >= 5) and (g_osVersionInfo.dwMinorVersion >= 1)) then
  313 + Result := true;
252 314 end;
253 315  
254 316 {*------------------------------------------------------------------------------
... ... @@ -261,8 +323,13 @@ end;
261 323 function TCACIC_Windows.isWindowsXP() : boolean;
262 324 begin
263 325 Result := false;
264   - if((g_osVerInfo.dwMajorVersion = 5) and (g_osVerInfo.dwMinorVersion = 1)) then
265   - Result := true;
  326 + if(Self.g_osVersionInfoExtended) then begin
  327 + if((g_osVersionInfoEx.dwMajorVersion = 5) and (g_osVersionInfoEx.dwMinorVersion = 1)) then
  328 + Result := true;
  329 + end
  330 + else
  331 + if((g_osVersionInfo.dwMajorVersion = 5) and (g_osVersionInfo.dwMinorVersion = 1)) then
  332 + Result := true;
266 333 end;
267 334  
268 335 {*------------------------------------------------------------------------------
... ... @@ -275,8 +342,13 @@ end;
275 342 function TCACIC_Windows.isWindows2000() : boolean;
276 343 begin
277 344 Result := false;
278   - if((g_osVerInfo.dwMajorVersion = 5) and (g_osVerInfo.dwMinorVersion = 0)) then
279   - Result := true;
  345 + if(Self.g_osVersionInfoExtended) then begin
  346 + if((g_osVersionInfoEx.dwMajorVersion = 5) and (g_osVersionInfoEx.dwMinorVersion = 0)) then
  347 + Result := true;
  348 + end
  349 + else
  350 + if((g_osVersionInfo.dwMajorVersion = 5) and (g_osVersionInfo.dwMinorVersion = 0)) then
  351 + Result := true;
280 352 end;
281 353  
282 354 {*------------------------------------------------------------------------------
... ... @@ -289,8 +361,13 @@ end;
289 361 function TCACIC_Windows.isWindowsNT() : boolean;
290 362 begin
291 363 Result := false;
292   - if((g_osVerInfo.dwMajorVersion = 4) and (g_osVerInfo.dwMinorVersion = 0)) then
293   - Result := true;
  364 + if(Self.g_osVersionInfoExtended) then begin
  365 + if((g_osVersionInfoEx.dwMajorVersion = 4) and (g_osVersionInfoEx.dwMinorVersion = 0)) then
  366 + Result := true;
  367 + end
  368 + else
  369 + if((g_osVersionInfo.dwMajorVersion = 4) and (g_osVersionInfo.dwMinorVersion = 0)) then
  370 + Result := true;
294 371 end;
295 372  
296 373 {*------------------------------------------------------------------------------
... ... @@ -302,7 +379,10 @@ end;
302 379 -------------------------------------------------------------------------------}
303 380 function TCACIC_Windows.isWindows9xME() : boolean;
304 381 begin
305   - Result := (Self.g_osVerInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS);
  382 + if (Self.g_osVersionInfoExtended) then
  383 + Result := (Self.g_osVersionInfoEx.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS)
  384 + else
  385 + Result := (Self.g_osVersionInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS);
306 386 end;
307 387  
308 388 {*------------------------------------------------------------------------------
... ... @@ -312,13 +392,35 @@ end;
312 392 @example 1.4.10.A
313 393 -------------------------------------------------------------------------------}
314 394 function TCACIC_Windows.getWindowsStrId() : string;
  395 +var
  396 + v_version_id: string;
315 397 begin
316   - Result := IntToStr(Self.g_osVerInfo.dwPlatformId) + '.' +
317   - IntToStr(Self.g_osVerInfo.dwMajorVersion) + '.' +
318   - IntToStr(Self.g_osVerInfo.dwMinorVersion) +
319   - ifThen(trim(Self.g_osVerInfo.szCSDVersion)='',
320   - '',
321   - '.'+Self.g_osVerInfo.szCSDVersion);
  398 + v_version_id := 'S.O.unknown';
  399 + try
  400 + if (Self.g_osVersionInfoExtended) then
  401 + if(Self.isWindows9xME) then
  402 + v_version_id := IntToStr(Self.g_osVersionInfoEx.dwPlatformId) + '.' +
  403 + IntToStr(Self.g_osVersionInfoEx.dwMajorVersion) + '.' +
  404 + IntToStr(Self.g_osVersionInfoEx.dwMinorVersion) +
  405 + ifThen(trim(Self.g_osVersionInfoEx.szCSDVersion)='',
  406 + '',
  407 + '.'+trim(Self.g_osVersionInfoEx.szCSDVersion))
  408 + else
  409 + v_version_id := IntToStr(Self.g_osVersionInfoEx.dwPlatformId) + '.' +
  410 + IntToStr(Self.g_osVersionInfoEx.dwMajorVersion) + '.' +
  411 + IntToStr(Self.g_osVersionInfoEx.dwMinorVersion) + '.' +
  412 + IntToStr(Self.g_osVersionInfoEx.wProductType) + '.' +
  413 + IntToStr(Self.g_osVersionInfoEx.wSuiteMask)
  414 + else
  415 + v_version_id := IntToStr(Self.g_osVersionInfo.dwPlatformId) + '.' +
  416 + IntToStr(Self.g_osVersionInfo.dwMajorVersion) + '.' +
  417 + IntToStr(Self.g_osVersionInfo.dwMinorVersion) +
  418 + ifThen(trim(Self.g_osVersionInfo.szCSDVersion)='',
  419 + '',
  420 + '.'+trim(Self.g_osVersionInfo.szCSDVersion));
  421 + except
  422 + end;
  423 + Result := v_version_id;
322 424  
323 425 end;
324 426  
... ... @@ -330,7 +432,9 @@ end;
330 432 -------------------------------------------------------------------------------}
331 433 function TCACIC_Windows.isWindowsNTPlataform() : boolean;
332 434 begin
333   - Result := (Self.g_osVerInfo.dwPlatformId = VER_PLATFORM_WIN32_NT);
  435 + if(Self.g_osVersionInfoExtended)
  436 + then Result := (Self.g_osVersionInfoEx.dwPlatformId = VER_PLATFORM_WIN32_NT)
  437 + else Result := (Self.g_osVersionInfo.dwPlatformId = VER_PLATFORM_WIN32_NT);
334 438 end;
335 439  
336 440 {*------------------------------------------------------------------------------
... ...
chkcacic/main.pas
... ... @@ -87,7 +87,6 @@ uses Windows,
87 87  
88 88 var v_ip_serv_cacic,
89 89 v_cacic_dir,
90   -// v_rem_cacic_v0x,
91 90 v_te_instala_frase_sucesso,
92 91 v_te_instala_frase_insucesso,
93 92 v_te_instala_informacoes_extras,
... ... @@ -105,7 +104,6 @@ var v_ip_serv_cacic,
105 104 v_versao_LOC,
106 105 v_te_so : String;
107 106  
108   - intWinVer : integer;
109 107 v_Debugs : boolean;
110 108  
111 109 var v_tstrCipherOpened : TStrings;
... ... @@ -135,7 +133,6 @@ procedure LogDiario(strMsg : String);
135 133 procedure Matar(v_dir,v_files: string); // 2.2.0.16
136 134 Procedure MostraFormConfigura;
137 135  
138   -function abstraiCSD(p_te_so : String) : integer;
139 136 Function ChecaVersoesAgentes(p_strNomeAgente : String) : integer; // 2.2.0.16
140 137 Function Explode(Texto, Separador : String) : TStrings;
141 138 Function FindWindowByTitle(WindowTitle: string): Hwnd;
... ... @@ -147,7 +144,6 @@ Function GetRootKey(strRootKey: String): HKEY;
147 144 Function GetValorChaveRegEdit(Chave: String): Variant;
148 145 Function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String;
149 146 Function GetVersionInfo(p_File: string):string;
150   -Function GetWinVer: Integer;
151 147 Function HomeDrive : string;
152 148 Function KillTask(ExeFileName: string): Integer;
153 149 Function ListFileDir(Path: string):string;
... ... @@ -175,83 +171,7 @@ implementation
175 171 uses FormConfig;
176 172  
177 173 {$R *.dfm}
178   -function GetWinVer: Integer;
179   -const
180   - { operating system (OS)constants }
181   - cOsUnknown = 0;
182   - cOsWin95 = 1;
183   - cOsWin95OSR2 = 2; // Não implementado.
184   - cOsWin98 = 3;
185   - cOsWin98SE = 4;
186   - cOsWinME = 5;
187   - cOsWinNT = 6;
188   - cOsWin2000 = 7;
189   - cOsXP = 8;
190   - cOsServer2003 = 13;
191   -var
192   - osVerInfo: TOSVersionInfo;
193   - platformID,
194   - majorVer,
195   - minorVer: Integer;
196   - CSDVersion : String;
197   -begin
198   - Result := cOsUnknown;
199   - { set operating system type flag }
200   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
201   - if GetVersionEx(osVerInfo) then
202   - begin
203   - platformId := osVerInfo.dwPlatformId;
204   - majorVer := osVerInfo.dwMajorVersion;
205   - minorVer := osVerInfo.dwMinorVersion;
206   - CSDVersion := trim(osVerInfo.szCSDVersion);
207   -
208   - case osVerInfo.dwPlatformId of
209   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
210   - begin
211   - if majorVer <= 4 then
212   - Result := cOsWinNT
213   - else if (majorVer = 5) and (minorVer = 0) then
214   - Result := cOsWin2000
215   - else if (majorVer = 5) and (minorVer = 1) then
216   - Result := cOsXP
217   - else if (majorVer = 5) and (minorVer = 2) then
218   - Result := cOsServer2003
219   - else
220   - Result := cOsUnknown;
221   - end;
222   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
223   - begin
224   - if (majorVer = 4) and (minorVer = 0) then
225   - Result := cOsWin95
226   - else if (majorVer = 4) and (minorVer = 10) then
227   - begin
228   - if osVerInfo.szCSDVersion[1] = 'A' then
229   - Result := cOsWin98SE
230   - else
231   - Result := cOsWin98;
232   - end
233   - else if (majorVer = 4) and (minorVer = 90) then
234   - Result := cOsWinME
235   - else
236   - Result := cOsUnknown;
237   - end;
238   - else
239   - Result := cOsUnknown;
240   - end;
241   - end
242   - else
243   - Result := cOsUnknown;
244   -
245   - // A partir da versão 2.2.0.24, defino o valor da ID Interna e atribuo-a sem o CSDVersion à versão externa
246   - v_te_so := IntToStr(platformId) + '.' +
247   - IntToStr(majorVer) + '.' +
248   - IntToStr(minorVer) +
249   - IfThen(CSDVersion='','','.'+CSDVersion);
250   - if (Result = 0) then
251   - Result := abstraiCSD(v_te_so);
252 174  
253   - LogDebug('GetWinVer => ID_interna: '+ v_te_so + ' ID_Externa: ' + IntToStr(Result));
254   -end;
255 175 function GetNetworkUserName : String;
256 176 // Gets the name of the user currently logged into the network on
257 177 // the local PC
... ... @@ -360,7 +280,6 @@ begin
360 280 CloseFile(HistoricoLog); {Fecha o arquivo texto}
361 281 except
362 282 //Erro na gravação do log!
363   - //Application.Terminate;
364 283 end;
365 284 end;
366 285  
... ... @@ -368,10 +287,6 @@ procedure LogDebug(p_msg:string);
368 287 Begin
369 288 if v_Debugs then
370 289 Begin
371   -
372   - //if FileExists(Dir + '\Temp\Debugs\show.txt') then
373   - // ShowMessage('DEBUG - '+p_msg);
374   -
375 290 LogDiario('(v.'+getVersionInfo(ParamStr(0))+') DEBUG - '+p_msg);
376 291 End;
377 292 End;
... ... @@ -525,7 +440,7 @@ begin
525 440 if (trim(v_strCipherOpened)<>'') then
526 441 Result := explode(v_strCipherOpened,v_SeparatorKey)
527 442 else
528   - Result := explode('Configs.ID_SO'+v_SeparatorKey+inttostr(intWinVer)+v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
  443 + Result := explode('Configs.ID_SO'+v_SeparatorKey+ g_oCacic.getWindowsStrId() +v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
529 444  
530 445  
531 446 if Result.Count mod 2 <> 0 then
... ... @@ -564,14 +479,6 @@ end;
564 479  
565 480  
566 481  
567   -function abstraiCSD(p_te_so : String) : integer;
568   - var tstrTe_so : tstrings;
569   - Begin
570   - tstrTe_so := Explode(p_te_so, '.');
571   - Result := StrToInt(tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]);
572   - LogDebug('abstraiCSD=> '+ tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]);
573   - End;
574   -
575 482 function GetVersionInfo(p_File: string):string;
576 483 begin
577 484 Form1.PJVersionInfo1.FileName := PChar(p_File);
... ... @@ -1041,31 +948,6 @@ begin
1041 948 End;
1042 949 end;
1043 950  
1044   -{
1045   -// Dica obtida em http://www.webmundi.com/delphi/dfuncaof.asp?SubTipo=Sistema
1046   -Function DriveType(Unidade: String):String;
1047   -Var StrDrive,
1048   - StrDriveType : String;
1049   - intDriveType : Integer;
1050   -begin
1051   - StrDrive := Unidade;
1052   - If StrDrive[Length(StrDrive)] <> '\' Then
1053   - StrDrive := StrDrive + ':\';
1054   -
1055   - intDriveType := GetDriveType(PChar(StrDrive));
1056   - Case intDriveType Of
1057   - 0 : StrDriveType := 'ERRO';
1058   - 1 : StrDriveType := 'ERRO';
1059   - DRIVE_REMOVABLE : StrDriveType := 'FLOPPY';
1060   - DRIVE_FIXED : StrDriveType := 'HD';
1061   - DRIVE_REMOTE : StrDriveType := 'REDE';
1062   - DRIVE_CDROM : StrDriveType := 'CDROM';
1063   - DRIVE_RAMDISK : StrDriveType := 'RAM';
1064   - end;
1065   - Result := StrDriveType;
1066   -End;
1067   -}
1068   -
1069 951 Function ChecaVersoesAgentes(p_strNomeAgente : String) : integer; // 2.2.0.16
1070 952 var strNomeAgente : String;
1071 953 v_array_NomeAgente : TStrings;
... ... @@ -1341,12 +1223,11 @@ begin
1341 1223 End;
1342 1224 End;
1343 1225  
1344   - intWinVer := GetWinVer;
1345   -
1346 1226 // Verifica se o S.O. é NT Like e se o Usuário está com privilégio administrativo...
1347 1227 if (g_oCacic.isWindowsNTPlataform()) and (not g_oCacic.isWindowsAdmin()) then begin // Se NT/2000/XP/...
1348 1228 if (v_exibe_informacoes = 'S') then
1349 1229 MessageDLG(#13#10+'ATENÇÃO! Essa aplicação requer execução com nível administrativo.',mtError,[mbOK],0);
  1230 + LogDiario('Sem Privilégios: Necessário ser administrador "local" da estação');
1350 1231 ComunicaInsucesso('0'); // O indicador "0" (zero) sinalizará falta de privilégio na estação
1351 1232 end
1352 1233 else begin
... ...
chksis/chksis.dpr
... ... @@ -54,10 +54,11 @@ var PJVersionInfo1: TPJVersionInfo;
54 54 v_versao_remota,
55 55 v_retorno,
56 56 v_te_so : String;
57   - intWinVer : integer;
58 57 v_Debugs : Boolean;
59 58 var v_tstrCipherOpened : TStrings;
60 59  
  60 +var g_oCacic : TCACIC;
  61 +
61 62 // Some constants that are dependant on the cipher being used
62 63 // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
63 64 const KeySize = 32; // 32 bytes = 256 bits
... ... @@ -269,14 +270,8 @@ begin
269 270 Append(v_DatFile);
270 271 End;
271 272  
272   - //v_Cipher := TDCP_rijndael.Create(nil);
273   - //v_Cipher.InitStr(v_CipherKey,TDCP_md5);
274 273 v_strCipherOpenImploded := Implode(v_tstrCipherOpened,v_SeparatorKey);
275 274 v_strCipherClosed := EnCrypt(v_strCipherOpenImploded);
276   - //log_diario('Finalizando o Arquivo de Configurações com criptografia de: '+v_strCipherOpenImploded,ExtractFilePath(ParamStr(0)));
277   - //v_strCipherClosed := v_Cipher.EncryptString(v_strCipherOpenImploded);
278   - //v_Cipher.Burn;
279   - //v_Cipher.Free;
280 275  
281 276 Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto}
282 277  
... ... @@ -286,90 +281,6 @@ begin
286 281 end;
287 282 end;
288 283  
289   -function abstraiCSD(p_te_so : String) : integer;
290   - var tstrTe_so : tstrings;
291   - Begin
292   - tstrTe_so := Explode(p_te_so, '.');
293   - Result := StrToInt(tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]);
294   - End;
295   -
296   -function GetWinVer: Integer;
297   -const
298   - { operating system (OS)constants }
299   - cOsUnknown = 0;
300   - cOsWin95 = 1;
301   - cOsWin95OSR2 = 2; // Não implementado.
302   - cOsWin98 = 3;
303   - cOsWin98SE = 4;
304   - cOsWinME = 5;
305   - cOsWinNT = 6;
306   - cOsWin2000 = 7;
307   - cOsXP = 8;
308   - cOsServer2003 = 13;
309   -var
310   - osVerInfo: TOSVersionInfo;
311   - platformID,
312   - majorVer,
313   - minorVer: Integer;
314   - CSDVersion : String;
315   -begin
316   - Result := cOsUnknown;
317   - { set operating system type flag }
318   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
319   - if GetVersionEx(osVerInfo) then
320   - begin
321   - platformId := osVerInfo.dwPlatformId;
322   - majorVer := osVerInfo.dwMajorVersion;
323   - minorVer := osVerInfo.dwMinorVersion;
324   - CSDVersion := trim(osVerInfo.szCSDVersion);
325   -
326   - case osVerInfo.dwPlatformId of
327   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
328   - begin
329   - if majorVer <= 4 then
330   - Result := cOsWinNT
331   - else if (majorVer = 5) and (minorVer = 0) then
332   - Result := cOsWin2000
333   - else if (majorVer = 5) and (minorVer = 1) then
334   - Result := cOsXP
335   - else if (majorVer = 5) and (minorVer = 2) then
336   - Result := cOsServer2003
337   - else
338   - Result := cOsUnknown;
339   - end;
340   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
341   - begin
342   - if (majorVer = 4) and (minorVer = 0) then
343   - Result := cOsWin95
344   - else if (majorVer = 4) and (minorVer = 10) then
345   - begin
346   - if osVerInfo.szCSDVersion[1] = 'A' then
347   - Result := cOsWin98SE
348   - else
349   - Result := cOsWin98;
350   - end
351   - else if (majorVer = 4) and (minorVer = 90) then
352   - Result := cOsWinME
353   - else
354   - Result := cOsUnknown;
355   - end;
356   - else
357   - Result := cOsUnknown;
358   - end;
359   - end
360   - else
361   - Result := cOsUnknown;
362   -
363   - // A partir da versão 2.2.0.24, defino o valor da ID Interna e atribuo-a sem o CSDVersion à versão externa
364   - v_te_so := IntToStr(platformId) + '.' +
365   - IntToStr(majorVer) + '.' +
366   - IntToStr(minorVer) +
367   - IfThen(CSDVersion='','','.'+CSDVersion);
368   - if (Result = 0) then
369   - Result := abstraiCSD(v_te_so);
370   -
371   -end;
372   -
373 284 Function CipherOpen(p_DatFileName : string) : TStrings;
374 285 var v_DatFile : TextFile;
375 286 v_strCipherOpened,
... ... @@ -396,7 +307,7 @@ begin
396 307 if (trim(v_strCipherOpened)<>'') then
397 308 Result := explode(v_strCipherOpened,v_SeparatorKey)
398 309 else
399   - Result := explode('Configs.ID_SO' + v_SeparatorKey + inttostr(intWinVer)+v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
  310 + Result := explode('Configs.ID_SO' + v_SeparatorKey + g_oCacic.getWindowsStrId() +v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
400 311  
401 312 if Result.Count mod 2 <> 0 then
402 313 Result.Add('');
... ... @@ -404,7 +315,6 @@ end;
404 315  
405 316 Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String);
406 317 begin
407   - //log_diario('Setando chave: '+p_Chave+' com valor: '+p_Valor,ExtractFilePath(ParamStr(0)));
408 318 // Exemplo: p_Chave => Configs.nu_ip_servidor : p_Valor => 10.71.0.120
409 319 if (v_tstrCipherOpened.IndexOf(p_Chave)<>-1) then
410 320 v_tstrCipherOpened[v_tstrCipherOpened.IndexOf(p_Chave)+1] := p_Valor
... ... @@ -615,7 +525,9 @@ end;
615 525  
616 526 Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean;
617 527 var IdFTP : TIdFTP;
  528 + msg_error : string;
618 529 begin
  530 + msg_error := '';
619 531 Try
620 532 IdFTP := TIdFTP.Create(IdFTP);
621 533 IdFTP.Host := p_Host;
... ... @@ -629,21 +541,25 @@ begin
629 541 begin
630 542 IdFTP.Disconnect;
631 543 end;
  544 + msg_error := 'Falha ao tentar conexão com o servidor FTP: "' + p_Host + '"';
632 545 IdFTP.Connect(true);
  546 + msg_error := 'Falha ao tentar mudar diretório no servidor FTP: "' + p_PathServer + '"';
633 547 IdFTP.ChangeDir(p_PathServer);
634 548 Try
635 549 log_DEBUG('Size de "'+p_File+'" Antes do FTP => '+IntToSTR(IdFTP.Size(p_File)));
  550 + msg_error := 'Falha ao tentar obter arquivo no servidor FTP: "' + p_File + '"';
636 551 IdFTP.Get(p_File, p_Dest + '\' + p_File, True);
637 552 log_DEBUG('Size de "'+p_Dest + '\' + p_File +'" Após o FTP => '+Get_File_Size(p_Dest + '\' + p_File,true));
638 553 Finally
639 554 log_DEBUG('Size de "'+p_Dest + '\' + p_File +'" Após o FTP em Finally => '+Get_File_Size(p_Dest + '\' + p_File,true));
640 555 idFTP.Disconnect;
641   - idFTP.Free;
642 556 result := true;
643 557 End;
644 558 Except
  559 + log_diario(msg_error);
645 560 result := false;
646 561 end;
  562 + idFTP.Free;
647 563 Except
648 564 result := false;
649 565 End;
... ... @@ -772,12 +688,10 @@ begin
772 688  
773 689 if not DeleteFile(strFileName) then
774 690 Begin
775   - if ((intWinVer <> 0) and (intWinVer <= 5)) or
776   - (abstraiCSD(v_te_so) < 250) then // Menor que NT Like
  691 + if (not g_oCacic.isWindowsNTPlataform()) then // Menor que NT Like
777 692 KillTask(SearchRec.Name)
778 693 else
779 694 KillProcess(FindWindow(PChar(SearchRec.Name),nil));
780   -
781 695 DeleteFile(strFileName);
782 696 End;
783 697  
... ... @@ -891,8 +805,6 @@ begin
891 805 End;
892 806 End;
893 807  
894   - intWinVer := GetWinVer;
895   -
896 808 // Caso o parâmetro rem_cacic_v0x seja "S/s" removo a chave/valor de execução do Cacic antigo
897 809 if (LowerCase(v_rem_cacic_v0x)='s') then
898 810 begin
... ... @@ -923,25 +835,12 @@ begin
923 835 ForceDirectories(Dir + '\temp');
924 836 end;
925 837  
926   -
927   - // Igualo as chaves ip_serv_cacic e cacic dos arquivos chksis.ini e cacic2.ini!
928   -// log_diario('Setando chave Configs/EnderecoServidor=' + v_ip_serv_cacic + ' em '+Dir + '\cacic2.dat',ExtractFilePath(ParamStr(0)));
929   -// SetValorChaveRegIni('Configs', 'EnderecoServidor', v_ip_serv_cacic, Dir + '\cacic2.ini');
930   -
931 838 //chave AES. Recomenda-se que cada empresa altere a sua chave.
932 839 v_CipherKey := 'CacicBrasil';
933 840 v_IV := 'abcdefghijklmnop';
934 841 v_SeparatorKey := '=CacicIsFree=';
935 842 v_DatFileName := Dir + '\cacic2.dat';
936   - //v_tstrCipherOpened := CipherOpen(v_DatFileName);
937 843  
938   - //SetValorDatMemoria('Configs.EnderecoServidor', v_ip_serv_cacic);
939   -
940   -// log_diario('Setando chave Configs/cacic_dir=' + v_cacic_dir + ' em '+Dir + '\cacic2.ini',ExtractFilePath(ParamStr(0)));
941   -// SetValorChaveRegIni('Configs', 'cacic_dir', v_cacic_dir, Dir + '\cacic2.ini');
942   - //SetValorDatMemoria('Configs.cacic_dir', v_cacic_dir);
943   -
944   - //CipherClose(v_DatFileName);
945 844 // Verifico existência dos dois principais objetos
946 845 If (not FileExists(Dir + '\cacic2.exe')) or (not FileExists(Dir + '\modulos\ger_cols.exe')) Then
947 846 Begin
... ... @@ -1083,10 +982,6 @@ begin
1083 982 End;
1084 983  
1085 984 // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor
1086   - //if (bool_download_CACIC2) then
1087   - //Begin
1088   - //if not bool_ExistsAutoRun then
1089   - // Begin
1090 985 if Posso_Rodar_CACIC or not bool_ExistsAutoRun then
1091 986 Begin
1092 987 log_diario('Executando '+Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic);
... ... @@ -1097,23 +992,16 @@ begin
1097 992 else
1098 993 WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic ), SW_HIDE);
1099 994 End;
1100   - // End
1101   - // else
1102 995 log_diario('Não Executei. Chave de AutoExecução já existente...');
1103   - //End
1104   - Application.Terminate;
1105 996 end;
1106 997  
1107 998 const
1108 999 CACIC_APP_NAME = 'chksis';
1109 1000  
1110   -var
1111   - oCacic : TCACIC;
1112   -
1113 1001 begin
1114   - oCacic := TCACIC.Create();
  1002 + g_oCacic := TCACIC.Create();
1115 1003  
1116   - if( not oCacic.isAppRunning( CACIC_APP_NAME ) )
  1004 + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) )
1117 1005 then begin
1118 1006 if (FindWindowByTitle('chkcacic') = 0) and (FindWindowByTitle('cacic2') = 0)
1119 1007 then
... ... @@ -1122,7 +1010,7 @@ begin
1122 1010 else log_diario('Não executei devido execução em paralelo de "chkcacic" ou "cacic2"!');
1123 1011 end;
1124 1012  
1125   - oCacic.Free();
  1013 + g_oCacic.Free();
1126 1014  
1127 1015 end.
1128 1016  
... ...
chksis/chksis_erro.ini
... ... @@ -1,2 +0,0 @@
1   -[Erro]
2   -Erro=Arquivo chkcacic.ini inexistente!
chksis/main.ddp
No preview for this file type
chksis/main.dfm
... ... @@ -1,46 +0,0 @@
1   -object Form1: TForm1
2   - Left = 232
3   - Top = 106
4   - Width = 544
5   - Height = 375
6   - Caption = 'Form1'
7   - Color = clBtnFace
8   - Font.Charset = DEFAULT_CHARSET
9   - Font.Color = clWindowText
10   - Font.Height = -11
11   - Font.Name = 'MS Sans Serif'
12   - Font.Style = []
13   - OldCreateOrder = False
14   - OnCreate = FormCreate
15   - PixelsPerInch = 96
16   - TextHeight = 13
17   - object IdFTP1: TIdFTP
18   - MaxLineAction = maException
19   - ReadTimeout = 0
20   - ProxySettings.ProxyType = fpcmNone
21   - ProxySettings.Port = 0
22   - Left = 240
23   - Top = 72
24   - end
25   - object IdHTTP1: TIdHTTP
26   - MaxLineAction = maException
27   - ReadTimeout = 0
28   - AllowCookies = True
29   - ProxyParams.BasicAuthentication = False
30   - ProxyParams.ProxyPort = 0
31   - Request.ContentLength = -1
32   - Request.ContentRangeEnd = 0
33   - Request.ContentRangeStart = 0
34   - Request.ContentType = 'text/html'
35   - Request.Accept = 'text/html, */*'
36   - Request.BasicAuthentication = False
37   - Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'
38   - HTTPOptions = [hoForceEncodeParams]
39   - Left = 320
40   - Top = 72
41   - end
42   - object PJVersionInfo1: TPJVersionInfo
43   - Left = 80
44   - Top = 72
45   - end
46   -end
chksis/main.pas
... ... @@ -1,474 +0,0 @@
1   -(**
2   ----------------------------------------------------------------------------------------------------------------------------------------------------------------
3   -Copyright 2000, 2001, 2002, 2003, 2004, 2005 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   -
18   -unit main;
19   -
20   -interface
21   -
22   -uses Windows, SysUtils, Classes, Forms, Registry, Inifiles, XML, LibXmlParser, strUtils,IdHTTP, IdFTP, idFTPCommon,
23   - IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, PJVersionInfo;
24   -
25   -Procedure chksis;
26   -Procedure DelValorReg(Chave: String);
27   -Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean;
28   -Function Explode(Texto, Separador : String) : TStrings;
29   -Function GetRootKey(strRootKey: String): HKEY;
30   -Function SetValorChaveRegEdit(Chave: String; Dado: Variant): Variant;
31   -Function GetValorChaveRegEdit(Chave: String): Variant;
32   -function SetValorChaveRegIni(p_Secao, p_Chave, p_Valor, p_File : String): String;
33   -function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String;
34   -function HomeDrive : string;
35   -Function RemoveCaracteresEspeciais(Texto : String) : String;
36   -function FindWindowByTitle(WindowTitle: string): Hwnd;
37   -function GetVersionInfo(p_File: string):string;
38   -function VerFmt(const MS, LS: DWORD): string;
39   -
40   -type
41   - TForm1 = class(TForm)
42   - IdFTP1: TIdFTP;
43   - IdHTTP1: TIdHTTP;
44   - PJVersionInfo1: TPJVersionInfo;
45   - procedure FormCreate(Sender: TObject);
46   - private
47   - { Private declarations }
48   - public
49   - { Public declarations }
50   - end;
51   -
52   -var
53   - Form1: TForm1;
54   - Dir, ENDERECO_SERV_CACIC : string;
55   -implementation
56   -
57   -{$R *.dfm}
58   -function VerFmt(const MS, LS: DWORD): string;
59   - // Format the version number from the given DWORDs containing the info
60   -begin
61   - Result := Format('%d.%d.%d.%d',
62   - [HiWord(MS), LoWord(MS), HiWord(LS), LoWord(LS)])
63   -end;
64   -
65   -{ TMainForm }
66   -
67   -function GetVersionInfo(p_File: string):string;
68   -begin
69   - Form1.PJVersionInfo1.FileName := PChar(p_File);
70   - Result := VerFmt(Form1.PJVersionInfo1.FixedFileInfo.dwFileVersionMS, Form1.PJVersionInfo1.FixedFileInfo.dwFileVersionLS);
71   -end;
72   -
73   -function GetRootKey(strRootKey: String): HKEY;
74   -begin
75   - /// Encontrar uma maneira mais elegante de fazer esses testes.
76   - if Trim(strRootKey) = 'HKEY_LOCAL_MACHINE' Then Result := HKEY_LOCAL_MACHINE
77   - else if Trim(strRootKey) = 'HKEY_CLASSES_ROOT' Then Result := HKEY_CLASSES_ROOT
78   - else if Trim(strRootKey) = 'HKEY_CURRENT_USER' Then Result := HKEY_CURRENT_USER
79   - else if Trim(strRootKey) = 'HKEY_USERS' Then Result := HKEY_USERS
80   - else if Trim(strRootKey) = 'HKEY_CURRENT_CONFIG' Then Result := HKEY_CURRENT_CONFIG
81   - else if Trim(strRootKey) = 'HKEY_DYN_DATA' Then Result := HKEY_DYN_DATA;
82   -end;
83   -function SetValorChaveRegEdit(Chave: String; Dado: Variant): Variant;
84   -var RegEditSet: TRegistry;
85   - RegDataType: TRegDataType;
86   - strRootKey, strKey, strValue : String;
87   - ListaAuxSet : TStrings;
88   - I : Integer;
89   -begin
90   - ListaAuxSet := Explode(Chave, '\');
91   - strRootKey := ListaAuxSet[0];
92   - For I := 1 To ListaAuxSet.Count - 2 Do strKey := strKey + ListaAuxSet[I] + '\';
93   - strValue := ListaAuxSet[ListaAuxSet.Count - 1];
94   -
95   - RegEditSet := TRegistry.Create;
96   - try
97   - RegEditSet.Access := KEY_WRITE;
98   - RegEditSet.Rootkey := GetRootKey(strRootKey);
99   -
100   - if RegEditSet.OpenKey(strKey, True) then
101   - Begin
102   - RegDataType := RegEditSet.GetDataType(strValue);
103   - if RegDataType = rdString then
104   - begin
105   - RegEditSet.WriteString(strValue, Dado);
106   - end
107   - else if RegDataType = rdExpandString then
108   - begin
109   - RegEditSet.WriteExpandString(strValue, Dado);
110   - end
111   - else if RegDataType = rdInteger then
112   - begin
113   - RegEditSet.WriteInteger(strValue, Dado);
114   - end
115   - else
116   - begin
117   - RegEditSet.WriteString(strValue, Dado);
118   - end;
119   -
120   - end;
121   - finally
122   - RegEditSet.CloseKey;
123   - end;
124   - ListaAuxSet.Free;
125   - RegEditSet.Free;
126   -end;
127   -
128   -Function RemoveCaracteresEspeciais(Texto : String) : String;
129   -var I : Integer;
130   - strAux : String;
131   -Begin
132   - For I := 0 To Length(Texto) Do
133   - if ord(Texto[I]) in [32..126] Then
134   - strAux := strAux + Texto[I]
135   - else strAux := strAux + ' '; // Coloca um espaço onde houver caracteres especiais
136   - Result := strAux;
137   -end;
138   -
139   -//Para buscar do RegEdit...
140   -function GetValorChaveRegEdit(Chave: String): Variant;
141   -var RegEditGet: TRegistry;
142   - RegDataType: TRegDataType;
143   - strRootKey, strKey, strValue, s: String;
144   - ListaAuxGet : TStrings;
145   - DataSize, Len, I : Integer;
146   -begin
147   - try
148   - ListaAuxGet := Explode(Chave, '\');
149   -
150   - strRootKey := ListaAuxGet[0];
151   - For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\';
152   - strValue := ListaAuxGet[ListaAuxGet.Count - 1];
153   - RegEditGet := TRegistry.Create;
154   -
155   - RegEditGet.Access := KEY_READ;
156   - RegEditGet.Rootkey := GetRootKey(strRootKey);
157   - if RegEditGet.OpenKeyReadOnly(strKey) then //teste
158   - Begin
159   - RegDataType := RegEditGet.GetDataType(strValue);
160   - if (RegDataType = rdString) or (RegDataType = rdExpandString) then Result := RegEditGet.ReadString(strValue)
161   - else if RegDataType = rdInteger then Result := RegEditGet.ReadInteger(strValue)
162   - else if (RegDataType = rdBinary) or (RegDataType = rdUnknown)
163   - then
164   - begin
165   - DataSize := RegEditGet.GetDataSize(strValue);
166   - if DataSize = -1 then exit;
167   - SetLength(s, DataSize);
168   - Len := RegEditGet.ReadBinaryData(strValue, PChar(s)^, DataSize);
169   - if Len <> DataSize then exit;
170   - Result := RemoveCaracteresEspeciais(s);
171   - end
172   - end;
173   - finally
174   - RegEditGet.CloseKey;
175   - RegEditGet.Free;
176   - ListaAuxGet.Free;
177   -
178   - end;
179   -end;
180   -
181   -//Para gravar no Arquivo INI...
182   -function SetValorChaveRegIni(p_Secao, p_Chave, p_Valor, p_File : String): String;
183   -var Reg_Ini : TIniFile;
184   -begin
185   - FileSetAttr (p_File,0);
186   - Reg_Ini := TIniFile.Create(p_File);
187   -// Reg_Ini.WriteString(utils_cacic.Crip(p_Secao), utils_cacic.Crip(p_Chave), utils_cacic.Crip(p_Valor));
188   - Reg_Ini.WriteString(p_Secao, p_Chave, p_Valor);
189   - Reg_Ini.Free;
190   -end;
191   -
192   -function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String;
193   -//Para buscar do Arquivo INI...
194   -// Marreta devido a limitações do KERNEL w9x no tratamento de arquivos texto e suas seções
195   -//function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String;
196   -var
197   - FileText : TStringList;
198   - i, j, v_Size_Section, v_Size_Key : integer;
199   - v_SectionName, v_KeyName : string;
200   - begin
201   - Result := '';
202   - v_SectionName := '[' + p_Secao + ']';
203   - v_Size_Section := strLen(PChar(v_SectionName));
204   - v_KeyName := p_Chave + '=';
205   - v_Size_Key := strLen(PChar(v_KeyName));
206   - FileText := TStringList.Create;
207   - try
208   - FileText.LoadFromFile(p_File);
209   - For i := 0 To FileText.Count - 1 Do
210   - Begin
211   - if (LowerCase(Trim(PChar(Copy(FileText[i],1,v_Size_Section)))) = LowerCase(Trim(PChar(v_SectionName)))) then
212   - Begin
213   - For j := i to FileText.Count - 1 Do
214   - Begin
215   - if (LowerCase(Trim(PChar(Copy(FileText[j],1,v_Size_Key)))) = LowerCase(Trim(PChar(v_KeyName)))) then
216   - Begin
217   - Result := PChar(Copy(FileText[j],v_Size_Key + 1,strLen(PChar(FileText[j]))-v_Size_Key));
218   - Break;
219   - End;
220   - End;
221   - End;
222   - if (Result <> '') then break;
223   - End;
224   - finally
225   - FileText.Free;
226   - end;
227   - end;
228   -
229   -
230   -Procedure DelValorReg(Chave: String);
231   -var RegDelValorReg: TRegistry;
232   - strRootKey, strKey, strValue : String;
233   - ListaAuxDel : TStrings;
234   - I : Integer;
235   -begin
236   - ListaAuxDel := Explode(Chave, '\');
237   - strRootKey := ListaAuxDel[0];
238   - For I := 1 To ListaAuxDel.Count - 2 Do strKey := strKey + ListaAuxDel[I] + '\';
239   - strValue := ListaAuxDel[ListaAuxDel.Count - 1];
240   - RegDelValorReg := TRegistry.Create;
241   -
242   - try
243   - RegDelValorReg.Access := KEY_WRITE;
244   - RegDelValorReg.Rootkey := GetRootKey(strRootKey);
245   -
246   - if RegDelValorReg.OpenKey(strKey, True) then
247   - RegDelValorReg.DeleteValue(strValue);
248   - finally
249   - RegDelValorReg.CloseKey;
250   - end;
251   - RegDelValorReg.Free;
252   - ListaAuxDel.Free;
253   -end;
254   -
255   -
256   -Function Explode(Texto, Separador : String) : TStrings;
257   -var
258   - strItem : String;
259   - ListaAuxUTILS : TStrings;
260   - NumCaracteres, I : Integer;
261   -Begin
262   - ListaAuxUTILS := TStringList.Create;
263   - strItem := '';
264   - NumCaracteres := Length(Texto);
265   - For I := 0 To NumCaracteres Do
266   - If (Texto[I] = Separador) or (I = NumCaracteres) Then
267   - Begin
268   - If (I = NumCaracteres) then strItem := strItem + Texto[I];
269   - ListaAuxUTILS.Add(Trim(strItem));
270   - strItem := '';
271   - end
272   - Else strItem := strItem + Texto[I];
273   - Explode := ListaAuxUTILS;
274   -end;
275   -
276   -Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean;
277   -var IdFTP : TIdFTP;
278   -begin
279   - Try
280   - IdFTP := TIdFTP.Create(IdFTP);
281   - IdFTP.Host := p_Host;
282   - IdFTP.Username := p_Username;
283   - IdFTP.Password := p_Password;
284   - IdFTP.Port := strtoint(p_Port);
285   - IdFTP.TransferType := ftBinary;
286   - Try
287   - if IdFTP.Connected = true then
288   - begin
289   - IdFTP.Disconnect;
290   - end;
291   - IdFTP.Connect(true);
292   - IdFTP.ChangeDir(p_PathServer);
293   - Try
294   - IdFTP.Get(p_File, p_Dest + '\' + p_File, True);
295   - result := true;
296   - Except
297   - result := false;
298   - End;
299   - Except
300   - result := false;
301   - end;
302   - Except
303   - result := false;
304   - End;
305   -end;
306   -
307   -
308   -function HomeDrive : string;
309   -var
310   -WinDir : array [0..144] of char;
311   -begin
312   -GetWindowsDirectory (WinDir, 144);
313   -Result := StrPas (WinDir);
314   -end;
315   -
316   -procedure chksis;
317   -var
318   - v_download_CACIC2 : boolean;
319   - v_home_drive, v_ip_serv_cacic, v_cacic_dir, v_rem_cacic_v0x,
320   - v_var_inst_cac, v_te_serv_updates, v_nu_porta_serv_updates, v_nm_usuario_login_serv_updates,
321   - v_te_senha_login_serv_updates, v_te_path_serv_updates,strDataCACIC2 : String;
322   - BatchFile, Request_Config : TStringList;
323   - Response_Config : TStringStream;
324   - IdHTTP1: TIdHTTP;
325   -begin
326   - v_download_CACIC2 := false;
327   - v_home_drive := MidStr(HomeDrive,1,3); //x:\
328   - v_ip_serv_cacic := GetValorChaveRegIni('Cacic2', 'ip_serv_cacic', ExtractFilePath(Application.Exename) + '\chksis.ini');
329   - v_cacic_dir := GetValorChaveRegIni('Cacic2', 'cacic_dir', ExtractFilePath(Application.Exename) + '\chksis.ini');
330   - v_rem_cacic_v0x := GetValorChaveRegIni('Cacic2', 'rem_cacic_v0x', ExtractFilePath(Application.Exename) + '\chksis.ini');
331   - Dir := v_home_drive + v_cacic_dir;
332   -
333   - // Caso o parâmetro rem_cacic_v0x seja "S/s" removo a chave/valor de execução do Cacic antigo
334   - if (LowerCase(v_rem_cacic_v0x)='s') then
335   - begin
336   - DelValorReg('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic');
337   - end;
338   -
339   - // Verifico a existência do diretório configurado para o Cacic, normalmente CACIC
340   - if not DirectoryExists(Dir) then
341   - begin
342   - ForceDirectories(Dir);
343   - end;
344   -
345   - // Para eliminar versão 20014 e anteriores que provavelmente não fazem corretamente o AutoUpdate
346   - if not DirectoryExists(Dir+'\modulos') then
347   - begin
348   - DeleteFile(Dir + '\cacic2.exe');
349   - ForceDirectories(Dir + '\modulos');
350   - end;
351   -
352   - // Crio o SubDiretório TEMP, caso não exista
353   - if not DirectoryExists(Dir+'\temp') then
354   - begin
355   - ForceDirectories(Dir + '\temp');
356   - end;
357   -
358   - // Exclusão do arquivo cacic2.exe para que seja baixado novamente, devido a problema com versão 2.0.0.23
359   - // após alteração do método de leitura de arquivos INI.
360   - If (FileExists(Dir + '\cacic2.exe')) Then
361   - Begin
362   - if (StrToInt(StringReplace(GetVersionInfo(Dir + '\cacic2.exe'),'.','',[rfReplaceAll]))>20000) or
363   - (trim(GetVersionInfo(Dir + '\cacic2.exe'))='0.0.0.0') then
364   - Begin
365   - DeleteFile(Dir + '\cacic2.exe');
366   - End;
367   - End;
368   -
369   - If (FileExists(Dir + '\modulos\ger_cols.exe')) Then
370   - Begin
371   - if (StrToInt(StringReplace(GetVersionInfo(Dir + '\modulos\ger_cols.exe'),'.','',[rfReplaceAll]))>20000) or
372   - (trim(GetVersionInfo(Dir + '\modulos\ger_cols.exe'))='0.0.0.0') then
373   - Begin
374   - DeleteFile(Dir + '\modulos\ger_cols.exe');
375   - End;
376   - End;
377   -
378   - // Igualo as chaves ip_serv_cacic dos arquivos chksis.ini e cacic2.ini!
379   - SetValorChaveRegIni('Configs', 'EnderecoServidor', v_ip_serv_cacic, Dir + '\cacic2.ini');
380   -
381   - // Verifico existência dos dois principais objetos
382   - If (not FileExists(Dir + '\cacic2.exe')) or (not FileExists(Dir + '\modulos\ger_cols.exe')) Then
383   - Begin
384   - // Busco as configurações para acesso ao ambiente FTP - Updates
385   - Request_Config := TStringList.Create;
386   - Request_Config.Values['in_chkcacic'] := 'chkcacic';
387   - Response_Config := TStringStream.Create('');
388   -
389   - Try
390   - IdHTTP1 := TIdHTTP.Create(IdHTTP1);
391   - IdHTTP1.Post('http://' + v_ip_serv_cacic + '/cacic2/ws/get_config.php', Request_Config, Response_Config);
392   -
393   - v_te_serv_updates := XML_RetornaValor('te_serv_updates' , Response_Config.DataString);
394   - v_nu_porta_serv_updates := XML_RetornaValor('nu_porta_serv_updates' , Response_Config.DataString);
395   - v_nm_usuario_login_serv_updates := XML_RetornaValor('nm_usuario_login_serv_updates', Response_Config.DataString);
396   - v_te_senha_login_serv_updates := XML_RetornaValor('te_senha_login_serv_updates' , Response_Config.DataString);
397   - v_te_path_serv_updates := XML_RetornaValor('te_path_serv_updates' , Response_Config.DataString);
398   - Except
399   - End;
400   - Request_Config.Free;
401   - Response_Config.Free;
402   -
403   - // Tento detectar o Agente Principal e faço FTP caso não exista
404   - If not FileExists(Dir + '\cacic2.exe') Then
405   - begin
406   - FTP(v_te_serv_updates,
407   - v_nu_porta_serv_updates,
408   - v_nm_usuario_login_serv_updates,
409   - v_te_senha_login_serv_updates,
410   - v_te_path_serv_updates,
411   - 'cacic2.exe',
412   - Dir);
413   - v_download_CACIC2 := true;
414   - end;
415   -
416   - // Tento detectar o Gerente de Coletas e faço FTP caso não exista
417   - If (not FileExists(Dir + '\modulos\ger_cols.exe')) Then
418   - begin
419   - FTP(v_te_serv_updates,
420   - v_nu_porta_serv_updates,
421   - v_nm_usuario_login_serv_updates,
422   - v_te_senha_login_serv_updates,
423   - v_te_path_serv_updates,
424   - 'ger_cols.exe',
425   - Dir + '\modulos');
426   - end;
427   - End;
428   -
429   - // Crio a chave/valor cacic2 para autoexecução do Cacic, caso não exista esta chave/valor
430   - // Crio a chave/valor chksis para autoexecução do Cacic, caso não exista esta chave/valor
431   - SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\CheckSystemRoutine', HomeDrive + '\chksis.exe');
432   - SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2', Dir + '\cacic2.exe');
433   -
434   - // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor
435   - if (v_download_CACIC2) then
436   - Begin
437   - WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic), SW_HIDE);
438   - End
439   -end;
440   -function FindWindowByTitle(WindowTitle: string): Hwnd;
441   -var
442   - NextHandle: Hwnd;
443   - NextTitle: array[0..260] of char;
444   -begin
445   - // Get the first window
446   - NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
447   - while NextHandle > 0 do
448   - begin
449   - // retrieve its text
450   - GetWindowText(NextHandle, NextTitle, 255);
451   -
452   - if (trim(StrPas(NextTitle))<> '') and (Pos(strlower(pchar(WindowTitle)), strlower(PChar(StrPas(NextTitle)))) <> 0) then
453   - begin
454   - Result := NextHandle;
455   - Exit;
456   - end
457   - else
458   - // Get the next window
459   - NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
460   - end;
461   - Result := 0;
462   -end;
463   -
464   -procedure TForm1.FormCreate(Sender: TObject);
465   -begin
466   - Application.ShowMainForm:=false;
467   - if (FindWindowByTitle('chkcacic') = 0) then
468   - Begin
469   - chksis;
470   - End;
471   - Application.Terminate;
472   -end;
473   -
474   -end.
col_comp/col_comp.dpr
... ... @@ -37,6 +37,8 @@ var p_path_cacic : string;
37 37 var v_tstrCipherOpened,
38 38 v_tstrCipherOpened1 : TStrings;
39 39  
  40 +var g_oCacic : TCACIC;
  41 +
40 42 // Some constants that are dependant on the cipher being used
41 43 // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
42 44 const KeySize = 32; // 32 bytes = 256 bits
... ... @@ -91,7 +93,6 @@ begin
91 93 Append(HistoricoLog);
92 94 Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now)+ '[Coletor COMP] '+strMsg); {Grava a string Texto no arquivo texto}
93 95 CloseFile(HistoricoLog); {Fecha o arquivo texto}
94   -// FileSetAttr (ExtractFilePath(Application.Exename) + '\cacic2.log',6); // Muda o atributo para arquivo de SISTEMA e OCULTO
95 96  
96 97 except
97 98 log_diario('Erro na gravação do log!');
... ... @@ -196,77 +197,14 @@ begin
196 197 Rewrite (v_DatFile);
197 198 Append(v_DatFile);
198 199  
199   - //v_Cipher := TDCP_rijndael.Create(nil);
200   - //v_Cipher.InitStr(v_CipherKey,TDCP_md5);
201 200 v_strCipherOpenImploded := Implode(p_tstrCipherOpened,'=CacicIsFree=');
202   - //v_strCipherClosed := v_Cipher.EncryptString(v_strCipherOpenImploded);
203 201 v_strCipherClosed := EnCrypt(v_strCipherOpenImploded);
204   - //v_Cipher.Burn;
205   - //v_Cipher.Free;
206 202 Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto}
207 203 CloseFile(v_DatFile);
208 204 except
209 205 end;
210 206 end;
211 207  
212   -function GetWinVer: Integer;
213   -const
214   - { operating system (OS)constants }
215   - cOsUnknown = 0;
216   - cOsWin95 = 1;
217   - cOsWin95OSR2 = 2; // Não implementado.
218   - cOsWin98 = 3;
219   - cOsWin98SE = 4;
220   - cOsWinME = 5;
221   - cOsWinNT = 6;
222   - cOsWin2000 = 7;
223   - cOsXP = 8;
224   -var
225   - osVerInfo: TOSVersionInfo;
226   - majorVer, minorVer: Integer;
227   -begin
228   - Result := cOsUnknown;
229   - { set operating system type flag }
230   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
231   - if GetVersionEx(osVerInfo) then
232   - begin
233   - majorVer := osVerInfo.dwMajorVersion;
234   - minorVer := osVerInfo.dwMinorVersion;
235   - case osVerInfo.dwPlatformId of
236   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
237   - begin
238   - if majorVer <= 4 then
239   - Result := cOsWinNT
240   - else if (majorVer = 5) and (minorVer = 0) then
241   - Result := cOsWin2000
242   - else if (majorVer = 5) and (minorVer = 1) then
243   - Result := cOsXP
244   - else
245   - Result := cOsUnknown;
246   - end;
247   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
248   - begin
249   - if (majorVer = 4) and (minorVer = 0) then
250   - Result := cOsWin95
251   - else if (majorVer = 4) and (minorVer = 10) then
252   - begin
253   - if osVerInfo.szCSDVersion[1] = 'A' then
254   - Result := cOsWin98SE
255   - else
256   - Result := cOsWin98;
257   - end
258   - else if (majorVer = 4) and (minorVer = 90) then
259   - Result := cOsWinME
260   - else
261   - Result := cOsUnknown;
262   - end;
263   - else
264   - Result := cOsUnknown;
265   - end;
266   - end
267   - else
268   - Result := cOsUnknown;
269   -end;
270 208 Function Explode(Texto, Separador : String) : TStrings;
271 209 var
272 210 strItem : String;
... ... @@ -324,7 +262,7 @@ begin
324 262 if (trim(v_strCipherOpened)<>'') then
325 263 Result := explode(v_strCipherOpened,'=CacicIsFree=')
326 264 else
327   - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  265 + Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
328 266  
329 267  
330 268 if Result.Count mod 2 <> 0 then
... ... @@ -333,7 +271,6 @@ end;
333 271  
334 272 Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String; p_tstrCipherOpened : TStrings);
335 273 begin
336   -//log_diario('Gravando: '+p_Chave+' Valor: '+p_Valor);
337 274 // Exemplo: p_Chave => Configs.nu_ip_servidor : p_Valor => 10.71.0.120
338 275 if (p_tstrCipherOpened.IndexOf(p_Chave)<>-1) then
339 276 p_tstrCipherOpened[v_tstrCipherOpened.IndexOf(p_Chave)+1] := p_Valor
... ... @@ -351,7 +288,6 @@ begin
351 288 Result := v_tstrCipherOpened[v_tstrCipherOpened.IndexOf(p_Chave)+1]
352 289 else
353 290 Result := '';
354   -//log_diario('Buscando: '+p_Chave+' Resultado: '+Result);
355 291 end;
356 292  
357 293  
... ... @@ -420,18 +356,17 @@ begin
420 356 end;
421 357 end;
422 358  
423   -
424   -
425   -
426 359 procedure Executa_Col_comp;
427   -function RetornaValorShareNT(ValorReg : String; LimiteEsq : String; LimiteDir : String) : String;
428   -var intAux, intAux2 : Integer;
429   -Begin
430   - intAux := Pos(LimiteEsq, ValorReg) + Length(LimiteEsq);
431   - if (LimiteDir = 'Fim') Then intAux2 := Length(ValorReg) - 1
432   - Else intAux2 := Pos(LimiteDir, ValorReg) - intAux - 1;
433   - result := Trim(Copy(ValorReg, intAux, intAux2));
434   -end;
  360 +
  361 + function RetornaValorShareNT(ValorReg : String; LimiteEsq : String; LimiteDir : String) : String;
  362 + var intAux, intAux2 : Integer;
  363 + Begin
  364 + intAux := Pos(LimiteEsq, ValorReg) + Length(LimiteEsq);
  365 + if (LimiteDir = 'Fim') Then intAux2 := Length(ValorReg) - 1
  366 + Else intAux2 := Pos(LimiteDir, ValorReg) - intAux - 1;
  367 + result := Trim(Copy(ValorReg, intAux, intAux2));
  368 + end;
  369 +
435 370 var Reg_RCC : TRegistry;
436 371 ChaveRegistro, ValorChaveRegistro, nm_compartilhamento, nm_dir_compart,
437 372 in_senha_escrita, in_senha_leitura, te_comentario, strTripaDados, strAux,
... ... @@ -453,16 +388,6 @@ Begin
453 388 Reg_RCC.LazyWrite := False;
454 389 Lista_RCC := TStringList.Create;
455 390 Reg_RCC.Rootkey := HKEY_LOCAL_MACHINE;
456   - {
457   - strXML := '<?xml version="1.0" encoding="ISO-8859-1"?>' +
458   - '<comparts>' +
459   - '<te_node_address>' + GetValorChaveRegIni('TcpIp' ,'TE_NODE_ADDRESS' ,p_path_cacic_ini) + '</te_node_address>' +
460   - '<te_nome_computador>' + GetValorChaveRegIni('TcpIp' ,'TE_NOME_COMPUTADOR',p_path_cacic_ini) + '</te_nome_computador>' +
461   - '<te_workgroup>' + GetValorChaveRegIni('TcpIp' ,'TE_WORKGROUP' ,p_path_cacic_ini) + '</te_workgroup>' +
462   - '<id_so>' + GetValorChaveRegIni('Configs','ID_SO' ,p_path_cacic_ini) + '</id_so>';
463   - }
464   -
465   - //strXML := '<?xml version="1.0" encoding="ISO-8859-1"?><comparts>';
466 391 strTripaDados := '';
467 392  
468 393 if Win32Platform = VER_PLATFORM_WIN32_NT then
... ... @@ -573,11 +498,10 @@ const
573 498  
574 499 var
575 500 hwind:HWND;
576   - oCacic : TCACIC;
577 501  
578 502 begin
579   - oCacic := TCACIC.Create();
580   - if( not oCacic.isAppRunning( CACIC_APP_NAME ) ) then
  503 + g_oCacic := TCACIC.Create();
  504 + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then
581 505 if (ParamCount>0) then
582 506 Begin
583 507 For intAux := 1 to ParamCount do
... ... @@ -614,5 +538,5 @@ begin
614 538 Halt(0);
615 539 End;
616 540 End;
617   - oCacic.Free();
  541 + g_oCacic.Free();
618 542 end.
... ...
col_hard/col_hard.dpr
... ... @@ -51,6 +51,8 @@ var p_path_cacic, v_mensagem : string;
51 51 var v_tstrCipherOpened,
52 52 v_tstrCipherOpened1 : TStrings;
53 53  
  54 +var g_oCacic : TCACIC;
  55 +
54 56 // Some constants that are dependant on the cipher being used
55 57 // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
56 58 const KeySize = 32; // 32 bytes = 256 bits
... ... @@ -129,7 +131,6 @@ begin
129 131 Append(HistoricoLog);
130 132 Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now)+ '[Coletor HARD] '+strMsg); {Grava a string Texto no arquivo texto}
131 133 CloseFile(HistoricoLog); {Fecha o arquivo texto}
132   -// FileSetAttr (ExtractFilePath(Application.Exename) + '\cacic2.log',6); // Muda o atributo para arquivo de SISTEMA e OCULTO
133 134  
134 135 except
135 136 log_diario('Erro na gravação do log!');
... ... @@ -220,13 +221,8 @@ begin
220 221 Rewrite (v_DatFile);
221 222 Append(v_DatFile);
222 223  
223   - //v_Cipher := TDCP_rijndael.Create(nil);
224   - //v_Cipher.InitStr(v_CipherKey,TDCP_md5);
225 224 v_strCipherOpenImploded := Implode(p_tstrCipherOpened,'=CacicIsFree=');
226 225 v_strCipherClosed := EnCrypt(v_strCipherOpenImploded);
227   - //v_strCipherClosed := v_Cipher.EncryptString(v_strCipherOpenImploded);
228   - //v_Cipher.Burn;
229   - //v_Cipher.Free;
230 226  
231 227 Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto}
232 228  
... ... @@ -234,64 +230,7 @@ begin
234 230 except
235 231 end;
236 232 end;
237   -function GetWinVer: Integer;
238   -const
239   - { operating system (OS)constants }
240   - cOsUnknown = 0;
241   - cOsWin95 = 1;
242   - cOsWin95OSR2 = 2; // Não implementado.
243   - cOsWin98 = 3;
244   - cOsWin98SE = 4;
245   - cOsWinME = 5;
246   - cOsWinNT = 6;
247   - cOsWin2000 = 7;
248   - cOsXP = 8;
249   -var
250   - osVerInfo: TOSVersionInfo;
251   - majorVer, minorVer: Integer;
252   -begin
253   - Result := cOsUnknown;
254   - { set operating system type flag }
255   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
256   - if GetVersionEx(osVerInfo) then
257   - begin
258   - majorVer := osVerInfo.dwMajorVersion;
259   - minorVer := osVerInfo.dwMinorVersion;
260   - case osVerInfo.dwPlatformId of
261   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
262   - begin
263   - if majorVer <= 4 then
264   - Result := cOsWinNT
265   - else if (majorVer = 5) and (minorVer = 0) then
266   - Result := cOsWin2000
267   - else if (majorVer = 5) and (minorVer = 1) then
268   - Result := cOsXP
269   - else
270   - Result := cOsUnknown;
271   - end;
272   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
273   - begin
274   - if (majorVer = 4) and (minorVer = 0) then
275   - Result := cOsWin95
276   - else if (majorVer = 4) and (minorVer = 10) then
277   - begin
278   - if osVerInfo.szCSDVersion[1] = 'A' then
279   - Result := cOsWin98SE
280   - else
281   - Result := cOsWin98;
282   - end
283   - else if (majorVer = 4) and (minorVer = 90) then
284   - Result := cOsWinME
285   - else
286   - Result := cOsUnknown;
287   - end;
288   - else
289   - Result := cOsUnknown;
290   - end;
291   - end
292   - else
293   - Result := cOsUnknown;
294   -end;
  233 +
295 234 Function Explode(Texto, Separador : String) : TStrings;
296 235 var
297 236 strItem : String;
... ... @@ -349,7 +288,7 @@ begin
349 288 if (trim(v_strCipherOpened)<>'') then
350 289 Result := explode(v_strCipherOpened,'=CacicIsFree=')
351 290 else
352   - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  291 + Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
353 292  
354 293 if Result.Count mod 2 <> 0 then
355 294 Result.Add('');
... ... @@ -791,9 +730,9 @@ begin
791 730 Try
792 731 for i:=0 to v_CPU.CPUCount-1 do begin
793 732 v_te_cpu_serial := v_CPU.SerialNumber;
794   - v_te_cpu_desc := v_CPU.CPUName;
  733 + v_te_cpu_desc := v_CPU.MarketingName;
795 734 if(v_te_cpu_desc = '') then
796   - v_te_cpu_desc := v_CPU.MarketingName;
  735 + v_te_cpu_desc := v_CPU.CPUName;
797 736  
798 737 v_te_cpu_fabricante := cVendorNames[v_CPU.Vendor].Prefix;
799 738  
... ... @@ -1158,12 +1097,11 @@ const
1158 1097  
1159 1098 var tstrTripa1 : TStrings;
1160 1099 intAux : integer;
1161   - oCacic : TCACIC;
1162 1100  
1163 1101 begin
1164   - oCacic := TCACIC.Create();
  1102 + g_oCacic := TCACIC.Create();
1165 1103  
1166   - if( not oCacic.isAppRunning( CACIC_APP_NAME ) ) then
  1104 + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then
1167 1105 if (ParamCount>0) then
1168 1106 Begin
1169 1107 For intAux := 1 to ParamCount do
... ... @@ -1211,6 +1149,6 @@ begin
1211 1149 End;
1212 1150 End;
1213 1151  
1214   - oCacic.Free();
  1152 + g_oCacic.Free();
1215 1153  
1216 1154 end.
... ...
col_moni/col_moni.dpr
... ... @@ -42,6 +42,8 @@ var v_Debugs : boolean;
42 42 var v_tstrCipherOpened,
43 43 v_tstrCipherOpened1 : TStrings;
44 44  
  45 +var g_oCacic : TCACIC;
  46 +
45 47 // Some constants that are dependant on the cipher being used
46 48 // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
47 49 const KeySize = 32; // 32 bytes = 256 bits
... ... @@ -342,64 +344,7 @@ begin
342 344 except
343 345 end;
344 346 end;
345   -function GetWinVer: Integer;
346   -const
347   - { operating system (OS)constants }
348   - cOsUnknown = 0;
349   - cOsWin95 = 1;
350   - cOsWin95OSR2 = 2; // Não implementado.
351   - cOsWin98 = 3;
352   - cOsWin98SE = 4;
353   - cOsWinME = 5;
354   - cOsWinNT = 6;
355   - cOsWin2000 = 7;
356   - cOsXP = 8;
357   -var
358   - osVerInfo: TOSVersionInfo;
359   - majorVer, minorVer: Integer;
360   -begin
361   - Result := cOsUnknown;
362   - { set operating system type flag }
363   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
364   - if GetVersionEx(osVerInfo) then
365   - begin
366   - majorVer := osVerInfo.dwMajorVersion;
367   - minorVer := osVerInfo.dwMinorVersion;
368   - case osVerInfo.dwPlatformId of
369   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
370   - begin
371   - if majorVer <= 4 then
372   - Result := cOsWinNT
373   - else if (majorVer = 5) and (minorVer = 0) then
374   - Result := cOsWin2000
375   - else if (majorVer = 5) and (minorVer = 1) then
376   - Result := cOsXP
377   - else
378   - Result := cOsUnknown;
379   - end;
380   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
381   - begin
382   - if (majorVer = 4) and (minorVer = 0) then
383   - Result := cOsWin95
384   - else if (majorVer = 4) and (minorVer = 10) then
385   - begin
386   - if osVerInfo.szCSDVersion[1] = 'A' then
387   - Result := cOsWin98SE
388   - else
389   - Result := cOsWin98;
390   - end
391   - else if (majorVer = 4) and (minorVer = 90) then
392   - Result := cOsWinME
393   - else
394   - Result := cOsUnknown;
395   - end;
396   - else
397   - Result := cOsUnknown;
398   - end;
399   - end
400   - else
401   - Result := cOsUnknown;
402   -end;
  347 +
403 348 Function Explode(Texto, Separador : String) : TStrings;
404 349 var
405 350 strItem : String;
... ... @@ -457,7 +402,7 @@ begin
457 402 if (trim(v_strCipherOpened)<>'') then
458 403 Result := explode(v_strCipherOpened,'=CacicIsFree=')
459 404 else
460   - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  405 + Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
461 406  
462 407 if Result.Count mod 2 <> 0 then
463 408 Result.Add('');
... ... @@ -1081,12 +1026,11 @@ const
1081 1026  
1082 1027 var tstrTripa1 : TStrings;
1083 1028 intAux : integer;
1084   - oCacic : TCACIC;
1085 1029  
1086 1030 begin
1087   - oCacic := TCACIC.Create();
  1031 + g_oCacic := TCACIC.Create();
1088 1032  
1089   - if( not oCacic.isAppRunning( CACIC_APP_NAME ) ) then
  1033 + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then
1090 1034 if (ParamCount>0) then
1091 1035 Begin
1092 1036 For intAux := 1 to ParamCount do
... ... @@ -1134,6 +1078,6 @@ begin
1134 1078 End;
1135 1079 End;
1136 1080  
1137   - oCacic.Free();
  1081 + g_oCacic.Free();
1138 1082  
1139 1083 end.
... ...
col_moni/coleta_monitorado.pas
... ... @@ -1,226 +0,0 @@
1   -unit coleta_monitorado;
2   -
3   -interface
4   -
5   -uses Windows, Registry, SysUtils, Classes, dialogs;
6   -
7   -procedure RealizarColetaMonitorado;
8   -
9   -implementation
10   -
11   -
12   -Uses main, comunicacao, utils, registro, Math;
13   -
14   -procedure RealizarColetaMonitorado;
15   -var Request_RCH : TStringlist;
16   - tstrTripa2, tstrTripa3, v_array1, v_array2, v_array3, v_array4 : TStrings;
17   - strAux, strAux1, strAux3, strAux4, strTripa, ValorChavePerfis, ValorChaveColetado : String;
18   - intAux4, v1, v3, v_achei : Integer;
19   -begin
20   - // Verifica se deverá ser realizada a coleta de informações de aplicativos monitorados neste
21   - // computador, perguntando ao agente gerente.
22   - if (CS_COLETA_MONITORADO) Then
23   - Begin
24   - main.frmMain.Log_Historico('* Coletando informações de aplicativos monitorados.');
25   - intAux4 := 1;
26   - strAux3 := '';
27   - ValorChavePerfis := '*';
28   - while ValorChavePerfis <> '' do
29   - begin
30   - strAux3 := 'APL' + trim(inttostr(intAux4));
31   -
32   - strTripa := ''; // Conterá as informações a serem enviadas ao Gerente.
33   - // Obtenho do registro o valor que foi previamente armazenado
34   - ValorChavePerfis := Trim(Registro.GetValorChaveRegIni('Coleta',strAux3, p_path_cacic_ini));
35   - if (ValorChavePerfis <> '') then
36   - Begin
37   - //Atenção, OS ELEMENTOS DEVEM ESTAR DE ACORDO COM A ORDEM QUE SÃO TRATADOS NO MÓDULO GERENTE.
38   - tstrTripa2 := Utils.Explode(ValorChavePerfis,',');
39   - if (strAux <> '') then strAux := strAux + '#';
40   - strAux := strAux + trim(tstrTripa2[0]) + ',';
41   -
42   -
43   - //Coleta de Informação de Licença
44   - if (trim(tstrTripa2[2])='0') then //Vazio
45   - Begin
46   - strAux := strAux + ',';
47   - End;
48   - if (trim(tstrTripa2[2])='1') then //Caminho\Chave\Valor em Registry
49   - Begin
50   - strAux4 := Trim(Registro.GetValorChaveRegEdit(trim(tstrTripa2[3])));
51   - if (strAux4 = '') then strAux4 := '?';
52   - strAux := strAux + strAux4 + ',';
53   - End;
54   - if (trim(tstrTripa2[2])='2') then //Nome\Seção\Chave de Arquivo INI
55   - Begin
56   - Try
57   - if (LastPos('/',trim(tstrTripa2[3]))>0) then
58   - Begin
59   - tstrTripa3 := Utils.Explode(trim(tstrTripa2[3]),'\');
60   - strAux4 := Trim(Registro.GetValorChaveRegIni(tstrTripa3[1],tstrTripa3[2],tstrTripa3[0]));
61   - if (strAux4 = '') then strAux4 := '?';
62   - strAux := strAux + strAux4 + ',';
63   - End;
64   - if (LastPos('\',trim(tstrTripa2[3]))=0) then
65   - Begin
66   - strAux := strAux + 'Parâm.Lic.Incorreto,';
67   - End
68   - Except
69   - strAux := strAux + 'Parâm.Lic.Incorreto,';
70   - End;
71   - End;
72   -
73   -
74   - //Coleta de Informação de Instalação
75   - if (trim(tstrTripa2[4])='0') then //Vazio
76   - Begin
77   - strAux := strAux + ',';
78   - End;
79   -
80   - if (trim(tstrTripa2[4])='1') or (trim(tstrTripa2[4]) = '2') then //Nome de Executável OU Nome de Arquivo de Configuração (CADPF!!!)
81   - Begin
82   - strAux1 := trim(utils.FileSearch('\',trim(tstrTripa2[5])));
83   - if (strAux1 <> '') then strAux := strAux + 'S,';
84   - if (strAux1 = '') then strAux := strAux + 'N,';
85   - End;
86   -
87   - if (trim(tstrTripa2[4])='3') then //Caminho\Chave\Valor em Registry
88   - Begin
89   - strAux1 := Trim(Registro.GetValorChaveRegEdit(trim(tstrTripa2[5])));
90   - if (strAux1 <> '') then strAux := strAux + 'S,';
91   - if (strAux1 = '') then strAux := strAux + 'N,';
92   - End;
93   -
94   -
95   - //Coleta de Informação de Versão
96   - if (trim(tstrTripa2[6])='0') then //Vazio
97   - Begin
98   - strAux := strAux + ',';
99   - End;
100   -
101   - if (trim(tstrTripa2[6])='1') then //Data de Arquivo
102   - Begin
103   - strAux1 := trim(utils.FileSearch('\',trim(tstrTripa2[7])));
104   - if (strAux1 <> '') then
105   - Begin
106   - strAux := strAux + DateToStr(FileDateToDateTime(FileAge(strAux1)))+',';
107   - End;
108   - if (strAux1 = '') then strAux := strAux + '?,';
109   - End;
110   -
111   - if (trim(tstrTripa2[6])='2') then //Caminho\Chave\Valor em Registry
112   - Begin
113   - strAux1 := Trim(Registro.GetValorChaveRegEdit(trim(tstrTripa2[7])));
114   - if (strAux1 <> '') then strAux := strAux + strAux1 + ',';
115   - if (strAux1 = '') then strAux := strAux + '?,';
116   - End;
117   -
118   - if (trim(tstrTripa2[6])='3') then //Nome\Seção\Chave de Arquivo INI
119   - Begin
120   - Try
121   - if (LastPos('\',trim(tstrTripa2[7]))>0) then
122   - Begin
123   - tstrTripa3 := Utils.Explode(trim(tstrTripa2[7]),'\');
124   - strAux4 := Trim(Registro.GetValorChaveRegIni(tstrTripa3[1],tstrTripa3[2],tstrTripa3[0]));
125   - if (strAux4 = '') then strAux4 := '?';
126   - strAux := strAux + strAux4 + ',';
127   -
128   - End;
129   - if (LastPos('\',trim(tstrTripa2[7]))=0) then
130   - Begin
131   - strAux := strAux + 'Parâm.Versao Incorreto,';
132   - End
133   - Except
134   - strAux := strAux + 'Parâm.Versao Incorreto,';
135   - End;
136   - End;
137   -
138   - //Coleta de Informação de Engine
139   - if (trim(tstrTripa2[8])='.') then //Vazio
140   - Begin
141   - strAux := strAux + ',';
142   - End;
143   - //O ponto é proposital para quando o último parâmetro vem vazio do Gerente!!! :)
144   - if (trim(tstrTripa2[8])<>'.') then //Arquivo para Versão de Engine
145   - Begin
146   - strAux1 := trim(utils.FileSearch('\',trim(tstrTripa2[8])));
147   - if (strAux1 <> '') then
148   - Begin
149   - tstrTripa3 := utils.Explode(utils.getVersionInfo(strAux1), '.'); // Pego só os dois primeiros dígitos. Por exemplo: 6.640.0.1001 vira 6.640.
150   - strAux := strAux + tstrTripa3[0] + '.' + tstrTripa3[1];
151   - End;
152   - if (strAux1 = '') then strAux := strAux + '?,';
153   - End;
154   -
155   - //Coleta de Informação de Pattern
156   - //O ponto é proposital para quando o último parâmetro vem vazio do Gerente!!! :)
157   - if (trim(tstrTripa2[9])<>'.') then //Arquivo para Versão de Pattern
158   - Begin
159   - strAux1 := trim(utils.FileSearch('\',trim(tstrTripa2[9])));
160   - if (strAux1 <> '') then
161   - Begin
162   - tstrTripa3 := utils.Explode(utils.getVersionInfo(strAux1), '.'); // Pego só os dois primeiros dígitos. Por exemplo: 6.640.0.1001 vira 6.640.
163   - strAux := strAux + tstrTripa3[0] + '.' + tstrTripa3[1];
164   - End;
165   - if (strAux1 = '') then strAux := strAux + '?,';
166   - End;
167   - End;
168   - intAux4 := intAux4 + 1;
169   - End;
170   -
171   - ValorChaveColetado := Trim(Registro.GetValorChaveRegIni('Coleta','APLICATIVOS_MONITORADOS_COLETADOS', p_path_cacic_ini));
172   -If ((trim(strAux) <> trim(ValorChaveColetado)) and (trim(ValorChaveColetado) <> '')) Then
173   - begin
174   - v_array1 := utils.Explode(strAux, '#');
175   - strAux := '';
176   - v_array3 := utils.Explode(ValorChaveColetado, '#');
177   - for v1 := 0 to (v_array1.count)-1 do
178   - Begin
179   - v_array2 := utils.Explode(v_array1[v1], ',');
180   - v_achei := 0;
181   - for v3 := 0 to (v_array3.count)-1 do
182   - Begin
183   - v_array4 := utils.Explode(v_array3[v3], ',');
184   - if (v_array4=v_array2) then v_achei := 1;
185   - End;
186   - if (v_achei = 0) then
187   - Begin
188   - if (strAUX <> '') then strAUX := strAUX + '#';
189   - strAUX := strAUX + v_array1[v1];
190   - End;
191   - End;
192   - end;
193   -
194   -
195   - // Se essas informações forem diferentes significa que houve alguma alteração
196   - // na configuração de hardware. Nesse caso, gravo as informações no BD Central
197   - // e, se não houver problemas durante esse procedimento, atualizo as
198   - // informações no registro.
199   - If (IN_COLETA_FORCADA or (trim(strAux) <> trim(ValorChaveColetado))) Then
200   - Begin
201   - //Envio via rede para ao Agente Gerente, para gravação no BD.
202   - Request_RCH:=TStringList.Create;
203   - Request_RCH.Values['te_node_address'] := TE_NODE_ADDRESS;
204   - Request_RCH.Values['id_so'] := ID_SO;
205   - Request_RCH.Values['te_nome_computador'] := TE_NOME_COMPUTADOR;
206   - Request_RCH.Values['id_ip_rede'] := ID_IP_REDE;
207   - Request_RCH.Values['te_ip'] := TE_IP;
208   - Request_RCH.Values['te_workgroup'] := TE_WORKGROUP;
209   - Request_RCH.Values['te_tripa_monitorados'] := strAux;
210   -
211   -
212   - // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD
213   - //Sobreponho a informação no registro para posterior comparação, na próxima execução.
214   - if (comunicacao.ComunicaServidor('set_monitorado.php', Request_RCH, '>> Enviando informações de aplicativos monitorados para o servidor.') <> '0') Then
215   - Begin
216   - Registro.SetValorChaveRegIni('Coleta','APLICATIVOS_MONITORADOS_COLETADOS',strAux, p_path_cacic_ini);
217   - end;
218   - Request_RCH.Free;
219   - end
220   - else main.frmMain.Log_Historico('Coleta de informações de aplicativos monitorados não configurada.');
221   - end;
222   -end;
223   -
224   -
225   -end.
226   -
col_moni/main_moni.ddp
No preview for this file type
col_moni/main_moni.dfm
... ... @@ -1,22 +0,0 @@
1   -object frm_col_moni: Tfrm_col_moni
2   - Left = 910
3   - Top = 715
4   - Width = 112
5   - Height = 27
6   - Caption = 'CACIC - Coletor Aplicativos Monitorados'
7   - Color = clBtnFace
8   - TransparentColor = True
9   - Font.Charset = DEFAULT_CHARSET
10   - Font.Color = clWindowText
11   - Font.Height = -11
12   - Font.Name = 'MS Sans Serif'
13   - Font.Style = []
14   - OldCreateOrder = False
15   - PrintScale = poNone
16   - OnCreate = FormCreate
17   - PixelsPerInch = 96
18   - TextHeight = 13
19   - object PJVersionInfo1: TPJVersionInfo
20   - Left = 40
21   - end
22   -end
col_moni/main_moni.pas
... ... @@ -1,776 +0,0 @@
1   -(**
2   ----------------------------------------------------------------------------------------------------------------------------------------------------------------
3   -Copyright 2000, 2001, 2002, 2003, 2004, 2005 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   -
18   -unit main_moni;
19   -
20   -interface
21   -
22   -uses Windows, Forms, sysutils, inifiles, Registry, Classes, PJVersionInfo;
23   -
24   -var p_path_cacic, p_path_cacic_ini, v_Res_Search, v_Drive, v_File : string;
25   -
26   -type
27   - Tfrm_col_moni = class(TForm)
28   - PJVersionInfo1: TPJVersionInfo;
29   - procedure Executa_Col_moni;
30   - procedure Log_Historico(strMsg : String);
31   - Function Crip(PNome: String): String;
32   - Function DesCrip(PNome: String): String;
33   - function SetValorChaveRegIni(p_Secao: String; p_Chave: String; p_Valor: String; p_Path : String): String;
34   - function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String;
35   - function GetValorChaveRegEdit(Chave: String): Variant;
36   - function GetRootKey(strRootKey: String): HKEY;
37   - Function Explode(Texto, Separador : String) : TStrings;
38   - Function RemoveCaracteresEspeciais(Texto : String) : String;
39   - function GetVersionInfo(p_File: string):string;
40   - function VerFmt(const MS, LS: DWORD): string;
41   - function LetrasDrives : string;
42   - function LastPos(SubStr, S: string): Integer;
43   - function SearchFile(p_Drive,p_File:string) : boolean;
44   - procedure GetSubDirs(Folder:string; sList:TStringList);
45   - procedure FormCreate(Sender: TObject);
46   - private
47   - { Private declarations }
48   - public
49   - { Public declarations }
50   - end;
51   -
52   -var
53   - frm_col_moni: Tfrm_col_moni;
54   -
55   -implementation
56   -
57   -{$R *.dfm}
58   -function Tfrm_col_moni.VerFmt(const MS, LS: DWORD): string;
59   - // Format the version number from the given DWORDs containing the info
60   -begin
61   - Result := Format('%d.%d.%d.%d',
62   - [HiWord(MS), LoWord(MS), HiWord(LS), LoWord(LS)])
63   -end;
64   -
65   -{ TMainForm }
66   -
67   -function Tfrm_col_moni.GetVersionInfo(p_File: string):string;
68   -begin
69   - PJVersionInfo1.FileName := PChar(p_File);
70   - Result := VerFmt(PJVersionInfo1.FixedFileInfo.dwFileVersionMS, PJVersionInfo1.FixedFileInfo.dwFileVersionLS);
71   -end;
72   -
73   -// Baixada de http://www.infoeng.hpg.ig.com.br/borland_delphi_dicas_2.htm
74   -function Tfrm_col_moni.LetrasDrives: string;
75   -var
76   -Drives: DWord;
77   -I, Tipo: byte;
78   -v_Unidade : string;
79   -begin
80   -Result := '';
81   -Drives := GetLogicalDrives;
82   -if Drives <> 0 then
83   -for I := 65 to 90 do
84   - if ((Drives shl (31 - (I - 65))) shr 31) = 1 then
85   - Begin
86   - v_Unidade := Char(I) + ':\';
87   - Tipo := GetDriveType(PChar(v_Unidade));
88   - case Tipo of
89   - DRIVE_FIXED: Result := Result + Char(I);
90   - end;
91   - End;
92   -end;
93   -
94   -// By Muad Dib 2003
95   -// at http://www.planet-source-code.com.
96   -// Excelente!!!
97   -function Tfrm_col_moni.SearchFile(p_Drive,p_File:string) : boolean;
98   -var sr:TSearchRec;
99   - sDirList:TStringList;
100   - i:integer;
101   -begin
102   - Result := false;
103   - v_Res_Search := '';
104   - if FindFirst(p_Drive+p_File,faAnyFile,sr) = 0 then
105   - Begin
106   - v_Res_Search := p_Drive+p_File;
107   - Result := true;
108   - End
109   - else
110   - Begin
111   - repeat
112   - until FindNext(sr)<>0;
113   - FindClose(sr);
114   - sDirList:= TStringList.Create;
115   - try
116   - GetSubDirs(p_Drive,sDirList);
117   - for i:=0 to sDirList.Count-1 do
118   - if (sDirList[i]<>'.') and (sDirList[i]<>'..') then
119   - begin
120   - Application.ProcessMessages;
121   - if (SearchFile(IncludeTrailingPathDelimiter(p_Drive+sDirList[i]),p_File)) then
122   - Begin
123   - Result := true;
124   - Break;
125   - End;
126   - end;
127   - finally
128   - sDirList.Free;
129   - End;
130   - end;
131   -end;
132   -
133   -procedure Tfrm_col_moni.GetSubDirs(Folder:string; sList:TStringList);
134   - var
135   - sr:TSearchRec;
136   -begin
137   - if FindFirst(Folder+'*.*',faDirectory,sr)=0 then
138   - try
139   - repeat
140   - if(sr.Attr and faDirectory)=faDirectory then
141   - sList.Add(sr.Name);
142   - until FindNext(sr)<>0;
143   - finally
144   - FindClose(sr);
145   - end;
146   -end;
147   -
148   -
149   -//Para gravar no Arquivo INI...
150   -function Tfrm_col_moni.SetValorChaveRegIni(p_Secao: String; p_Chave: String; p_Valor: String; p_Path : String): String;
151   -var Reg_Ini : TIniFile;
152   -begin
153   - FileSetAttr (p_Path,0);
154   - Reg_Ini := TIniFile.Create(p_Path);
155   -// Reg_Ini.WriteString(frm_col_moni.Crip(p_Secao), frm_col_moni.Crip(p_Chave), frm_col_moni.Crip(p_Valor));
156   - Reg_Ini.WriteString(p_Secao, p_Chave, p_Valor);
157   - Reg_Ini.Free;
158   -end;
159   -
160   -//Para buscar do Arquivo INI...
161   -// Marreta devido a limitações do KERNEL w9x no tratamento de arquivos texto e suas seções
162   -function Tfrm_col_moni.GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String;
163   -var
164   - FileText : TStringList;
165   - i, j, v_Size_Section, v_Size_Key : integer;
166   - v_SectionName, v_KeyName : string;
167   - begin
168   - Result := '';
169   - v_SectionName := '[' + p_SectionName + ']';
170   - v_Size_Section := strLen(PChar(v_SectionName));
171   - v_KeyName := p_KeyName + '=';
172   - v_Size_Key := strLen(PChar(v_KeyName));
173   - FileText := TStringList.Create;
174   - try
175   - FileText.LoadFromFile(p_IniFileName);
176   - For i := 0 To FileText.Count - 1 Do
177   - Begin
178   - if (LowerCase(Trim(PChar(Copy(FileText[i],1,v_Size_Section)))) = LowerCase(Trim(PChar(v_SectionName)))) then
179   - Begin
180   - For j := i to FileText.Count - 1 Do
181   - Begin
182   - if (LowerCase(Trim(PChar(Copy(FileText[j],1,v_Size_Key)))) = LowerCase(Trim(PChar(v_KeyName)))) then
183   - Begin
184   - Result := PChar(Copy(FileText[j],v_Size_Key + 1,strLen(PChar(FileText[j]))-v_Size_Key));
185   - Break;
186   - End;
187   - End;
188   - End;
189   - if (Result <> '') then break;
190   - End;
191   - finally
192   - FileText.Free;
193   - end;
194   - end;
195   -
196   -Function Tfrm_col_moni.Explode(Texto, Separador : String) : TStrings;
197   -var
198   - strItem : String;
199   - ListaAuxUTILS : TStrings;
200   - NumCaracteres, I : Integer;
201   -Begin
202   - ListaAuxUTILS := TStringList.Create;
203   - strItem := '';
204   - NumCaracteres := Length(Texto);
205   - For I := 0 To NumCaracteres Do
206   - If (Texto[I] = Separador) or (I = NumCaracteres) Then
207   - Begin
208   - If (I = NumCaracteres) then strItem := strItem + Texto[I];
209   - ListaAuxUTILS.Add(Trim(strItem));
210   - strItem := '';
211   - end
212   - Else strItem := strItem + Texto[I];
213   - Explode := ListaAuxUTILS;
214   -end;
215   -
216   -function Tfrm_col_moni.GetRootKey(strRootKey: String): HKEY;
217   -begin
218   - if Trim(strRootKey) = 'HKEY_LOCAL_MACHINE' Then Result := HKEY_LOCAL_MACHINE
219   - else if Trim(strRootKey) = 'HKEY_CLASSES_ROOT' Then Result := HKEY_CLASSES_ROOT
220   - else if Trim(strRootKey) = 'HKEY_CURRENT_USER' Then Result := HKEY_CURRENT_USER
221   - else if Trim(strRootKey) = 'HKEY_USERS' Then Result := HKEY_USERS
222   - else if Trim(strRootKey) = 'HKEY_CURRENT_CONFIG' Then Result := HKEY_CURRENT_CONFIG
223   - else if Trim(strRootKey) = 'HKEY_DYN_DATA' Then Result := HKEY_DYN_DATA;
224   -end;
225   -
226   -Function Tfrm_col_moni.RemoveCaracteresEspeciais(Texto : String) : String;
227   -var I : Integer;
228   - strAux : String;
229   -Begin
230   - For I := 0 To Length(Texto) Do
231   - if ord(Texto[I]) in [32..126] Then
232   - strAux := strAux + Texto[I]
233   - else strAux := strAux + ' '; // Coloca um espaço onde houver caracteres especiais
234   - Result := strAux;
235   -end;
236   -
237   -function Tfrm_col_moni.GetValorChaveRegEdit(Chave: String): Variant;
238   -var RegEditGet: TRegistry;
239   - RegDataType: TRegDataType;
240   - strRootKey, strKey, strValue, s: String;
241   - ListaAuxGet : TStrings;
242   - DataSize, Len, I : Integer;
243   -begin
244   - try
245   - Result := '';
246   - ListaAuxGet := frm_col_moni.Explode(Chave, '\');
247   -
248   - strRootKey := ListaAuxGet[0];
249   - For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\';
250   - strValue := ListaAuxGet[ListaAuxGet.Count - 1];
251   - if (strValue = '(Padrão)') then strValue := ''; //Para os casos de se querer buscar o valor default (Padrão)
252   - RegEditGet := TRegistry.Create;
253   -
254   - RegEditGet.Access := KEY_READ;
255   - RegEditGet.Rootkey := GetRootKey(strRootKey);
256   - if RegEditGet.OpenKeyReadOnly(strKey) then //teste
257   - Begin
258   - RegDataType := RegEditGet.GetDataType(strValue);
259   - if (RegDataType = rdString) or (RegDataType = rdExpandString) then Result := RegEditGet.ReadString(strValue)
260   - else if RegDataType = rdInteger then Result := RegEditGet.ReadInteger(strValue)
261   - else if (RegDataType = rdBinary) or (RegDataType = rdUnknown)
262   - then
263   - begin
264   - DataSize := RegEditGet.GetDataSize(strValue);
265   - if DataSize = -1 then exit;
266   - SetLength(s, DataSize);
267   - Len := RegEditGet.ReadBinaryData(strValue, PChar(s)^, DataSize);
268   - if Len <> DataSize then exit;
269   - Result := frm_col_moni.RemoveCaracteresEspeciais(s);
270   - end
271   - end;
272   - finally
273   - RegEditGet.CloseKey;
274   - RegEditGet.Free;
275   - ListaAuxGet.Free;
276   -
277   - end;
278   -end;
279   -
280   -
281   -// Simples rotinas de Criptografação e Descriptografação
282   -// Baixadas de http://www.costaweb.com.br/forum/delphi/474.shtml
283   -Function Tfrm_col_moni.Crip(PNome: String): String;
284   -Var
285   - TamI, TamF: Integer;
286   - SenA, SenM, SenD: String;
287   -Begin
288   - SenA := Trim(PNome);
289   - TamF := Length(SenA);
290   - if (TamF > 1) then
291   - begin
292   - SenM := '';
293   - SenD := '';
294   - For TamI := TamF Downto 1 do
295   - Begin
296   - SenM := SenM + Copy(SenA,TamI,1);
297   - End;
298   - SenD := Chr(TamF+95)+Copy(SenM,1,1)+Copy(SenA,1,1)+Copy(SenM,2,TamF-2)+Chr(75+TamF);
299   - end
300   - else SenD := SenA;
301   - Result := SenD;
302   -End;
303   -
304   -Function Tfrm_col_moni.DesCrip(PNome: String): String;
305   -Var
306   - TamI, TamF: Integer;
307   - SenA, SenM, SenD: String;
308   -Begin
309   - SenA := Trim(PNome);
310   - TamF := Length(SenA) - 2;
311   - if (TamF > 1) then
312   - begin
313   - SenM := '';
314   - SenD := '';
315   - SenA := Copy(SenA,2,TamF);
316   - SenM := Copy(SenA,1,1)+Copy(SenA,3,TamF)+Copy(SenA,2,1);
317   - For TamI := TamF Downto 1 do
318   - Begin
319   - SenD := SenD + Copy(SenM,TamI,1);
320   - End;
321   - end
322   - else SenD := SenA;
323   - Result := SenD;
324   -End;
325   -
326   -procedure Tfrm_col_moni.Log_Historico(strMsg : String);
327   -var
328   - HistoricoLog : TextFile;
329   - strDataArqLocal, strDataAtual : string;
330   -begin
331   - try
332   - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
333   - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
334   - {$IOChecks off}
335   - Reset(HistoricoLog); {Abre o arquivo texto}
336   - {$IOChecks on}
337   - if (IOResult <> 0) then // Arquivo não existe, será recriado.
338   - begin
339   - Rewrite (HistoricoLog);
340   - Append(HistoricoLog);
341   - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <=======================');
342   - end;
343   - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log')));
344   - DateTimeToString(strDataAtual , 'yyyymmdd', Date);
345   - if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual...
346   - begin
347   - Rewrite (HistoricoLog); //Cria/Recria o arquivo
348   - Append(HistoricoLog);
349   - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <=======================');
350   - end;
351   - Append(HistoricoLog);
352   - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + strMsg); {Grava a string Texto no arquivo texto}
353   - CloseFile(HistoricoLog); {Fecha o arquivo texto}
354   - except
355   - Log_Historico('Erro na gravação do log!');
356   - end;
357   -end;
358   -
359   -function Tfrm_col_moni.LastPos(SubStr, S: string): Integer;
360   -var
361   - Found, Len, Pos: integer;
362   -begin
363   - Pos := Length(S);
364   - Len := Length(SubStr);
365   - Found := 0;
366   - while (Pos > 0) and (Found = 0) do
367   - begin
368   - if Copy(S, Pos, Len) = SubStr then
369   - Found := Pos;
370   - Dec(Pos);
371   - end;
372   - LastPos := Found;
373   -end;
374   -
375   -
376   -procedure Tfrm_col_moni.Executa_Col_moni;
377   -var tstrTripa2, tstrTripa3, v_array1, v_array2, v_array3, v_array4 : TStrings;
378   - strAux, strAux1, strAux3, strAux4, strTripa, ValorChavePerfis, ValorChaveColetado, v_LetrasDrives, v_Data : String;
379   - intAux4, v1, v3, v_achei : Integer;
380   -
381   -begin
382   - Try
383   - // Verifica se deverá ser realizada a coleta de informações de sistemas monitorados neste
384   - // computador, perguntando ao agente gerente.
385   - Log_Historico('* Coletando informações de Sistemas Monitorados.');
386   - ShortDateFormat := 'dd/mm/yyyy';
387   - intAux4 := 1;
388   - strAux3 := '';
389   - ValorChavePerfis := '*';
390   - v_LetrasDrives := LetrasDrives;
391   -
392   - while ValorChavePerfis <> '' do
393   - begin
394   - strAux3 := 'SIS' + trim(inttostr(intAux4));
395   - strTripa := ''; // Conterá as informações a serem enviadas ao Gerente.
396   - // Obtenho do registro o valor que foi previamente armazenado
397   - ValorChavePerfis := Trim(GetValorChaveRegIni('Coleta',strAux3, p_path_cacic + 'cacic2.ini'));
398   -
399   - if (ValorChavePerfis <> '') then
400   - Begin
401   - //Atenção, OS ELEMENTOS DEVEM ESTAR DE ACORDO COM A ORDEM QUE SÃO TRATADOS NO MÓDULO GERENTE.
402   - tstrTripa2 := Explode(ValorChavePerfis,',');
403   - if (strAux <> '') then strAux := strAux + '#';
404   - strAux := strAux + trim(tstrTripa2[0]) + ',';
405   -
406   - //Coleta de Informação de Licença
407   - if (trim(tstrTripa2[2])='0') then //Vazio
408   - Begin
409   - strAux := strAux + ',';
410   - End;
411   -
412   - if (trim(tstrTripa2[2])='1') then //Caminho\Chave\Valor em Registry
413   - Begin
414   - strAux4 := '';
415   - Try
416   - strAux4 := Trim(GetValorChaveRegEdit(trim(tstrTripa2[3])));
417   - Except
418   - End;
419   - if (strAux4 = '') then strAux4 := '?';
420   - strAux := strAux + strAux4 + ',';
421   - End;
422   -
423   - if (trim(tstrTripa2[2])='2') then //Nome/Seção/Chave de Arquivo INI
424   - Begin
425   - Try
426   - if (LastPos('/',trim(tstrTripa2[3]))>0) then
427   - Begin
428   - tstrTripa3 := Explode(trim(tstrTripa2[3]),'/');
429   - //
430   - for v1:=1 to length(v_LetrasDrives) do
431   - Begin
432   - v_File := trim(tstrTripa3[0]);
433   - if (LastPos(':\',v_File)>0) then
434   - Begin
435   - v_Drive := Copy(v_File,1,3);
436   - v_File := Copy(v_File,4,Length(v_File));
437   - End
438   - else
439   - Begin
440   - v_Drive := v_LetrasDrives[v1] + ':';
441   - if (Copy(v_File,1,1)<>'\') then v_Drive := v_Drive + '\';
442   - v_File := Copy(v_File,1,Length(v_File));
443   - End;
444   -
445   - strAux1 := ExtractShortPathName(v_Drive + v_File);
446   - if (strAux1 = '') then
447   - begin
448   - if (SearchFile(v_Drive,v_File)) then
449   - Begin
450   - strAux1 := v_Res_Search;
451   - break;
452   - End;
453   - end
454   - else break;
455   - End;
456   -
457   -
458   - //
459   - strAux4 := Trim(GetValorChaveRegIni(tstrTripa3[1],tstrTripa3[2],strAux1));
460   - if (strAux4 = '') then strAux4 := '?';
461   - strAux := strAux + strAux4 + ',';
462   - End;
463   -
464   - if (LastPos('/',trim(tstrTripa2[3]))=0) then
465   - Begin
466   - strAux := strAux + 'Parâm.Lic.Incorreto,';
467   - End
468   - Except
469   - strAux := strAux + 'Parâm.Lic.Incorreto,';
470   - End;
471   - End;
472   -
473   - //Coleta de Informação de Instalação
474   - if (trim(tstrTripa2[5])='0') then //Vazio
475   - Begin
476   - strAux := strAux + ',';
477   - End;
478   -
479   - if (trim(tstrTripa2[5])='1') or (trim(tstrTripa2[5]) = '2') then //Nome de Executável OU Nome de Arquivo de Configuração (CADPF!!!)
480   - Begin
481   - strAux1 := '';
482   - for v1:=1 to length(v_LetrasDrives) do
483   - Begin
484   - v_File := trim(tstrTripa2[6]);
485   - if (LastPos(':\',v_File)>0) then
486   - Begin
487   - v_Drive := Copy(v_File,1,3);
488   - v_File := Copy(v_File,4,Length(v_File));
489   - End
490   - else
491   - Begin
492   - v_Drive := v_LetrasDrives[v1] + ':';
493   - if (Copy(v_File,1,1)<>'\') then v_Drive := v_Drive + '\';
494   - v_File := Copy(v_File,1,Length(v_File));
495   - End;
496   -
497   - strAux1 := ExtractShortPathName(v_Drive + v_File);
498   - if (strAux1 = '') then
499   - begin
500   - if (SearchFile(v_Drive,v_File)) then
501   - Begin
502   - strAux1 := v_Res_Search;
503   - break;
504   - End;
505   - end
506   - else break;
507   -
508   - End;
509   -
510   - if (strAux1 <> '') then strAux := strAux + 'S,';
511   - if (strAux1 = '') then strAux := strAux + 'N,';
512   - strAux1 := '';
513   - End;
514   -
515   - if (trim(tstrTripa2[5])='3') then //Caminho\Chave\Valor em Registry
516   - Begin
517   - strAux1 := '';
518   - Try
519   - strAux1 := Trim(GetValorChaveRegEdit(trim(tstrTripa2[5])));
520   - Except
521   - End;
522   - if (strAux1 <> '') then strAux := strAux + 'S,';
523   - if (strAux1 = '') then strAux := strAux + 'N,';
524   - strAux1 := '';
525   - End;
526   -
527   - //Coleta de Informação de Versão
528   - if (trim(tstrTripa2[7])='0') then //Vazio
529   - Begin
530   - strAux := strAux + ',';
531   - End;
532   -
533   - if (trim(tstrTripa2[7])='1') then //Data de Arquivo
534   - Begin
535   - strAux1 := '';
536   - for v1:=1 to length(v_LetrasDrives) do
537   - Begin
538   - v_File := trim(tstrTripa2[8]);
539   - if (LastPos(':\',v_File)>0) then
540   - Begin
541   - v_Drive := Copy(v_File,1,3);
542   - v_File := Copy(v_File,4,Length(v_File));
543   - End
544   - else
545   - Begin
546   - v_Drive := v_LetrasDrives[v1] + ':';
547   - if (Copy(v_File,1,1)<>'\') then v_Drive := v_Drive + '\';
548   - v_File := Copy(v_File,1,Length(v_File));
549   - End;
550   -
551   - strAux1 := ExtractShortPathName(v_Drive + v_File);
552   - if (strAux1 = '') then
553   - begin
554   - if (SearchFile(v_Drive,v_File)) then
555   - Begin
556   - strAux1 := v_Res_Search;
557   - break;
558   - End;
559   - end
560   - else break;
561   - End;
562   - if (strAux1 <> '') then
563   - Begin
564   - v_Data := StringReplace(DateToStr(FileDateToDateTime(FileAge(strAux1))),'.','/',[rfReplaceAll]);
565   - v_Data := StringReplace(v_Data,'-','/',[rfReplaceAll]);
566   - strAux := strAux + v_Data + ',';
567   - v_Data := '';
568   - End;
569   - if (strAux1 = '') then strAux := strAux + '?,';
570   - strAux1 := '';
571   - End;
572   -
573   - if (trim(tstrTripa2[7])='2') then //Caminho\Chave\Valor em Registry
574   - Begin
575   - strAux1 := '';
576   - Try
577   - strAux1 := Trim(GetValorChaveRegEdit(trim(tstrTripa2[8])));
578   - Except
579   - End;
580   - if (strAux1 <> '') then strAux := strAux + strAux1 + ',';
581   - if (strAux1 = '') then strAux := strAux + '?,';
582   - strAux1 := '';
583   - End;
584   -
585   - if (trim(tstrTripa2[7])='3') then //Nome/Seção/Chave de Arquivo INI
586   - Begin
587   - Try
588   - if (LastPos('/',trim(tstrTripa2[8]))>0) then
589   - Begin
590   - tstrTripa3 := Explode(trim(tstrTripa2[8]),'/');
591   - //
592   - for v1:=1 to length(v_LetrasDrives) do
593   - Begin
594   - v_File := trim(tstrTripa3[0]);
595   - if (LastPos(':\',v_File)>0) then
596   - Begin
597   - v_Drive := Copy(v_File,1,3);
598   - v_File := Copy(v_File,4,Length(v_File));
599   - End
600   - else
601   - Begin
602   - v_Drive := v_LetrasDrives[v1] + ':';
603   - if (Copy(v_File,1,1)<>'\') then v_Drive := v_Drive + '\';
604   - v_File := Copy(v_File,1,Length(v_File));
605   - End;
606   -
607   -
608   - strAux1 := ExtractShortPathName(v_Drive + v_File);
609   - if (strAux1 = '') then
610   - begin
611   - if (SearchFile(v_Drive,v_File)) then
612   - Begin
613   - strAux1 := v_Res_Search;
614   - break;
615   - End;
616   - end
617   - else break;
618   - End;
619   -
620   - //
621   - strAux4 := Trim(GetValorChaveRegIni(tstrTripa3[1],tstrTripa3[2],strAux1));
622   - if (strAux4 = '') then strAux4 := '?';
623   - strAux := strAux + strAux4 + ',';
624   - End
625   - else
626   - Begin
627   - strAux := strAux + 'Parâm.Versao Incorreto,';
628   - End;
629   - Except
630   - End;
631   - End;
632   -
633   - //Coleta de Informação de Engine
634   - if (trim(tstrTripa2[9])='.') then //Vazio
635   - Begin
636   - strAux := strAux + ',';
637   - End;
638   - //O ponto é proposital para quando o último parâmetro vem vazio do Gerente!!! :)
639   - if (trim(tstrTripa2[9])<>'.') then //Arquivo para Versão de Engine
640   - Begin
641   - for v1:=1 to length(v_LetrasDrives) do
642   - Begin
643   - v_File := trim(tstrTripa2[9]);
644   - if (LastPos(':\',v_File)>0) then
645   - Begin
646   - v_Drive := Copy(v_File,1,3);
647   - v_File := Copy(v_File,4,Length(v_File));
648   - End
649   - else
650   - Begin
651   - v_Drive := v_LetrasDrives[v1] + ':';
652   - if (Copy(v_File,1,1)<>'\') then v_Drive := v_Drive + '\';
653   - v_File := Copy(v_File,1,Length(v_File));
654   - End;
655   -
656   - strAux1 := ExtractShortPathName(v_Drive + v_File);
657   - if (strAux1 = '') then
658   - begin
659   - if (SearchFile(v_Drive,v_File)) then
660   - Begin
661   - strAux1 := v_Res_Search;
662   - break;
663   - End;
664   - end
665   - else break;
666   - End;
667   - if (strAux1 <> '') then
668   - Begin
669   - tstrTripa3 := Explode(getVersionInfo(strAux1), '.'); // Pego só os dois primeiros dígitos. Por exemplo: 6.640.0.1001 vira 6.640.
670   - strAux := strAux + tstrTripa3[0] + '.' + tstrTripa3[1];
671   - End;
672   - End;
673   -
674   - //Coleta de Informação de Pattern
675   - //O ponto é proposital para quando o último parâmetro vem vazio do Gerente!!! :)
676   - strAux1 := '';
677   - if (trim(tstrTripa2[10])<>'.') then //Arquivo para Versão de Pattern
678   - Begin
679   - for v1:=1 to length(v_LetrasDrives) do
680   - Begin
681   - v_File := trim(tstrTripa2[10]);
682   - if (LastPos(':\',v_File)>0) then
683   - Begin
684   - v_Drive := Copy(v_File,1,3);
685   - v_File := Copy(v_File,4,Length(v_File));
686   - End
687   - else
688   - Begin
689   - v_Drive := v_LetrasDrives[v1] + ':';
690   - if (Copy(v_File,1,1)<>'\') then v_Drive := v_Drive + '\';
691   - v_File := Copy(v_File,1,Length(v_File));
692   - End;
693   -
694   - strAux1 := ExtractShortPathName(v_Drive + v_File);
695   - if (strAux1 = '') then
696   - begin
697   - if (SearchFile(v_Drive, v_File)) then
698   - Begin
699   - strAux1 := v_Res_Search;
700   - break;
701   - End;
702   - end
703   - else break;
704   -
705   - End;
706   - End;
707   - if (strAux1 <> '') then
708   - Begin
709   - tstrTripa3 := Explode(getVersionInfo(strAux1), '.'); // Pego só os dois primeiros dígitos. Por exemplo: 6.640.0.1001 vira 6.640.
710   - strAux := strAux + tstrTripa3[0] + '.' + tstrTripa3[1];
711   - End;
712   - if (strAux1 = '') then strAux := strAux + ',';
713   - strAux1 := '';
714   - End;
715   - intAux4 := intAux4 + 1;
716   - End;
717   - ValorChaveColetado := Trim(GetValorChaveRegIni('Coleta','Sistemas_Monitorados', p_path_cacic + 'cacic2.ini'));
718   - If (GetValorChaveRegIni('Configs','IN_COLETA_FORCADA_MONI',p_path_cacic_ini)='S') or (trim(strAux) <> trim(ValorChaveColetado)) Then
719   - Begin
720   - if (trim(ValorChaveColetado) <> '') then
721   - begin
722   - v_array1 := Explode(strAux, '#');
723   - strAux := '';
724   - v_array3 := Explode(ValorChaveColetado, '#');
725   - for v1 := 0 to (v_array1.count)-1 do
726   - Begin
727   - v_array2 := Explode(v_array1[v1], ',');
728   - v_achei := 0;
729   - for v3 := 0 to (v_array3.count)-1 do
730   - Begin
731   - v_array4 := Explode(v_array3[v3], ',');
732   - if (v_array4=v_array2) then v_achei := 1;
733   - End;
734   - if (v_achei = 0) then
735   - Begin
736   - if (strAUX <> '') then strAUX := strAUX + '#';
737   - strAUX := strAUX + v_array1[v1];
738   - End;
739   - End;
740   - end;
741   - frm_col_moni.SetValorChaveRegIni('Col_Moni','Sistemas_Monitorados', strAux,frm_col_moni.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_moni.ini');
742   - end
743   - else frm_col_moni.SetValorChaveRegIni('Col_Moni','nada', 'nada',frm_col_moni.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_moni.ini');
744   - application.Terminate;
745   - Except
746   - Begin
747   - frm_col_moni.SetValorChaveRegIni('Col_Moni','nada', 'nada',frm_col_moni.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_moni.ini');
748   - application.Terminate;
749   - End;
750   - End;
751   -END;
752   -
753   -procedure Tfrm_col_moni.FormCreate(Sender: TObject);
754   -var tstrTripa1 : TStrings;
755   - intAux : integer;
756   -begin
757   -
758   - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini
759   - tstrTripa1 := explode(ExtractFilePath(Application.Exename),'\');
760   - p_path_cacic := '';
761   - For intAux := 0 to tstrTripa1.Count -2 do
762   - begin
763   - p_path_cacic := p_path_cacic + tstrTripa1[intAux] + '\';
764   - end;
765   - p_path_cacic_ini := p_path_cacic + 'cacic2.ini';
766   - Application.ShowMainForm := false;
767   -
768   - Try
769   - Executa_Col_moni;
770   - Except
771   - frm_col_moni.SetValorChaveRegIni('Col_Moni','nada', 'nada',frm_col_moni.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_moni.ini');
772   - application.Terminate;
773   - End;
774   -end;
775   -end.
776   -
col_undi/col_undi.dpr
... ... @@ -44,6 +44,8 @@ var p_path_cacic,
44 44 var v_tstrCipherOpened,
45 45 v_tstrCipherOpened1 : TStrings;
46 46  
  47 +var g_oCacic : TCACIC;
  48 +
47 49 // Some constants that are dependant on the cipher being used
48 50 // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
49 51 const KeySize = 32; // 32 bytes = 256 bits
... ... @@ -199,14 +201,9 @@ begin
199 201 // Criação do arquivo .DAT
200 202 Rewrite (v_DatFile);
201 203 Append(v_DatFile);
202   -
203   - //v_Cipher := TDCP_rijndael.Create(nil);
204   - //v_Cipher.InitStr(v_CipherKey,TDCP_md5);
  204 +
205 205 v_strCipherOpenImploded := Implode(p_tstrCipherOpened,'=CacicIsFree=');
206 206 v_strCipherClosed := EnCrypt(v_strCipherOpenImploded);
207   - //v_strCipherClosed := v_Cipher.EncryptString(v_strCipherOpenImploded);
208   - //v_Cipher.Burn;
209   - //v_Cipher.Free;
210 207  
211 208 Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto}
212 209  
... ... @@ -244,66 +241,6 @@ Begin
244 241 Explode := ListaAuxUTILS;
245 242 end;
246 243  
247   -
248   -function GetWinVer: Integer;
249   -const
250   - { operating system (OS)constants }
251   - cOsUnknown = 0;
252   - cOsWin95 = 1;
253   - cOsWin95OSR2 = 2; // Não implementado.
254   - cOsWin98 = 3;
255   - cOsWin98SE = 4;
256   - cOsWinME = 5;
257   - cOsWinNT = 6;
258   - cOsWin2000 = 7;
259   - cOsXP = 8;
260   -var
261   - osVerInfo: TOSVersionInfo;
262   - majorVer, minorVer: Integer;
263   -begin
264   - Result := cOsUnknown;
265   - { set operating system type flag }
266   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
267   - if GetVersionEx(osVerInfo) then
268   - begin
269   - majorVer := osVerInfo.dwMajorVersion;
270   - minorVer := osVerInfo.dwMinorVersion;
271   - case osVerInfo.dwPlatformId of
272   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
273   - begin
274   - if majorVer <= 4 then
275   - Result := cOsWinNT
276   - else if (majorVer = 5) and (minorVer = 0) then
277   - Result := cOsWin2000
278   - else if (majorVer = 5) and (minorVer = 1) then
279   - Result := cOsXP
280   - else
281   - Result := cOsUnknown;
282   - end;
283   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
284   - begin
285   - if (majorVer = 4) and (minorVer = 0) then
286   - Result := cOsWin95
287   - else if (majorVer = 4) and (minorVer = 10) then
288   - begin
289   - if osVerInfo.szCSDVersion[1] = 'A' then
290   - Result := cOsWin98SE
291   - else
292   - Result := cOsWin98;
293   - end
294   - else if (majorVer = 4) and (minorVer = 90) then
295   - Result := cOsWinME
296   - else
297   - Result := cOsUnknown;
298   - end;
299   - else
300   - Result := cOsUnknown;
301   - end;
302   - end
303   - else
304   - Result := cOsUnknown;
305   -end;
306   -
307 244 Function CipherOpen(p_DatFileName : string) : TStrings;
308 245 var v_DatFile : TextFile;
309 246 v_strCipherOpened,
... ... @@ -330,7 +267,7 @@ begin
330 267 if (trim(v_strCipherOpened)<>'') then
331 268 Result := explode(v_strCipherOpened,'=CacicIsFree=')
332 269 else
333   - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  270 + Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
334 271  
335 272 if Result.Count mod 2 <> 0 then
336 273 Result.Add('');
... ... @@ -346,9 +283,8 @@ begin
346 283 p_tstrCipherOpened.Add(p_Chave);
347 284 p_tstrCipherOpened.Add(p_Valor);
348 285 End;
349   -//DEBUG
350   -//log_diario('Gravando: '+p_Chave +' => '+p_Valor);
351 286 end;
  287 +
352 288 Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String;
353 289 begin
354 290 if (p_tstrCipherOpened.IndexOf(p_Chave)<>-1) then
... ... @@ -357,7 +293,6 @@ begin
357 293 Result := '';
358 294 end;
359 295  
360   -
361 296 function GetFolderDate(Folder: string): TDateTime;
362 297 var
363 298 Rec: TSearchRec;
... ... @@ -379,8 +314,6 @@ begin
379 314 end;
380 315 end;
381 316  
382   -
383   -
384 317 function GetRootKey(strRootKey: String): HKEY;
385 318 begin
386 319 /// Encontrar uma maneira mais elegante de fazer esses testes.
... ... @@ -446,8 +379,6 @@ begin
446 379 end;
447 380 end;
448 381  
449   -
450   -
451 382 procedure Grava_Debugs(strMsg : String);
452 383 var
453 384 DebugsFile : TextFile;
... ... @@ -597,12 +528,11 @@ const
597 528 var
598 529 tstrTripa1 : TStrings;
599 530 intAux : integer;
600   - oCacic : TCACIC;
601 531  
602 532 begin
603   - oCacic := TCACIC.Create();
  533 + g_oCacic := TCACIC.Create();
604 534  
605   - if( not oCacic.isAppRunning( CACIC_APP_NAME ) ) then
  535 + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then
606 536 if (ParamCount>0) then
607 537 Begin
608 538 For intAux := 1 to ParamCount do
... ... @@ -650,6 +580,6 @@ begin
650 580 End;
651 581 End;
652 582  
653   - oCacic.Free();
  583 + g_oCacic.Free();
654 584  
655 585 end.
... ...
ger_cols/ger_cols.dpr
... ... @@ -330,12 +330,6 @@ Begin
330 330 End;
331 331 Implode := strAux;
332 332 end;
333   -function abstraiCSD(p_te_so : String) : integer;
334   - var tstrTe_so : tstrings;
335   - Begin
336   - tstrTe_so := Explode(p_te_so, '.');
337   - Result := StrToInt(tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]);
338   - End;
339 333  
340 334 Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String; p_tstrCipherOpened : TStrings);
341 335 var v_Aux : string;
... ... @@ -458,89 +452,6 @@ begin
458 452 End;
459 453 end;
460 454  
461   -function GetWinVer: Integer;
462   -const
463   - { operating system (OS)constants }
464   - cOsUnknown = 0;
465   - cOsWin95 = 1;
466   - cOsWin95OSR2 = 2; // Não implementado.
467   - cOsWin98 = 3;
468   - cOsWin98SE = 4;
469   - cOsWinME = 5;
470   - cOsWinNT = 6;
471   - cOsWin2000 = 7;
472   - cOsXP = 8;
473   - cOsWinServer2003 = 13;
474   -var
475   - osVerInfo: TOSVersionInfo;
476   - platformID,
477   - majorVer,
478   - minorVer : Integer;
479   - CSDVersion : String;
480   -begin
481   - Result := cOsUnknown;
482   - { set operating system type flag }
483   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
484   - if GetVersionEx(osVerInfo) then
485   - begin
486   - platformId := osVerInfo.dwPlatformId;
487   - majorVer := osVerInfo.dwMajorVersion;
488   - minorVer := osVerInfo.dwMinorVersion;
489   - CSDVersion := trim(osVerInfo.szCSDVersion);
490   -
491   - case osVerInfo.dwPlatformId of
492   - VER_PLATFORM_WIN32_NT: {Windows NT Like}
493   - begin
494   - if majorVer <= 4 then
495   - Result := cOsWinNT
496   - else if (majorVer = 5) and (minorVer = 0) then
497   - Result := cOsWin2000
498   - else if (majorVer = 5) and (minorVer = 1) then
499   - Result := cOsXP
500   - else if (majorVer = 5) and (minorVer = 2) then
501   - Result := cOsWinServer2003
502   - else
503   - Result := cOsUnknown;
504   -
505   - end;
506   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
507   - begin
508   - if (majorVer = 4) and (minorVer = 0) then
509   - Result := cOsWin95
510   - else if (majorVer = 4) and (minorVer = 10) then
511   - begin
512   - if osVerInfo.szCSDVersion[1] = 'A' then
513   - Result := cOsWin98SE
514   - else
515   - Result := cOsWin98;
516   - end
517   - else if (majorVer = 4) and (minorVer = 90) then
518   - Result := cOsWinME
519   - else
520   - Result := cOsUnknown;
521   -
522   - end;
523   -
524   - else
525   - Result := cOsUnknown;
526   - end;
527   - end
528   - else
529   - Result := cOsUnknown;
530   -
531   - // A partir da versão 2.2.0.24, defino o valor da ID Interna e atribuo-a sem o CSDVersion à versão externa
532   - v_te_so := IntToStr(platformId) + '.' +
533   - IntToStr(majorVer) + '.' +
534   - IntToStr(minorVer) +
535   - ifThen(CSDVersion='','','.'+CSDVersion);
536   -
537   - {
538   - Forço o envio do identificador interno
539   - if (Result = 0) then
540   - }
541   - Result := abstraiCSD(v_te_so);
542   -end;
543   -
544 455 procedure Matar(v_dir,v_files: string);
545 456 var SearchRec: TSearchRec;
546 457 Result: Integer;
... ... @@ -639,7 +550,7 @@ begin
639 550 if (trim(v_strCipherOpened)<>'') then
640 551 Result := explode(v_strCipherOpened,'=CacicIsFree=')
641 552 else
642   - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  553 + Result := explode('Configs.ID_SO=CacicIsFree='+g_oCacic.getWindowsStrId()+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
643 554  
644 555 if Result.Count mod 2 = 0 then
645 556 Result.Add('');
... ... @@ -1215,8 +1126,6 @@ Function ComunicaServidor(URL : String; Request : TStringList; MsgAcao: String)
1215 1126 var Response_CS : TStringStream;
1216 1127 strEndereco,
1217 1128 v_Endereco_WS,
1218   - v_Aux,
1219   - v_Aux1,
1220 1129 strAux : String;
1221 1130 idHTTP1 : TIdHTTP;
1222 1131 intAux : integer;
... ... @@ -1231,13 +1140,12 @@ Begin
1231 1140 // A partir da versão 2.0.2.18+ envio um Classificador indicativo de dados compactados...
1232 1141 v_AuxRequest.Values['cs_compress'] := GetValorDatMemoria('Configs.CS_COMPRESS',v_tstrCipherOpened);
1233 1142  
1234   - intAux := GetWinVer;
1235 1143 strAux := GetValorDatMemoria('TcpIp.TE_IP', v_tstrCipherOpened);
1236 1144 if (strAux = '') then
1237 1145 strAux := 'A.B.C.D'; // Apenas para forçar que o Gerente extraia via _SERVER[REMOTE_ADDR]
1238 1146  
1239 1147 v_AuxRequest.Values['te_node_address'] := StringReplace(EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1240   - v_AuxRequest.Values['id_so'] := StringReplace(EnCrypt(IntToStr(intAux) ,l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1148 + v_AuxRequest.Values['id_so'] := StringReplace(EnCrypt(g_oCacic.getWindowsStrId() , l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
1241 1149 // Tratamentos de valores para tráfego POST:
1242 1150 // v_te_so => transformar ' ' em <ESPACE> Razão: o mmcrypt se perde quando encontra ' ' (espaço)
1243 1151 //v_te_so := StringReplace(v_te_so,' ','<ESPACE>',[rfReplaceAll]);
... ... @@ -1792,7 +1700,8 @@ procedure Patrimnio1Click(Sender: TObject);
1792 1700 begin
1793 1701 SetValorDatMemoria('Patrimonio.dt_ultima_renovacao_patrim','', v_tstrCipherOpened);
1794 1702 if ChecaAgente(p_path_cacic + 'modulos', 'ini_cols.exe') then
1795   - WinExec(PChar(p_path_cacic + 'modulos\ini_cols.exe /p_CipherKey='+v_CipherKey+ ' /p_ModulosOpcoes=col_patr,wait,user#'),SW_HIDE);
  1703 + g_oCacic.createSampleProcess( p_path_cacic + 'modulos\ini_cols.exe /p_CipherKey=' + v_CipherKey +
  1704 + ' /p_ModulosOpcoes=col_patr,wait,user#', CACIC_PROCESS_WAIT );
1796 1705 end;
1797 1706  
1798 1707 procedure ChecaCipher;
... ... @@ -2929,8 +2838,8 @@ Begin
2929 2838 Finalizar(false);
2930 2839 Matar(p_path_cacic + 'temp\','*.dat');
2931 2840 CriaTXT(p_path_cacic+'temp','coletas');
2932   - WinExec(PChar(p_path_cacic + 'modulos\ini_cols.exe /p_CipherKey='+v_CipherKey+' /p_ModulosOpcoes='+v_ModulosOpcoes), SW_HIDE);
2933   - Sair;
  2841 + g_oCacic.createSampleProcess( p_path_cacic + 'modulos\ini_cols.exe /p_CipherKey=' + v_CipherKey +
  2842 + ' /p_ModulosOpcoes=' + v_ModulosOpcoes, CACIC_PROCESS_WAIT );
2934 2843 End;
2935 2844  
2936 2845 end
... ... @@ -3326,9 +3235,11 @@ Begin
3326 3235  
3327 3236 if (intAux = 0) then
3328 3237 log_diario('Sem informações para envio ao Gerente WEB.')
3329   - // Atualizo a data de última coleta
3330   - else
  3238 + else begin
  3239 + // Atualiza a data de última coleta
3331 3240 SetValorDatMemoria('Configs.DT_HR_ULTIMA_COLETA',FormatDateTime('YYYYmmddHHnnss', Now), v_tstrCipherOpened);
  3241 + log_diario('Todos os dados coletados foram enviados ao Gerente WEB.');
  3242 + end;
3332 3243 end;
3333 3244 Except
3334 3245 Begin
... ... @@ -3398,7 +3309,7 @@ begin
3398 3309 v_tstrCipherOpened := CipherOpen(v_DatFileName);
3399 3310  
3400 3311 // Não tirar desta posição
3401   - SetValorDatMemoria('Configs.ID_SO',IntToStr(GetWinVer), v_tstrCipherOpened);
  3312 + SetValorDatMemoria('Configs.ID_SO',g_oCacic.getWindowsStrId(), v_tstrCipherOpened);
3402 3313  
3403 3314 v_scripter := 'wscript.exe';
3404 3315 // A existência e bloqueio do arquivo abaixo evitará que Cacic2.exe chame o Ger_Cols quando este estiver em funcionamento
... ...
ini_cols/ini_cols.dpr
... ... @@ -518,36 +518,8 @@ begin
518 518 v_Aux := v_tstrModuloOpcao[0]+'.exe /p_CipherKey='+v_CipherKey+ ' /p_Option='+v_tstrModuloOpcao[2];
519 519 log_DEBUG('Chamando "' + v_tstrModuloOpcao[0]+'.exe /p_CipherKey=*****" /p_Option='+v_tstrModuloOpcao[2]);
520 520  
521   - WinExec(PChar(v_Aux), SW_HIDE);
522   -
523   - if (v_tstrModuloOpcao[1]='wait') then
524   - while not FileExists(p_path_cacic + 'temp\'+v_tstrModuloOpcao[0]+'.dat') do
525   - Sleep(2000)
526   - else
527   - Begin
528   - v_ContaTempo := 0;
529   - while not FileExists(p_path_cacic + 'temp\'+v_tstrModuloOpcao[0]+'.dat') and
530   - ((v_ContaTempo/60)< v_Tolerancia) do // Tolerância para a coleta
531   - Begin
532   - Sleep(2000);
533   - v_ContaTempo := v_ContaTempo + 2;
534   - End;
535   - End;
536   - End;
  521 + oCacic.createSampleProcess( p_path_cacic + '\modulos\' + v_aux, CACIC_PROCESS_WAIT );
537 522  
538   - For intAux := 0 to v_tstrModulosOpcoes.Count -1 do
539   - Begin
540   - v_tstrModuloOpcao := explode(v_tstrModulosOpcoes[intAux],',');
541   - v_Aux := p_path_cacic + 'temp\'+v_tstrModuloOpcao[0]+'.dat';
542   - if (FileExists(v_Aux)) then
543   - Begin
544   - log_DEBUG('Chamando "'+'ger_cols.exe /p_CipherKey=*****');
545   - WinExec(PChar('ger_cols.exe /p_CipherKey='+v_CipherKey), SW_HIDE);
546   - // Fecha o arquivo temp\aguarde_INI.txt
547   - CloseFile(v_Aguarde);
548   - Matar(p_path_cacic+'temp\','aguarde_INI');
549   - break;
550   - End;
551 523 End;
552 524 except
553 525 end;
... ...
mapa/main_mapa.pas
... ... @@ -43,17 +43,18 @@ uses IniFiles,
43 43 DCPbase64,
44 44 ExtCtrls,
45 45 Graphics,
46   - Dialogs;
  46 + Dialogs,
  47 + CACIC_Library;
47 48  
48 49 var strCipherClosed,
49 50 strCipherOpened,
50   - strPathCacic,
51   - str_te_so : string;
  51 + strPathCacic : string;
52 52  
53 53 var intPausaPadrao : integer;
54 54  
55 55 var boolDebugs : boolean;
56 56  
  57 +var g_oCacic : TCACIC;
57 58  
58 59 // Some constants that are dependant on the cipher being used
59 60 // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
... ... @@ -111,7 +112,6 @@ type
111 112 function HomeDrive : string;
112 113 Function Implode(p_Array : TStrings ; p_Separador : String) : String;
113 114 Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String;
114   - function GetWinVer: Integer;
115 115 Function Explode(Texto, Separador : String) : TStrings;
116 116 Function CipherOpen(p_DatFileName : string) : TStrings;
117 117 Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String;
... ... @@ -456,9 +456,8 @@ end;
456 456  
457 457 procedure TfrmMapaCacic.Sair;
458 458 Begin
459   - application.Terminate;
460   -// FreeMemory(0);
461   -// Halt(0);
  459 + g_oCacic.Free();
  460 + Application.Terminate;
462 461 End;
463 462  
464 463 procedure TfrmMapaCacic.Finalizar(p_pausa:boolean);
... ... @@ -818,79 +817,6 @@ begin
818 817 except
819 818 end;
820 819 end;
821   -function TfrmMapaCacic.GetWinVer: Integer;
822   -const
823   - { operating system (OS)constants }
824   - cOsUnknown = 0;
825   - cOsWin95 = 1;
826   - cOsWin95OSR2 = 2; // Não implementado.
827   - cOsWin98 = 3;
828   - cOsWin98SE = 4;
829   - cOsWinME = 5;
830   - cOsWinNT = 6;
831   - cOsWin2000 = 7;
832   - cOsXP = 8;
833   -
834   -var
835   - osVerInfo: TOSVersionInfo;
836   - platformID,
837   - majorVer,
838   - minorVer: Integer;
839   - CSDVersion : String;
840   -begin
841   - Result := cOsUnknown;
842   - { set operating system type flag }
843   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
844   - if GetVersionEx(osVerInfo) then
845   - begin
846   - platformId := osVerInfo.dwPlatformId;
847   - majorVer := osVerInfo.dwMajorVersion;
848   - minorVer := osVerInfo.dwMinorVersion;
849   - CSDVersion := trim(osVerInfo.szCSDVersion);
850   -
851   - case osVerInfo.dwPlatformId of
852   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
853   - begin
854   - if majorVer <= 4 then
855   - Result := cOsWinNT
856   - else if (majorVer = 5) and (minorVer = 0) then
857   - Result := cOsWin2000
858   - else if (majorVer = 5) and (minorVer = 1) then
859   - Result := cOsXP
860   - else
861   - Result := cOsUnknown;
862   - end;
863   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
864   - begin
865   - if (majorVer = 4) and (minorVer = 0) then
866   - Result := cOsWin95
867   - else if (majorVer = 4) and (minorVer = 10) then
868   - begin
869   - if osVerInfo.szCSDVersion[1] = 'A' then
870   - Result := cOsWin98SE
871   - else
872   - Result := cOsWin98;
873   - end
874   - else if (majorVer = 4) and (minorVer = 90) then
875   - Result := cOsWinME
876   - else
877   - Result := cOsUnknown;
878   - end;
879   - else
880   - Result := cOsUnknown;
881   - end;
882   - end
883   - else
884   - Result := cOsUnknown;
885   -
886   - // Defino o valor da ID Interna
887   - str_te_so := IntToStr(platformId) + '.' +
888   - IntToStr(majorVer) + '.' +
889   - IntToStr(minorVer) +
890   - IfThen(CSDVersion='','','.'+CSDVersion);
891   -
892   -end;
893   -
894 820  
895 821 Function TfrmMapaCacic.CipherOpen(p_DatFileName : string) : TStrings;
896 822 var v_DatFile : TextFile;
... ... @@ -919,7 +845,7 @@ begin
919 845 if (trim(strCipherOpened)<>'') then
920 846 Result := explode(strCipherOpened,'=CacicIsFree=')
921 847 else
922   - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  848 + Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
923 849  
924 850 if Result.Count mod 2 = 0 then
925 851 Result.Add('');
... ... @@ -1388,25 +1314,13 @@ begin
1388 1314  
1389 1315 tstrAux.Free;
1390 1316  
1391   -// Assim, o envio será incondicional! - 01/12/2006 - Anderson Peterle
1392   -// if (strAux1 <> strId_unid_organizacional_nivel1) or
1393   -// (strAux2 <> strId_unid_organizacional_nivel2) or
1394   -// (ed_te_localizacao_complementar.Text <> strTe_localizacao_complementar) or
1395   -// (ed_te_info_patrimonio1.Text <> strTe_info_patrimonio1) or
1396   -// (ed_te_info_patrimonio2.Text <> strTe_info_patrimonio2) or
1397   -// (ed_te_info_patrimonio3.Text <> strTe_info_patrimonio3) or
1398   -// (ed_te_info_patrimonio4.Text <> strTe_info_patrimonio4) or
1399   -// (ed_te_info_patrimonio5.Text <> strTe_info_patrimonio5) or
1400   -// (ed_te_info_patrimonio6.Text <> strTe_info_patrimonio6) then
1401   -// begin
1402   -
1403 1317 Mensagem('Enviando Informações Coletadas ao Banco de Dados...',false,intPausaPadrao div 3);
1404 1318  
1405 1319 // Envio dos Dados Coletados ao Banco de Dados
1406 1320 tstrListAux := TStringList.Create;
1407 1321 tstrListAux.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened));
1408 1322 tstrListAux.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened));
1409   - tstrListAux.Values['te_so'] := frmMapaCacic.EnCrypt(str_te_so);
  1323 + tstrListAux.Values['te_so'] := frmMapaCacic.EnCrypt(g_oCacic.getWindowsStrId());
1410 1324 tstrListAux.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened));
1411 1325 tstrListAux.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened));
1412 1326 tstrListAux.Values['te_nome_computador'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR' , frmMapaCacic.tStringsCipherOpened));
... ... @@ -1746,9 +1660,10 @@ var intAux : integer;
1746 1660 strRetorno : String;
1747 1661 Request_mapa : TStringList;
1748 1662 begin
  1663 + g_oCacic := TCACIC.Create();
1749 1664 frmMapaCacic.lbVersao.Caption := 'Versão: ' + frmMapaCacic.GetVersionInfo(ParamStr(0));
1750 1665 log_DEBUG('Versão do MapaCacic: '+frmMapaCacic.lbVersao.Caption);
1751   - if (GetWinVer > 5) and not IsAdmin then
  1666 + if (g_oCacic.isWindowsNTPlataform()) and (not g_oCacic.isWindowsAdmin()) then
1752 1667 Begin
1753 1668 MessageDLG(#13#10+'ATENÇÃO! Essa aplicação requer execução com nível administrativo.',mtError,[mbOK],0);
1754 1669 Sair;
... ... @@ -1805,7 +1720,7 @@ begin
1805 1720 Request_mapa := TStringList.Create;
1806 1721 Request_mapa.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened));
1807 1722 Request_mapa.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened));
1808   - Request_mapa.Values['te_so'] := frmMapaCacic.EnCrypt(str_te_so);
  1723 + Request_mapa.Values['te_so'] := frmMapaCacic.EnCrypt(g_oCacic.getWindowsStrId());
1809 1724 Request_mapa.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened));
1810 1725 Request_mapa.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened));
1811 1726 Request_mapa.Values['te_nome_computador']:= frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', frmMapaCacic.tStringsCipherOpened));
... ...