Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2002.08.26;
Скачать: [xml.tar.bz2];

Вниз

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 вся ветка

Форум: "WinAPI";
Текущий архив: 2002.08.26;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.009 c
1-85124
jessis
2002-08-15 11:55
2002.08.26
Параметр в командной строке


14-85181
Dmk
2002-07-27 19:20
2002.08.26
Delphi 6 - Руководство разработчика


1-84990
Olorin
2002-08-15 14:06
2002.08.26
Что-то типа eval или другие способы...


1-85082
dim-
2002-08-14 17:29
2002.08.26
Компонент htmllite


14-85203
Alexey-neo
2002-04-28 20:44
2002.08.26
Как работать с модемом???





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский