카테고리 없음

[일반/컴포넌트] IE Toolbar 에 버튼 올리기

쇼핑스크래퍼5 2023. 9. 4. 08:08
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Registry, ShellAPI;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
const
  TagID = '{10954C80-4F0F-11d3-B17C-00C0DFE39736}';
var
  Reg: TRegistry;
        ProgramPath: string;
  RegKeyPath: string;
begin
  // 실행할 파일명 또는 URL
  ProgramPath := 'http://www.howto.pe.kr';
  
  Reg := TRegistry.Create;
  try
    with Reg do
    begin
      RootKey := HKEY_LOCAL_MACHINE;
      RegKeyPath := 'SoftwareMicrosoftInternet ExplorerExtensions';
      OpenKey(RegKeyPath + TagID, True);
      WriteString('ButtonText', 'HOWTO');
      WriteString('MenuText', 'Your program Menu text');
      WriteString('MenuStatusBar', 'Run Script');
      WriteString('ClSid', '{E7D9BC68-5F94-4917-B9D3-F61ADBD1AC75}');
      WriteString('Default Visible', 'Yes');
      WriteString('Exec', ProgramPath);
      WriteString('HotIcon', ',4');
      WriteString('Icon', ',4');
     end
  finally
    Reg.CloseKey;
    Reg.Free;
  end;

  ShellExecute(0, nil, PChar(ProgramPath), nil, nil, SW_SHOWDEFAULT);
end;

end.