Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Hostanwendung für gegebenen Dateityp bestimmen (https://www.delphipraxis.net/115646-hostanwendung-fuer-gegebenen-dateityp-bestimmen.html)

ToZie 15. Jun 2008 18:11


Hostanwendung für gegebenen Dateityp bestimmen
 
Huhu,

ich habe das Problem Dateien ohne Endung (aber bekanntem Dateityp - hier TIFF) mit der jeweils für diesen Dateityp konfigurierten Hostanwendung öffnen zu müssen. Leider stehe ich dabei etwas auf dem Schlauch, vielleicht kann mir ja hier jemand rasch weiterhelfen.

Vielen Dank

Torsten

sirius 15. Jun 2008 19:17

Re: Hostanwendung für gegebenen Dateityp bestimmen
 
Da musst du dir die Specification deiner einzelnen Formate ansehen. Meist sind in den ersten Bytes jeder Datei noch irgendwleche Kennungen hinterlegt. In deinem genannten Fall liegt die Spec bei Adobe. [url=http://partners.adobe.com/public/developer/tiff/index.html]
Zitat:

A TIFF file begins with an 8-byte image file header, containing the following
information:
Bytes 0-1:
The byte order used within the file. Legal values are:
“II” (4949.H)
“MM” (4D4D.H)
In the “II” format, byte order is always from the least significant byte to the most
significant byte, for both 16-bit and 32-bit integers This is called little-endian byte
order. In the “MM” format, byte order is always from most significant to least
significant, for both 16-bit and 32-bit integers. This is called big-endian byte
order.
Bytes 2-3
An arbitrary but carefully chosen number (42) that further identifies the file as a
TIFF file.

The byte order depends on the value of Bytes 0-1.
Bytes 4-7
The offset (in bytes) of the first IFD. The directory may be at any location in the
file after the header but must begin on a word boundary. In particular, an Image
File Directory may follow the image data it describes. Readers must follow the
pointers wherever they may lead.
The term byte offset is always used in this document to refer to a location with
respect to the beginning of the TIFF file. The first byte of the file has an offset of
0.
Also du musst eine 42 an Byte 2-3 finden und vorher in Byte 0 und 1 schauen, ob es Big oder Little Endian ist.

ToZie 15. Jun 2008 19:37

Re: Hostanwendung für gegebenen Dateityp bestimmen
 
ich kenne den Dateityp - ich möchte feststellen welche Hostanwendung für ihn konfiguriert ist.

paritycheck 15. Jun 2008 21:05

Re: Hostanwendung für gegebenen Dateityp bestimmen
 
Könnte damit klappen ;)
Delphi-Quellcode:
function FindExecutableA(lpFile: PChar; lpDirectory: PChar; lpResult: PChar): Cardinal; stdcall; external 'shell32.dll' name 'FindExecutableA';

function GetExeFromDocument(const Document: String; const Directory: String): String;
var
  ret: array[0..MAX_PATH-1] of char;
  lpFile,
  lpDirectory: PChar;
begin
  result:= '';
  ZeroMemory(@ret, MAX_PATH);
  lpFile:= PChar(Document);
  lpDirectory:= PChar(Directory);
  if FindExecutableA(lpFile, lpDirectory, @ret[0]) > 32 then
     Result:= ret;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Showmessage(GetExeFromDocument('a.txt', 'D:\Temp'));
end;

Namenloser 15. Jun 2008 21:14

Re: Hostanwendung für gegebenen Dateityp bestimmen
 
*bielefeld*

ToZie 15. Jun 2008 23:18

Re: Hostanwendung für gegebenen Dateityp bestimmen
 
Vielen Dank paritycheck, das funktioniert tadellos.

Torsten


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:38 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz