Kylix
Tips

NEW TIPS
Database (91)
Files (138)
Forms (112)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (133)
IntraWeb (0)
Math (77)
Misc (128)
Multimedia (46)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (246)

Search Tip
Top15
Add new Tip

Forum

...read/write REG_DWORD values from/to the Registry?
Author: Thomas Stutz
[ Print tip ]    

Tip Rating (16):  
     



uses
  
Registry;

// Read REG_DWORD
procedure TForm1.Button1Click(Sender: TObject);
var
  
Reg: TRegistry;
  RegKey: DWORD;
  Key: string;
begin
  
Reg := TRegistry.Create;
  try
    
Reg.RootKey := HKEY_USERS;
    Key := '.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\URL History';
    if Reg.OpenKeyReadOnly(Key) then
    begin
      if 
Reg.ValueExists('DaysToKeep') then
      begin
        
RegKey := Reg.ReadInteger('DaysToKeep');
        Reg.CloseKey;
        ShowMessage(IntToStr(RegKey));
      end;
    end;
  finally
    
Reg.Free
  end;
end;


// Write REG_DWORD
procedure TForm1.Button2Click(Sender: TObject);
var
  
Reg: TRegistry;
  Key: string;
begin
  
Reg := TRegistry.Create;
  try
    
Reg.RootKey := HKEY_USERS;
    Key := '.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\URL History';
    if Reg.OpenKey(Key, True) then
    begin
      
Reg.WriteInteger('DaysToKeep', 20);
      Reg.CloseKey;
    end;
  finally
    
Reg.Free
  end;
end;

Rate this tip:

poor
very good


Copyright  Torry's Delphi Pages Torry's Delphi Pages Maintained by Simon Grossenbacher Notes? Comments? Feel free to send... Copyright 1996-2001