|
-
May 21st, 2006, 11:34 PM
#1
Thread Starter
New Member
-
May 21st, 2006, 11:41 PM
#2
Fanatic Member
Re: How can i kill a background process !
try this code
VB Code:
'Module Declaration
Option Explicit
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Const WM_CLOSE = &H10
'Code
Public Sub CloseProgram(ByVal Caption as String)
Dim Handle As Long
Handle= FindWindow(vbNullString, Caption)
If Handle = 0 Then Exit Sub
SendMessage Handle, WM_CLOSE, 0&, 0&
End Sub
'BUTTON
Private Sub Command1_Click()
CloseProgram ("Title/Name of the Application")
End Sub
noister
<advertising link removed by moderator>
-
May 22nd, 2006, 12:40 AM
#3
Addicted Member
Re: How can i kill a background process !
-
May 22nd, 2006, 12:45 AM
#4
Re: How can i kill a background process !
That will work for processes with a visible window and/or window caption. To truely close a program you need to Terminate its process. Search the forums for Terminate Process and you will find many examples already, a couple by me too.
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 
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
|