Board index » delphi » How to find the program associated with one file extension

How to find the program associated with one file extension

Hello, all.

I will like to know how to find the program (exe) associated with
one file extension from register (not win.ini).

Anybody could help me?

Regards,
Agustin

--
              ===============================
              |  Jose Agustin Lopez Bueno   |
              | E-Mail: Agustin.Lo...@uv.es |
              |                             |
              |  http://www.uv.es/~lopezj/  |  
              |                             |
              |     Tel: +34-6-3864310      |
              |     Fax: +34-6-3864200      |
              |   Servicio de Informatica   |
              |   Universidad de Valencia   |
              ===============================

 

Re:How to find the program associated with one file extension


lop...@iluso.ci.uv.es (Agustin Lopez Bueno) wrote:

Quote
>Hello, all.

>I will like to know how to find the program (exe) associated with
>one file extension from register (not win.ini).

 const
      BufferSize = {$IFDEF Win32} 540 {$ELSE} 80 {$ENDIF};
  var
      Buffer : PChar;
      StringPosition : PChar;
      ReturnedData: Longint;
begin
  Buffer := StrAlloc(BufferSize);
  try
    { get the first entry, don't bother about the version !}
    ReturnedData := BufferSize;
    StrPCopy(Buffer, '.xls');
    RegQueryValue(hKey_Classes_Root, Buffer, Buffer, ReturnedData);
    if StrLen(Buffer) > 0 then
    begin

--
Stefan.Hoffmeis...@Uni-Passau.de
http://www.rz.uni-passau.de/~w4hoff01/
University of Passau, Bavaria, Germany

Re:How to find the program associated with one file extension


Agustin Lopez Bueno <lop...@iluso.ci.uv.es> a crit dans l'article
<5f190i$...@power.ci.uv.es>...

Quote
> Hello, all.

> I will like to know how to find the program (exe) associated with
> one file extension from register (not win.ini).

You might use a trick (I tested it in Windows 95) :

There is an API function which let you know the executable associated
with a document : ExtractAssociatedIcon(hInstance,PChar(szFile),wIndex);
You might look for the icon of a document having the extension you want,
by calling this function, and Windows will put the name of the associated
executable in your szFile parameter ... But this is just a trick ... Just
type in
the name of the function and call the Help.

I think that the normal method should be to look in the registry :
In the HKEY_CLASSES_ROOT key, you must look for a key whose
name is ".bmp" for instance. Then, get the "Default" value of this key.
This is the generic name of the application used to manage this extension.
For instance, you might have "PSP.Image". Then, look (also in
HKEY_CLASSES_ROOT) for the default value of :
PSP.Image\shell\open\command
This value is the name of the executable.

Hope this will help you !

--
o?o?,,?o?oo?  Jean-Michel CAMBOT   ?oo?o?,,?o?o
o?o?,,?o?oo?  balic...@cge-ol.XXX.fr   ?oo?o?,,?o?o
... Please remove XXX from the address to answer ...
Site BALICIEL French : http://www.cge-ol.fr/baliciel/  ;o)
Site BALICIEL English : http://www.cge-ol.fr/baliciel/welcome1.htm  ;o)

Other Threads