瀏覽器打開后,在PB中如何關閉瀏覽器?
uj5u.com熱心網友回復:
API, 找到行程,再結束它。找一個PB 做的任務管理器,就有了。
uj5u.com熱心網友回復:
宣告APIFunction Long GetCurrentProcessId() Library "kernel32.dll"
Function Long CreateToolhelp32Snapshot(Long Flags,Long ProcessId) Library "kernel32.dll"
Function Integer Process32First(uLong Snapshot,ref s_Process Process1) Library "kernel32.dll"
Function Integer Process32Next(uLong Snapshot,ref s_Process Process1) Library "kernel32.dll"
Function ulong TerminateProcess(long hProcess,ulong uExitCode) LIBRARY "kernel32.dll"
FUNCTION ulong OpenProcess(ulong dwDesiredAccess,ulong bInheritHandle,ulong dwProcessId) LIBRARY "kernel32.dll"
宣告結構體
type s_process from structure
unsignedlong structsize
unsignedlong usage
unsignedlong processid
unsignedlong defaultheapid
unsignedlong moduleid
unsignedlong threads
unsignedlong parentprocessid
unsignedlong classbase
unsignedlong flags
character filename[200]
end type
呼叫,殺死行程 IEXPLORE.EXE
as_pro='IEXPLORE.EXE'
s_Process lst_Process //行程結構
ulong ln_Snapshot
string ls_deal_File
IF as_pro='' OR isnull(as_pro) Then Return 1
ln_Snapshot = CreateToolhelp32Snapshot(2,0) //在堆上創建行程快照
if (ln_Snapshot<1) then return -1 //出錯則回傳
lst_Process.StructSize = 296 //Win32api的Process結構大小
//第一個
if Process32First(ln_Snapshot,lst_Process)=0 then
return -1 //取第一個行程失敗則回傳
End IF
ls_deal_File = lst_Process.FileName
IF pos(lower(as_pro),lower(ls_deal_File))>0 Then
if GetCurrentProcessId() = lst_process.processid then return //自己則回傳,不要輕易自殺
TerminateProcess(Long(OpenProcess(1,0,lst_process.processid)),1) //使該行程可讀寫 //Kill Process
End IF
//第二個及之后的
do while true //回圈取列舉的行程名稱
if Process32Next(ln_Snapshot,lst_Process)=0 then exit //列舉完畢
ls_deal_File = lst_Process.FileName
IF pos(lower(as_pro),lower(ls_deal_File))>0 Then
if GetCurrentProcessId() = lst_process.processid then return //自己則回傳,不要輕易自殺
TerminateProcess(Long(OpenProcess(1,0,lst_process.processid)),1) //使該行程可讀寫 //Kill Process
End IF
loop
Return 1
uj5u.com熱心網友回復:
mark轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/75034.html
標籤:API 調用
下一篇:求購酒店管理系統原始碼
