По указанному файлу, получаем путь к ассоциированному с ним приложению.
1 2 3 4 5 6 7 8 9 10 11 |
Uses Winapi.ShellAPI; ... var filePath, assocExePath: WideString; begin filePath:= 'C:\Windows\Fonts\tahoma.ttf'; assocExePath:= ShellFindExecutable(filePath); ShowMessage(assocExePath); end; |
Параметры
filePath - путь к файлу
Результат
Путь к ассоциированному приложению или пустая строка в случае неудачи.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function ShellFindExecutable(filePath: string): string; var Res: HINST; Buffer: array[0..MAX_PATH] of Char; P: PChar; begin FillChar(Buffer, SizeOf(Buffer), #0); P := nil; Res := FindExecutable(PChar(filePath), P, Buffer); if Res > 32 then begin P := Buffer; while PWord(P)^ <> 0 do begin if P^ = #0 then P^ := ' '; Inc(P); end; Result := Buffer; end else Result := ''; end; |