Lenguaje de programación Borland Delphi
A continuación mostramos el código fuente para poner una página web como página de inicio para Internet Explorer y también para mostrar la página de inicio actual de Internet Explorer. Para ello necesitamos un formulario y dos botones:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComObj, StdCtrls, registry;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
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;
// Mostrar la web de inicio de IE
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(GetIEStartPage);
end;
// Poner web en página de inicio de IE
procedure TForm1.Button2Click(Sender: TObject);
begin
SetIEStartPage('www.ajpdsoft.com');
end;
end.
Publicado el: 2003-12-11