دوستان
من در برنامه خود یک فایل exe داسی را اجرا می کنم و چگونه می توانم از بسته شدن ( بعد ار اجرا برنامه exe ) این برنامه مطلع شوم
Printable View
دوستان
من در برنامه خود یک فایل exe داسی را اجرا می کنم و چگونه می توانم از بسته شدن ( بعد ار اجرا برنامه exe ) این برنامه مطلع شوم
یعنی میخوای تا زمانی که برنامه بسته نشده کار دیگه ایی انجام نده؟
اگر منظورت اینه در قسمت نکته های دلفی یک کد هست که خیلی جالبه.میتونی از اون استفاده کنی.
اینهم نمونه اش.
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;
اگر میشه بیشتر توضیح بدید شما می خواهید از بسته شدن برنامه مطلع بشید یا فایلexe؟
از بسته شدن فایل exe داسی
می تونی در لیست Process ها چک کنی آیا اون فایل وجود داره یا نه!