ورود

View Full Version : مطللع شدن از بسته شدن یک برنامه



reza_Nazem
چهارشنبه 29 شهریور 1385, 11:31 صبح
دوستان

من در برنامه خود یک فایل exe داسی را اجرا می کنم و چگونه می توانم از بسته شدن ( بعد ار اجرا برنامه exe ) این برنامه مطلع شوم

حمیدرضاصادقیان
چهارشنبه 29 شهریور 1385, 11:48 صبح
یعنی میخوای تا زمانی که برنامه بسته نشده کار دیگه ایی انجام نده؟
اگر منظورت اینه در قسمت نکته های دلفی یک کد هست که خیلی جالبه.میتونی از اون استفاده کنی.
اینهم نمونه اش.


function ExecutePrg(const CmdLine: String; const Wait: boolean): boolean;
var
LastError: Integer;
ExitCode: Cardinal ;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
StartupInfo.wShowWindow := SW_SHOWNORMAL;
Result := CreateProcess(nil, // ptr to name of executable module
PChar(CmdLine), // ptr to command line string
nil, // ptr to process security attributes
nil, // ptr to thread security attributes
false, // handle inheritance flag
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, // creation flags
nil, // ptr to new environment block
nil, // ptr to current directory name
StartupInfo, // ptr to STARTUPINFO
ProcessInfo); // ptr to PROCESS_INFORMATION
if Result then
begin
if Wait then
begin
repeat
Application.ProcessMessages;
GetExitCodeProcess(ProcessInfo.hProcess, ExitCode);
until (ExitCode <> STILL_ACTIVE);
end;
end
else
begin
LastError := GetLastError;
MessageDlg(' (Error : ' +IntToStr(LastError) +')', mtError, [mbOK], 0);
end;
end;

amin a.^2
چهارشنبه 29 شهریور 1385, 14:44 عصر
اگر میشه بیشتر توضیح بدید شما می خواهید از بسته شدن برنامه مطلع بشید یا فایلexe؟

reza_Nazem
چهارشنبه 29 شهریور 1385, 16:30 عصر
از بسته شدن فایل exe داسی

dkhatibi
چهارشنبه 29 شهریور 1385, 17:24 عصر
می تونی در لیست Process ها چک کنی آیا اون فایل وجود داره یا نه!