Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt

When user register a application by user choice, there are some registry entries automatically created by windows. By doing the same behaviors like windows, application can be launched automatically by click the clicking associated files.

Following example shows an example I implemented

Code Block
languagedelphi
uses System.Win.Registry;

.
.
.

Procedure TForm1.FormCreate(Sender: TObject);
begin
  with TRegistry.Create do
    try
      RootKey := HKEY_CURRENT_USER;
      if OpenKey('Software\Classes\.kes', true) then begin
        WriteString('', '.kes_auto_file');
      end;
    finally
      Free;
    end;

  with TRegistry.Create do
    try
      RootKey := HKEY_CURRENT_USER;
      if OpenKey('Software\Classes\.kes_auto_file\shell\open\command', true) then begin
        WriteString('', '"' + ParamStr(0) + '" "%1"');
      end;
    finally
      Free;
    end;

  with TRegistry.Create do
    try
      RootKey := HKEY_CURRENT_USER;
      if OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.kes\UserChoice', true) then begin
        WriteString('', 'Applications\EmployeeSurvey.exe');
        WriteString('ProgId', '.kes_auto_file');
      end;
    finally
      Free;
    end;
end;

...