procedure TForm17.Button2Click(Sender: TObject);
const
FILENAME = '
Dok.pdf';
var
PDFField: TBlobField;
TempPath :
String;
ExecuteInfo: SHELLEXECUTEINFO;
begin
ADOTable1.Open;
PDFField := ADOTable1.FieldByName('
PDFFILE')
as TBlobField;
if not PDFField.IsNull
then
begin
SetLength(TempPath, GetTempPath(0,
nil));
GetTempPath(Length(TempPath), PChar(TempPath));
SetLength(TempPath, StrLen(PChar(TempPath)));
TempPath := IncludeTrailingPathDelimiter(TempPath) + FILENAME;
try
PDFField.SaveToFile(TempPath);
ZeroMemory(@ExecuteInfo, SizeOf(ExecuteInfo));
ExecuteInfo.cbSize := SizeOf(ExecuteInfo);
ExecuteInfo.fMask := SEE_MASK_NOCLOSEPROCESS;
ExecuteInfo.lpVerb := '
open';
ExecuteInfo.lpFilename := PChar(TempPath);
ExecuteInfo.nShow := SW_SHOWNORMAL;
if ShellExecuteEx(@ExecuteInfo)
then
CloseHandle(ExecuteInfo.hProcess)
else
raise Exception.Create(SysErrorMessage(GetLastError));
except
on E:
Exception do
ShowMessage('
Fehler beim Öffnen der Datei: ' + E.
Message);
end;
end
else
ShowMessage('
Kein PDF im aktuellen Datensatz enthalten.');
end;