|
-
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?
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
|