Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.08.26;
Скачать: CL | DM;

Вниз

CreateProcess   Найти похожие ветки 

 
skiph ©   (2002-06-21 06:00) [0]

Запускаю с помощью CreateProcess процесс архивирования, как узнать, что он завершился, чтобы перекопировать файл на дискету?


 
MBo ©   (2002-06-21 06:05) [1]

в FAQ есть


 
Robor   (2002-06-21 09:49) [2]

Я делал так:

Unit exec;

interface

Uses Windows, SysUtils, Forms, ShellAPI;

function ExecWin(Path,name,CommandLine,CurrentDir:string;Wait:boolean) : word;

implementation

function ExecWin(Path,name,CommandLine,CurrentDir:string;Wait:boolean) : word;
var
tsi : TStartupInfo;
tpi : TProcessInformation;
tPath,Command : PChar;
CurDir :Pchar;
// st1 :string;
// T1,T2,T3,T4 :TFileTime;
// rr :boolean;
cod :DWord;

// ErrorMessage: Pointer; // holds a system error string
// ErrorCode: DWORD; // holds a system error code
begin
Result := 30;
Path:=path+name+" "+CommandLine+#00;
CommandLine:=CommandLine+#0;
tPath := StrAlloc(512);
Command := StrAlloc(512);
CurDir :=StrAlloc(512);

FillChar(tsi, SizeOf(TStartupInfo), 0);
tsi.cb := SizeOf(TStartupInfo);
tsi.dwFlags := STARTF_USESHOWWINDOW;
tsi.wShowWindow := SW_SHOWMINNOACTIVE;
// FindExecutable(@Path[1],nil,tPath);
// st1:=string(tPath)+#0;
// st1:=AnsiUpperCase(st1);
// Path:=AnsiUpperCase(Path);
// if st1<>Path then st1:=Concat(st1," ",path,#0);
// Move(st1[1],tPath[0],Length(st1));
// Move(CommandLine[1],Command[0],length(CommandLine));
Move(Path[1],tPath[0],Length(Path));
CurrentDir:=CurrentDir+#0;
Move(CurrentDir[1],CurDir[0],length(CurrentDir));
try
if CreateProcess(nil,@tPath[0]{, @Command[0]},nil, nil, False,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,nil, @CurDir[0], tsi, tpi)
then begin
cod:=WAIT_TIMEOUT;
while (cod=WAIT_TIMEOUT) and Wait do begin
cod:=WaitForSingleObject(tpi.hProcess, 500);
Application.ProcessMessages;
end;
result:=0;
{ rr:=GetProcessTimes(tpi.hProcess,t1,t2,t3,t4);
while (t2.dwLowDateTime=0) and (t2.dwHighDateTime=0) and rr do begin
Application.ProcessMessages;
rr:=GetProcessTimes(tpi.hProcess,t1,t2,t3,t4);
end;}
CloseHandle(tpi.hProcess);
CloseHandle(tpi.hThread);
end
else result:=GetLastError;
finally
{ ErrorCode := GetLastError;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM,
nil, ErrorCode, 0, @ErrorMessage, 0, nil);
LocalFree(hlocal(ErrorMessage));}
StrDispose(Command);
StrDispose(tPath);
StrDispose(CurDir);
end;
end;

end.



Страницы: 1 вся ветка

Текущий архив: 2002.08.26;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.015 c
1-84963
vlv
2002-08-15 15:40
2002.08.26
Преобразование URL


1-84985
Геннадий
2002-08-15 23:13
2002.08.26
Как включить ActiveDesktop программно?


1-85109
AlexCement
2002-08-15 08:10
2002.08.26
Работа с верхним и нижним индексом текста


1-85120
Sergey V. Shadrin
2002-08-15 08:58
2002.08.26
запустить программу


3-84924
ренат
2002-08-07 09:25
2002.08.26
JBasix