Associate specific file extensions with my delphi application - any library for this?

Until now, if I needed to associate a file extension with my application, I just modified the registry. However, I have not done this for many years, and I am afraid that everything could change. I do not know how to prevent registry access restrictions in Windows 7 / Vista (if they exist for HKEY_CLASSES_ROOT). So I'm looking for some delphi libraries, a block, a code snippet, or something that works reliably under XP, Vista, and 7. Are there any pens for backup? By backup I mean the ability to revert changes to a previous association ...

+3
source share
1 answer

I would recommend not using a third-party component for this, because it will only complicate the situation.

We all know how to create file associations by editing ducks HKEY_CURRENT_USERand HKEY_LOCAL_MACHINE, right? In Windows Vista +, editing the former implies no problems, but if for some reason you want to edit the latter, that is, if you want to edit the associations for all users on the machine, your application should run with elevated privileges.

, " ". . , ( XML) . UAC *.exe , , , HKEY_LOCAL_MACHINE. , , SO. .

, "" . , , , - :

procedure Button1.Click(Sender: TObject);
begin
  SomehowGetAdminPrivileges;
  ChangeLocalMachineRegistry;
  SomehowGetBackNormalPrivileges;
end;

. , -, , ,

procedure Button1.Click(Sender: TObject);
begin
  ShellExecute(Application.Handle, nil, PChar('myapp.exe'), nil, nil, SW_SHOWNORMAL);
end;

myapp.exe , , . , myapp.exe - , UAC, myapp.exe , .

, , .

? Inno Setup, , Inno Setup . , UAC setup.exe( Inno Setup), . - HKEY_LOCAL_MACHINE.

+5

Source: https://habr.com/ru/post/1748727/


All Articles