|
-
Jan 22nd, 2006, 08:14 PM
#1
Thread Starter
Addicted Member
Closing programs code isn't behaving correctly
hey. I'm having some trouble with the code to close programs. heres what I have for my code so far:
Dim px() As Process = System.Diagnostics.Process.GetProcesses 'gets processes running
'gets number of DuckySE processes
For Each Proc As Process In px 'loops through all processes, finding the name we want
If Proc.ProcessName = "myProgram" And Not Proc.MainWindowHandle.ToInt32 = Me.Handle.ToInt32 Then 'used so doesnt close self
Proc.CloseMainWindow()
End If
Next
The problem is that it only closes some of the time! When I have this in a command button, it can find all the processes but it just doesn't close them. I dont have anything thats preventing it from closing in the form_closing of the applications either. Does the window have to be infocus or something? any ideas? .kill() works, but id like the other other one to work cause then it closes correctly....
-
Jan 22nd, 2006, 08:34 PM
#2
Re: Closing programs code isn't behaving correctly
Assuming that there is nothing in your app that would prevent it closing then this should work.
VB Code:
Dim myProcID As Integer = Process.GetCurrentProcess.Id
For Each proc As Process In Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)
If proc.Id <> myProcID Then
proc.CloseMainWindow()
End If
Next proc
-
Jan 23rd, 2006, 02:41 PM
#3
Thread Starter
Addicted Member
Re: Closing programs code isn't behaving correctly
ok thanks. I tried that and it still doesnt work! The only code I have in the form_closing is: trayicon1.visible = false. Still no luck. It works though with the .kill(). I want to use the other one though because then it will hide the icon. Any ideas?
-
Jan 23rd, 2006, 02:44 PM
#4
Thread Starter
Addicted Member
Re: Closing programs code isn't behaving correctly
ok I just realized why it doesnt work. My apps are set up to now show in the taskbar! I want it that way though. Anyway to get this to work wihtout having the programs show in the taskbar?
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
|