|
-
Nov 1st, 2006, 07:51 AM
#1
Thread Starter
Member
[RESOLVED] More powerful than API TerminateProcess...
I've tested API TerminateProcess and it did not kill some programs like
"Warcraft 3 Frozen Throne" as far as i knew the program is not running as
service...why? is there any other way which is more powerfull to kill a process
like the one program i mentioned above...thanks
-
Nov 1st, 2006, 08:39 AM
#2
Hyperactive Member
Re: More powerful than API TerminateProcess...
I don't have VB6 with me right now, but stick this in a module and try:
VB Code:
Option Explicit
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" _
(ByVal hwnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
Private Declare Function EnumWindows Lib "user32.dll" _
(ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Target As String
Private Const WM_CLOSE = &H10
Private Function EnumCallback(ByVal app_hWnd As Long, ByVal param As Long) As Long
Dim buf As String * 256
Dim title As String
Dim length As Long
Dim hWndREC As Long
length = GetWindowText(app_hWnd, buf, Len(buf))
title = Left$(buf, length)
If InStr(1, title, Target, 3) <> 0 Then
PostMessage app_hWnd, WM_CLOSE, 0, 0
End If
EnumCallback = 1
End Function
Public Sub CloseProgram(app_name As String)
Target = app_name
EnumWindows AddressOf EnumCallback, 0
End Sub
Call with
CloseProgram("Warcraft 3 Frozen Throne"), or whatever the caption is in the toolbar.
-
Nov 1st, 2006, 09:08 AM
#3
Thread Starter
Member
Re: More powerful than API TerminateProcess...
Works Great thanks...
but another problem comes up...because i want to programatically kill some processes that way, i dont know how to enumerate the caption of each process that is on the taskbar so that i can pass each caption to closeprogram...can you show me how...thank you very very much.
-
Nov 1st, 2006, 04:51 PM
#4
Hyperactive Member
Re: More powerful than API TerminateProcess...
I'm not sure what you mean.. do you want to end every process with this function?
-
Nov 1st, 2006, 05:16 PM
#5
Re: More powerful than API TerminateProcess...
Why do you need to terminate so many processes?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 1st, 2006, 08:50 PM
#6
Thread Starter
Member
Re: More powerful than API TerminateProcess...
Ok, this is what i mean...
At a certain amount of time, my app should kill some process(a variety of programs) which have been lunch(and was left running) during the session. my app will iterate through a list of that processes and kill each one of them.
And by using the function above, it needs to know the captions of each processes in order to kill it, right.
Thats where my problem arise, i have to enumerate and make a list of the "captions" of that variety of running processes, how would i get that "captions" programatically...
(im pretty sure its not the exe name)
i hope you understand my explanation...
-
Nov 1st, 2006, 11:38 PM
#7
Re: More powerful than API TerminateProcess...
Umm, no. You can Terminate a running process just by its exe name.
http://www.vbforums.com/showpost.php...71&postcount=5
And to enumerate the running processes.
http://vbforums.com/showthread.php?t=244232
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 2nd, 2006, 10:34 PM
#8
New Member
Re: More powerful than API TerminateProcess...
I think i got your problem(same with mine) and maybe This can help you too.
-
Nov 2nd, 2006, 10:40 PM
#9
Thread Starter
Member
Re: More powerful than API TerminateProcess...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|