Title: How to determine which Application is associated with a File Type
function ShellFindExecutable(const FileName, DefaultDir: string): string;
var
Res: HINST;
Buffer: array[0..MAX_PATH] of Char;
P: PChar;
begin
FillChar(Buffer, SizeOf(Buffer), #0);
if DefaultDir = '' then P := nil
else
P := PChar(DefaultDir);
Res := FindExecutable(PChar(FileName), P, Buffer);
if Res 32 then
begin
P := Buffer;
while PWord(P)^ 0 do
begin
if P^ = #0 then // FindExecutable replaces #32 with #0
P^ := #32;
Inc(P);
end;
Result := Buffer;
end
else
Result := '';
end;
Usage Example:
procedure TForm1.Button1Click(Sender: TObject);
begin
ShellFindExecutable('1stboot.bmp', 'c:\windows');
end;