Evo kako sam to rjesio, ako nekome, nekada bude trebalo !
procedure TOtvoriDok.Button2Click(Sender: TObject);
var doc:string;
var kraj:boolean;
hwnd, hins:Thandle;
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
ExecuteFile, ParamString, StartInString, st: string;
tempdir:string;
A : Array[0..100] of Char;
doc2:string;
default_convert : string;
tip, pozicija : integer;
begin
GetTempPath(100,@A);
tempdir:=A;
pozicija := pos('.', document);
st := copy(document, pozicija, length(document)-pozicija+1);
tip := 1;
// doc := document;
doc := 'tempfile'+PROTOKOL_DOKUMENTI_ID.AsString;
{ case tip of
1 : doc:=doc+'.png';
else
MessageDlg('Nepoznat format', mtError, [mbOK], 0);
exit;
end; }
doc:=doc+st;
doc2:=tempdir+'tempscan2.tif';
ExecuteFile:='C:\Projekt\Tis\Aplikacije\nconvert';
default_convert:=' -quiet -out tiff -c 6 ';
FillChar(SEInfo, SizeOf(SEInfo), 0);
SEInfo.cbSize := SizeOf(TShellExecuteInfo);
Application.ProcessMessages;
with SEInfo do begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Application.Handle;
lpFile := PChar(ExecuteFile);
lpParameters := PChar('-o '+doc2+default_convert+doc);
lpDirectory := PChar(tempdir);
nShow := SW_Hide;
end;
if ShellExecuteEx(@SEInfo) then begin
repeat
Application.ProcessMessages;
GetExitCodeProcess(SEInfo.hProcess, ExitCode);
sleep(10);
until (ExitCode <> STILL_ACTIVE) or (application.Terminated);
end else begin
ShowMessage('Greska u konvertovanju dokumenta !');
end;
// DeleteFile(doc2);
end;
|