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

Вниз

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

 
BAY   (2002-08-07 22:09) [0]

А как лучше запустить win-прогу, и проконтролировать, когда сия закроется? (подозреваю, что CreateProcess это делает, но как с ним работать - не представляю)


 
AlexXP   (2002-08-08 02:24) [1]

Ты угадал эта функция запускает процесс и выдаёт кучу инфы о нём, среди неё ести и Handle (дескриптор этого процесса).
Используй его в функции WaitForSingleObject.
///////////////////////////////////////////
The WaitForSingleObject function returns when one of the following occurs:

· The specified object is in the signaled state.
· The time-out interval elapses.



DWORD WaitForSingleObject(

HANDLE hHandle, // handle of object to wait for
DWORD dwMilliseconds // time-out interval in milliseconds
);


Parameters

hHandle

Identifies the object. For a list of the object types whose handles can be specified, see the following Remarks section.
Windows NT: The handle must have SYNCHRONIZE access. For more information, see Access Masks and Access Rights.

dwMilliseconds

Specifies the time-out interval, in milliseconds. The function returns if the interval elapses, even if the object"s state is nonsignaled. If dwMilliseconds is zero, the function tests the object"s state and returns immediately. If dwMilliseconds is INFINITE, the function"s time-out interval never elapses.



Return Values

If the function succeeds, the return value indicates the event that caused the function to return.
If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError.
The return value on success is one of the following values:

Value Meaning
WAIT_ABANDONED The specified object is a mutex object that was not released by the thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled.
WAIT_OBJECT_0 The state of the specified object is signaled.
WAIT_TIMEOUT The time-out interval elapsed, and the object"s state is nonsignaled.


 
Slava   (2002-08-08 11:20) [2]

http://delphibase.endimus.com/?action=viewtopic&topic=winappctrl


 
SergeSV   (2002-08-08 11:52) [3]

Смотри - это точно работает

function ExecuteSomething(const ProgName, Cmd: String; Show: Word): DWORD;
var
sInf: TStartupInfo;
pInf: TProcessInformation;
Code: DWORD;
begin
Code := 0;
FillChar(sInf, SizeOf(sInf),0);
sInf.cb := SizeOf(sInf);
sInf.wShowWindow := Show;
sInf.dwFlags := STARTF_USESHOWWINDOW;
if CreateProcess(PChar(ProgName),PChar(Cmd), nil, nil, False, 0, nil, nil, sInf, pInf) then
while GetExitCodeProcess(pInf.hProcess, Code)
and (Code = STILL_ACTIVE) do
begin
Application.ProcessMessages;
Sleep(500);
end;
Result := Code;
CloseHandle(pInf.hThread);
CloseHandle(pInf.hProcess);
end;


 
SergeSV   (2002-08-08 12:01) [4]

Ну да, и вызов:

ExecResult := ExecuteSomething(IShield, IShield+" -p"+IProject+" -m"+MediaType+" -b""+tempPath+"" "+lParams, SW_SHOWNORMAL);

{Вверху IShield = "C:\PROGRA~1\INSTAL~2\PROFES~1\Program\ISBuild.exe" второй параметр то же самое только с параметрами уже для IShield}


// Ниже просто обработка результата
if ExecResult = 0 then mResults.Lines.Add(" Compilation finished "+DateTimeToStr(Now)+" Return code: "+IntToStr(ExecResult)+" (No errors)")
else mResults.Lines.Add("Compilation finished "+DateTimeToStr(Now)+" Return code: "+IntToStr(ExecResult)+" See package log for details.");
mResults.Lines.Add("");


 
Alx2   (2002-08-08 14:03) [5]

Var
PInf : TProcessInformation;
StInfo : TStartupInfo;
begin
StInfo.dwFlags := STARTF_USESHOWWINDOW;
CreateProcess("filename.exe",<параметры>,Nil,Nil,
False,0,nil,nil,stInfo,PInf);
// Но сначала нужно проверить успешность запуска
WaitForSingleObject(PInf.hProcess,INFINITE);
end;

просто ждем окончания процесса, при этом совсем не загружаем процессор, в отличие от
"
SergeSV (08.08.02 11:52)
...........
while GetExitCodeProcess(pInf.hProcess, Code)
.......
"



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

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

Наверх





Память: 0.46 MB
Время: 0.006 c
1-56204
Just programmer
2002-10-07 16:39
2002.10.17
Прорисовка элементов спика


1-56103
maiar
2002-10-09 02:22
2002.10.17
Линейка разметки для richedit ов


3-55926
AlexeyBl
2002-09-22 12:19
2002.10.17
Как сделать разные PopupMenu для заголовка и записей TDBGrid ?


7-56381
Андрей Рыбцов
2002-08-12 09:38
2002.10.17
Вопрос по работе с каталогами


4-56405
МИФИст
2002-09-03 21:45
2002.10.17
Номер последней видмиой строки в RichEdit е...





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский