| |

VerySource

 Forgot password?
 Register
Search
View: 1345|Reply: 7

The program closed, but the process still exists, and sometimes it takes several minutes to close. How can I avoid this?

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-7 20:00:01
| Show all posts |Read mode
The program closed, but the process still exists, and sometimes it takes several minutes to close. Since my program is only allowed to open once, the system will prompt "the system is open" when the program is executed after it is opened. Although the program is closed, but the process still exists, it will confuse the user at this time. How can I avoid this?
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-8-9 02:00:02
| Show all posts
Don't wait a few minutes. Just a few seconds
Reply

Use magic Report

2

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-8-16 01:15:01
| Show all posts
Are there too many resources that are not DESTORY being recycled by the system?
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-17 07:00:02
| Show all posts
May be busy
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-17 07:30:01
| Show all posts
Try halt in close
Reply

Use magic Report

0

Threads

4

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-18 14:45:02
| Show all posts
I don’t know if you mean closing a window or an application process. If it is an application process, you can
Considering the above code, you can end any process. Just pass in a process name.
Reply

Use magic Report

0

Threads

4

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-18 15:00:02
| Show all posts
//Create a non-visual object uf_get_exename
   
  //Declare local external function(api)
  Function Long CreateToolhelp32Snapshot(Long Flags,Long ProcessId) Library "kernel32.dll"
  Function Integer Process32First(uLong Snapshot,ref s_Process Process) Library "kernel32.dll"
  Function Integer Process32Next(uLong Snapshot,ref s_Process Process) Library "kernel32.dll"
   
  //Create structure before declaration
  unsignedlong structsize
  unsignedlong usage
  unsignedlong processid
  unsignedlong defaultheapid
  unsignedlong moduleid
  unsignedlong threads
  unsignedlong parentprocessid
  unsignedlong classbase
  unsignedlong flags
  character filename[260]
  //The function of constructing the object uf_get_exename of_getexe()
   
  //////////////////////////of_getexe()//////////////////// ////
  Function: enumerate processes and return the PID of the specified process number
  Incoming: None
  Back: Long
  ///////////////////////////////////////////////// ///////////
   
  s_Process lst_Process
  string ls_filename[100] ,ls_curexename
  ulong ln_ProcessID,ln_SameCount,ln_Snapshot,ln_Circle,ln_Count,ul_PID
   
  ul_PID = 0
  ln_Snapshot = CreateToolhelp32Snapshot(2,0)
  if (ln_Snapshot<1) then return 0
  lst_Process.StructSize = 296
   
  if Process32First(ln_Snapshot,lst_Process)=0 then return 0
   
  //Enumerate processes under current permissions
  debugbreak()
  do while true
   
  if Process32Next(ln_Snapshot,lst_Process)=0 then exit
  ln_Count = ln_Count + 1
  ls_FileName[ln_Count] = lst_Process.FileName
  If Lower(ls_FileName[ln_Count]) ='iexplore.exe' Then
  //Get the process number
  ul_PID = lst_Process.ProcessID
  //messagebox(string(ul_PID),ls_FileName[ln_Count])
  End If
   
  loop
   
  return ul_PID
   
  //Next
  //Create a form, put a button on it cb_click
   
  //Declare local external function(api) in the form
  FUNCTION ulong TerminateProcess(ulong hProcess,ulong uExitCode) LIBRARY "kernel32.dll"
  FUNCTION ulong OpenProcess(ulong dwDesiredAccess,ulong bInheritHandle,ulong dwProcessId) LIBRARY "kernel32.dll"
   
  //cb_click clicked event
   
  uf_get_exename luf_get_exename
   
   
  INTEGER li_rc
  ULONG ul_PID
  ULONG PROCESS_TERMINATE = 0001
  ULONG hwdprocess
   
  If messagebox('End process','Are you sure? Kill?',question!,yesno!,1) = 2 Then return
   
  //Create instance variables
  luf_get_exename = create uf_get_exename
  //Get the specified process number
  ul_PID = luf_get_exename.of_getexe()
   
  If ul_PID = 0 Then
        Messagebox('End process','No IE process found!')
        return
  End If
   
  If ul_PID <> 0 Then
  //Get the process handle of the specified process number
  hwdprocess = OpenProcess(PROCESS_TERMINATE,1,ul_PID)
  //messagebox('',string(hwdprocess))
    //End the process, return non-zero successfully
  li_rc = TerminateProcess(hwdprocess,0)
  If li_rc <> 0 Then Messagebox('End process','Successfully end process!')
  End If
   
   
  Destroy luf_get_exename;
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-27 11:45:01
| Show all posts
I will not disappear in the process until a program error occurs.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list