Mega Code Archive

 
Categories / Delphi / API
 

Application associated with a specific file name extension

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,shellapi, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var sApp : array [0..256] of char; begin //this code should return notepad.exe //*.xls would be excel.exe //*.doc would be winword.exe if FindExecutable('c:\test.txt', nil, sApp) >= 32 then ShowMessage(sApp) else ShowMessage(SysErrorMessage(GetLastError)); end; end.