-
April 9th, 2011, 04:46 AM
#1
How to close 32 bit and 64 bit programs in C#
this code works to close 64 bit programs after i pick the program.
private void btnSleep_Click(object sender, System.EventArgs e)
{
string processName = ExtractProcessName(ofdBrowse1.FileName);
foreach(Process p in Process.GetProcesses())
{
if(0 == String.Compare(processName, p.ProcessName, true))
{
p.CloseMainWindow();
}
}
}
private string ExtractProcessName(string fileName)
{
string processName = fileName;
int index = processName.LastIndexOf("\\");
if(-1 != index)
{
processName = processName.Substring(index + 1, processName.Length - index - 1);
}
processName = processName.ToUpper();
processName = processName.Replace(".EXE", "");
return processName;
}
How can I get this code to close both 32 bit and 64 bit programs?
-
April 12th, 2011, 11:27 AM
#2
Re: How to close 32 bit and 64 bit programs in C#
This should work for 32bit programs too. It looks like you're navigating to the executable in your file system.
32 bit apps on a 64bit OS are normally stored in C:\Program Files (x86) instead of c:\Program Files
Does that help?
-
April 13th, 2011, 02:44 AM
#3
Re: How to close 32 bit and 64 bit programs in C#
Have you tried it and it doesn't work, or are you just asking? Because it should work. You can only try to add call to Proces.Close().
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
-
April 13th, 2011, 02:46 AM
#4
Re: How to close 32 bit and 64 bit programs in C#
I ran your program and closed both 64bit and 32bit Internet Explorer. I'm running 64bit Windows 7.
-
April 16th, 2011, 12:52 AM
#5
Re: How to close 32 bit and 64 bit programs in C#
I can close windows media player (64) but but can't close blaze media pro(86)
-
April 16th, 2011, 01:20 AM
#6
Re: How to close 32 bit and 64 bit programs in C#
Ok I seem to be able to close 32 bit programs that don't require me to say yes to start the program
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
|