Получить приложение, ассоциированное с указанным расширением файлов
Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch
{ FindExecutable returns the name and handle to the executable (.EXE) file associated with a specified file type (.BMP) } { Wenn du z.B eine BMP-Datei anklickst, wird die dazugehorige Anwendung MSPAINT.EXE mit der Datei als Parameter ausgefuhrt. In diesem Beispiel wird herausgefunden, welche Anwendung (hier MSPAINT.EXE) mit dem jeweiligen Datei Typ verknupft ist. } 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^ := ' '; Inc(P); end; Result := Buffer; end else Result := ''; end; // Example, Beispiel: procedure TForm1.Button1Click(Sender: TObject); begin ShellFindExecutable('1stboot.bmp', 'c:\windows'); end;
Далее: Получить список запущенных приложений, проверить запущена ли программа »»