was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

53 Visitors Online


 
...alle Registry Schlüssel auslesen die sich in einer bestimmten Zeitspanne geändert haben
Autor: Carlo Pasolini, Riccione (Italy)
Homepage: http://utenti.lycos.it/carlpasolini
[ Tip ausdrucken ]  

Tip Bewertung (12):  
     


unit Main;

interface

uses
  
Windows, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Registry, StdCtrls, ComCtrls, ExtCtrls;

type
  
TFrmMain = class(TForm)
    Memo1: TMemo;
    btEnumReg: TButton;
    dtBeginDate: TDateTimePicker;
    dtEndDate: TDateTimePicker;
    dtBeginTime: TDateTimePicker;
    dtEndTime: TDateTimePicker;
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    procedure btEnumRegClick(Sender: TObject);
  private
    
{ Private declarations }
    
RegDate: TDateTime;
    RegKeyInfo: TRegKeyInfo;
    TimeZoneInfo: TTimeZoneInformation;
    function DateTimeToLocalDateTime(DateTime: TDateTime): TDateTime;
    procedure FileTimeToDateTime(ft: TFileTime; var dt: TDateTime);
  public
    
{ Public declarations }

  
end;

var
  
FrmMain: TFrmMain;

implementation

{$R *.dfm}

function TFrmMain.DateTimeToLocalDateTime(DateTime: TDateTime): TDateTime;
begin
  case 
GetTimeZoneInformation(TimeZoneInfo) of
    
TIME_ZONE_ID_STANDARD:
      Result := DateTime - (TimeZoneInfo.Bias / 60 / 24);
    TIME_ZONE_ID_DAYLIGHT:
      Result := DateTime - ((TimeZoneInfo.Bias + TimeZoneInfo.DaylightBias) / 60 / 24);
    else
      
Result := 0;
  end;
end;

procedure TFrmMain.FileTimeToDateTime(ft: TFileTime; var dt: TDateTime);
var
  
SystemTime: TSystemTime;
  FileTime: TFileTime;
begin
  if 
FileTimeToLocalFileTime(ft, FileTime) then
  begin
    
FileTimeToSystemTime(ft, SystemTime);
    dt := SystemTimeToDateTime(SystemTime);
  end;
end;

procedure TFrmMain.btEnumRegClick(Sender: TObject);
var
  
Inizio, Fine: TDateTime;

  procedure EnumAllKeys(hkey: THandle; KeyName: string);
  var
    
l: TStringList;
    n: Integer;
    KeyName_: string;
  begin
    
KeyName_ := KeyName;
    with TRegistry.Create do
      try
        
RootKey := hkey;
        OpenKey(EmptyStr, False);
        l := TStringList.Create;
        try
          
GetKeynames(l);
          CloseKey;
          for n := 0 to l.Count - 1 do
          begin
            if 
OpenKey(l[n], False) then
            begin
              
GetKeyInfo(RegKeyInfo);
              with RegKeyInfo do
              begin
                
FileTimeToDateTime(FileTime, RegDate);
                RegDate := DateTimeToLocalDateTime(RegDate);
              end;
              if (RegDate <= Fine) and (RegDate >= Inizio) then
                
memo1.Lines.Add(DateTimeToStr(RegDate) + ' --- ' + KeyName_ + '\' + l[n]);
              EnumAllKeys(CurrentKey, KeyName_ + '\' + l[n]);
              CloseKey;
            end;
          end;
        finally
          
l.Free
        end;
      finally
        
Free;
      end;
  end;
begin
  
Memo1.Clear;
  Memo1.Lines.BeginUpdate;
  Inizio := int(dtBeginDate.DateTime) + frac(dtBeginTime.DateTime);
  Fine   := int(dtEndDate.Date) + frac(dtEndTime.DateTime);
  try
    
EnumAllKeys(HKEY_CURRENT_USER, 'HKey_Current_User');
  finally
    
Memo1.Lines.EndUpdate;
  end;

  MessageDlg('Enumeration ended', mtInformation, [mbOK], 0);
end;

end.

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners