Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 Feb : Associate extension with application using Vista

www.cryer.info
Managed Newsgroup Archive

Associate extension with application using Vista

Subject:Associate extension with application using Vista
Posted by:"Michael Fritz" (spam_athome@yahoo.de)
Date:Mon, 18 Feb 2008 09:37:20

Hi,

I wonder if anyone has got experience on how to associate a file extension
with an application under Vista.

So far I'm using this coding:

    with TRegistry.Create(KEY_READ or KEY_WRITE) do
    begin
      RootKey := HKEY_CLASSES_ROOT;
      OpenKey('.' + PREFIX, True);
      WriteString('',PREFIX + 'File');
      CloseKey;
      OpenKey(PREFIX + 'File',True);
      WriteString('',DESCRIPTION);
      OpenKey(PREFIX + 'File\DefaultIcon',True);
      WriteString('',sExe + ',0');
      CloseKey;
      OpenKey(PREFIX + 'File\Shell\Open\Command',True);
      WriteString('',sExe + ' "%1"');
      CloseKey;
      Free;
    end;

However this requires to write to HKCR and I assume this needs
administrative rights in Vista.

Of course an elevated setup program (Inno Setup, btw) does this already but
if for any reasons this association is dropped I would like to repair it
from within my application.

Any hints are welcome on how to do this using Vista.
--
cu,
Michael

Replies:

www.cryer.info
Managed Newsgroup Archive