Board index » delphi » associate file types with a checkbox...

associate file types with a checkbox...

hey..

i'm still making my own text editor, but there's one thing i have to get to
know...
how can i make changes to the registry with the help of a button and a
checkbox? (i want to associate .txt files with my own program.. and then i
just have to check a checkbox in the options, and press ok... but how)..
please give me an example / source....

thanks.. again.. =)

Alien Dealer
alien...@hotmail.com

 

Re:associate file types with a checkbox...


On Wed, 21 Jul 1999 21:48:51 GMT, "Alien Dealer"
<alien...@hotmail.com> waffled on about something:

Quote
>hey..

>i'm still making my own text editor, but there's one thing i have to get to
>know...
>how can i make changes to the registry with the help of a button and a
>checkbox? (i want to associate .txt files with my own program.. and then i
>just have to check a checkbox in the options, and press ok... but how)..
>please give me an example / source....

>thanks.. again.. =)

>Alien Dealer
>alien...@hotmail.com

Here you go Alien....
just call the registry entries whatever you like (I just used
mytexteditor as an example).
Make sure the writestrings and the registry paths in the const's
contain the same names, or windows will get lost trying to link the
extension and the program.
I have also included the code to change the icon to one in the
program's runtime directory.
If you don't want to change that, just remove the last
openkey,writestring,closekey steps.

Dodgy.

You will need "registry" in the uses.

procedure Tmainform.associatetxt(Sender: TObject);
const
  EXT = '\.txt';
  EXTDESC = '\mytexteditor\shell\open\command';
  EXTNAME = '\mytexteditor';
  EXTICON = '\mytexteditor\DefaultIcon';
var TheRegistry:tregistry;
begin
  theregistry:=tregistry.create;
  TheRegistry.RootKey := HKEY_CLASSES_ROOT;
  TheRegistry.OpenKey(EXT, True);
  TheRegistry.WriteString('', 'mytexteditor');
  TheRegistry.CloseKey;
  TheRegistry.OpenKey(EXTNAME, True);
  TheRegistry.WriteString('', 'mytexteditor');
  TheRegistry.CloseKey;
  TheRegistry.OpenKey(EXTDESC, True);
  TheRegistry.WriteString('', '"' + Application.ExeName + '" "%1"');
  TheRegistry.CloseKey;
  TheRegistry.OpenKey(EXTICON, True);
  TheRegistry.WriteString('', ExtractFilePath(Application.ExeName) +
'myicon.ico');
  TheRegistry.CloseKey;
  theregistry.free;
end;

Re:associate file types with a checkbox...


Look at
http://www.borland.com/devsupport/delphi/ti_list/
and choose
TI4646D How to register my program's file type with the Window's registry.

Alien Dealer <alien...@hotmail.com> skrev i en
nyhedsmeddelelse:7frl3.796$vX4.75...@juliett.dax.net...

Quote
> how can i make changes to the registry with the help of a button and a
> checkbox? (i want to associate .txt files with my own program.. and then i
> just have to check a checkbox in the options, and press ok... but how)..
> please give me an example / source....

Other Threads