...get/set the startpage for the Internet Explorer?

Author: Thomas Stutz

Category: Internet / LAN

uses
  
{...,}Registry;
  
function GetIEStartPage: string;
var
  
Reg: TRegistry;
begin
  
Reg := TRegistry.Create;
  try
    
Reg.RootKey := HKEY_CURRENT_USER;
    Reg.OpenKey('Software\Microsoft\Internet Explorer\Main', False);
    try
      
Result := Reg.ReadString('Start Page');
    except
      
Result := '';
    end;
    Reg.CloseKey;
  finally
    
Reg.Free;
  end;
end;

function SetIEStartPage(APage: string): Boolean;
var
  
Reg: TRegistry;
begin
  
Reg := TRegistry.Create;
  try
    
Reg.RootKey := HKEY_CURRENT_USER;
    Reg.OpenKey('Software\Microsoft\Internet Explorer\Main', False);
    try
      
Reg.WriteString('Start Page', APage);
      Result := True;
    finally
      
Reg.CloseKey;
      Result := False;
    end;
  finally
    
Reg.Free;
  end;
end;

// Show the Startpage
procedure TForm1.Button1Click(Sender: TObject);
begin
  
ShowMessage(GetIEStartPage);
end;

// Set the Startpage
procedure TForm1.Button2Click(Sender: TObject);
begin
  
SetIEStartPage('www.swissdelphicenter.ch');
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base