Author: William Gerbert
Determine which application is associated with a specific file name extension
Answer:
To determine which application is associated with a specific file name extension
you can look in the registry under HKEY_CLASSES_ROOT.
Easier is to use the Windows API function FindExecutable() - see the following
example. The code shows the fully qualified associated application or the last
error (using GetLastError).
1 program Project1;
2 3 uses4 Forms, Dialogs, ShellAPI, SysUtils, Windows;
5 6 {$R *.RES}7 8 var9 sApp: array[0..256] of char;
10 begin11 // this should return something like c:\program files\office\excel.exe12 13 if FindExecutable('c:\temp\xxx.xls', nil, sApp) >= 32 then14 ShowMessage(sApp)
15 else16 ShowMessage(SysErrorMessage(GetLastError));
17 end.