Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2004, 03:55 PM
Registered User
 
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Terminate Process (How To)

Hi guys this is my first post on these forums im a newbie to VB6

I am trying to make a simple program with one button

When the button is pressed I want it to kill the process explorer.exe

Heres the code I have already

..............................................
Declarations
......................
Public Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
..............................................
Code
.....................
Private Sub Kill_Click()

TerminateProcess explorer.exe

End Sub
.................................................. ..........................................

Can anyone explain to me what I need to do in order for this to happen ?
Tnx in advance,
Nova



 
Old June 16th, 2004, 04:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

i dont know why you wanna kill the explorer.. sounds weird, but you dont send a name to terminateprocess.. you need the handle for the proccess.. and you dont have it since you dont start explorer by hand.. could be a little tricky to get it...



HTH

Gonzalo
 
Old June 16th, 2004, 04:08 PM
Registered User
 
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have made a simular program using batch,and now that im learning VB6 id like to make the same program in vb

Killing and refreshing explorer.exe helps my laptop to load trayicons on startup its a really old laptop and doing this cuts the time for the icons to appear in half.

So dose anyone know of a way I can kill explorer.exe :D

 
Old October 14th, 2006, 02:37 PM
mkb mkb is offline
Registered User
 
Join Date: Oct 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

now it been a while since i used vb6
but i rember sumthink like this declare handle as a long
then what window (explorer in this cae)

Handle = FindWindow(vbNullString, Caption)
SendMessage Handle, WM_CLOSE, 0&, 0&

should be sumthink like that but has been a while since i used vb6 u should move to ther .net framework everythink so easy i perfer c# now but vb.net and c# are very simular only took me like 4 days 2 conver but makes thes jobs so easy simple

 string processName = "explorer";
            Process[] processes = Process.GetProcessesByName(processName);
            foreach (Process process in processes)
            {
                process.Kill();}

and in vb.net its practicly the same






Similar Threads
Thread Thread Starter Forum Replies Last Post
process.startinfo opens new instance of process Anypond General .NET 0 August 28th, 2008 05:35 AM
Terminate Already-Existing App Instance wscheiman Pro VB 6 0 January 10th, 2007 09:08 AM
Form Hide and terminate raj_phoenix Excel VBA 4 January 17th, 2005 07:55 AM
terminate a thread problem lmadhavi Visual C++ 0 November 23rd, 2004 06:20 AM
How to terminate program execution without "End" pavel Beginning VB 6 2 September 2nd, 2003 06:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.