Hi,
I'm intending on offering Raw (& DICOM) support as an add-on to my software.
When a user selects a CR2 (for instance) file (in a FolderMView) to preview (in an ImageEnView) before importing to the database, I'd like to detect that they're attempting to access an ioRAW file and if IELibAvailable = false, then pop up some kind of prompt for them to get the add-on.
Code I'm using at the moment to detect formats is:
TFileAddResult = (faOK, faNotSupported, faNeedsAddOn);
...
function AddFile(const aFilename : string) : TFileAddResult;
begin
aIO := TImageEnIO.Create(nil);
try
try
aIO.ParamsFromFile(aFilename);
if aIO.Params.FileType = ioUnknown then
result := faNotSupported
else
if aIO.Params.FileType in [ioRAW, ioBMPRAW, ioDICOM] then
result := faNeedsAddOn
else
if ImageEnMView.MIO.LoadFromFileAuto(aFilename) then
result := faOK;
except
on EIERawException do
result := faNeedsAddOn;
on Exception do
result := faNotSupported;
end;
finally
aIO.Free;
end;
end;
Problem is, the line in bold raises an EIERawException which is handled internally but it leaves the aIO.Params.FileType as ioUnknown - so I cannot detect if the user has tried to access a genuine Raw file versus just some random unsupported file...?
What's the best method for detecting a file type from a filename when IELIB isn't available ?
Cheers
Stuart Clennett
Delphi Berlin 10.1