掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ShellExecuteで実行したプロセスを終了させるには (ID:8622)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
> 「ShellExecuteExでプロセス終了」の方はわかりません。 こんな感じです。わたしのところでは、EmEditor が立ち上がって、10秒後に 閉じます。 uses ShellAPI; var hProcess:THandle; function ExecAndWaitQuit(FileOrURL:string):Boolean; var sei:TShellExecuteInfo; begin FillChar(sei,SizeOf(TShellExecuteInfo),#0); sei.cbSize := SizeOf(TShellExecuteInfo); sei.fMask := SEE_MASK_NOCLOSEPROCESS; sei.Wnd := Form1.Handle; sei.lpVerb := 'open'; sei.lpFile := PChar(FileOrURL); sei.lpDirectory := PChar(ExtractFilePath(Application.Exename)); sei.nShow := SW_SHOWNORMAL; result := ShellExecuteEx(@sei); if result then hProcess := sei.hProcess else hProcess := 0; end; procedure TForm1.Button1Click(Sender: TObject); begin if ExecAndWaitQuit('C:\Test.txt') then begin Sleep(10000); TerminateProcess(hProcess,0); CloseHandle(hProcess); end; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.