Kylix
Tips

NEW TIPS
Database (98)
Files (1188)
Forms (125)
Graphic (126)
IDE (30)
Indy (13)
Internet / LAN (146)
IntraWeb (12)
Math (84)
Misc (137)
Multimedia (56)
Objects/
ActiveX (64)

OpenTools API (14)
Printing (47)
Strings (94)
System (275)
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