Home > database >  How to close the open IE browser in the pb?
How to close the open IE browser in the pb?

Time:09-25

The browser opens, in PB how to close the browser?

CodePudding user response:

API, find the process, and then to end it,
To find a PB to do the task manager, there has been,

CodePudding user response:

Statement API
 Function Long GetCurrentProcessId () Library "kernel32. DLL 
"The Function Long CreateToolhelp32Snapshot (Long Flags, Long ProcessId) Library "kernel32. DLL
"The Function of Integer Process32First (uLong Snapshot, ref s_Process Process1) Library "kernel32. DLL
"The Function of Integer Process32Next (uLong Snapshot, ref s_Process Process1) Library "kernel32. DLL
"The Function ulong TerminateProcess (long hProcess, ulong uExitCode) LIBRARY "kernel32. DLL
"The FUNCTION ulong OpenProcess (ulong dwDesiredAccess, ulong bInheritHandle, ulong dwProcessId) LIBRARY "kernel32. DLL
"


The statement structure
 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


Call, kill process IEXPLORE. EXE
 as_pro='IEXPLORE. EXE' 

S_Process lst_Process/structure/process
Ulong ln_Snapshot
String ls_deal_File

IF as_pro='OR isnull (as_pro) Then Return 1

Ln_Snapshot=CreateToolhelp32Snapshot (2, 0)//on the heap snapshot creation process
If (ln_Snapshot & lt; 1) then return 1//an error is returned
Lst_Process. StructSize=296//Win32api Process structure size
//the first
If Process32First (ln_Snapshot, lst_Process)=0 then
Return 1//to take the first process failure returns
End the IF
Ls_deal_File=lst_Process. FileName
IF pos (the lower (as_pro), the lower (ls_deal_File)) & gt; 0 Then
If GetCurrentProcessId ()=lst_process. Processid then return//is returned, don't commit suicide
The TerminateProcess (Long (OpenProcess (1, 0, lst_process. Processid)), 1)//read/write/make the Process/Kill Process
End the IF
//the second and later
The do while true//cycle process name listed in the
If Process32Next (ln_Snapshot, lst_Process)=0 then the exit//finished list
Ls_deal_File=lst_Process. FileName
IF pos (the lower (as_pro), the lower (ls_deal_File)) & gt; 0 Then
If GetCurrentProcessId ()=lst_process. Processid then return//is returned, don't commit suicide
The TerminateProcess (Long (OpenProcess (1, 0, lst_process. Processid)), 1)//read/write/make the Process/Kill Process
End the IF
Loop

Return 1

CodePudding user response:

mark
  • Related