Sumber Kode

Retreive default browser path

  • delphibasics
  • Nov 19' 14
  • Delphi
  • 99
  • 280
  • United States
There are many different ways to retreive the default browser path.  I will detail two methods.

1. Using registry.
uses
  Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
  Reg: TRegistry;
  KeyName: string;
  ValueStr: string;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CLASSES_ROOT;
    KeyName     := 'htmlfile\shell\open\command';
    if Reg.OpenKey(KeyName, False) then
    begin
      ValueStr := Reg.ReadString('');
      Reg.CloseKey;
      ShowMessage(ValueStr);
    end
    else
      ShowMessage('There isn't a default browser');
  finally
    Reg.Free;
  end;
end;

2. Using associated application.
var
    Path: array[0..255] of char;

begin
  CloseHandle(CreateFile('C:\default.html', GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0));
  FindExecutable('C:\default.html', nil, Path); //Find the executable (default browser) associated with the html file.
  DeleteFile('C:\default.html');
  Showmessage(Path);
end;



Powered by
Pasar Kode Partner

Share

  • Tags :
comments powered by Disqus

Kode Terkait

Create a functioning form with Windows API.

HHUtils 1.0 - A collection of useful delphi functions.

Screen Capture with Pure Windows API

Programmatically talk using Microsoft Sam

Modify TEdit to include text alignment

Delphi RC4 Encryption Source Code

Update PE CheckSum

Enumerate Processes using Native Windows API

Self-Deleting File - "Melting"

Change ImageBase of a PE File



Kategori