Giả sử mình có ứng dụng notepad.exe đang chạy
Muốn tạo sự kiện cho button là tắt notepad.exe thì phải làm thế nào nhỉ ??
Rồi xác định thư mục hệ thống như thế nào nhỉ ??
%dirsystem% <-- cái này ko đc
Giả sử mình có ứng dụng notepad.exe đang chạy
Muốn tạo sự kiện cho button là tắt notepad.exe thì phải làm thế nào nhỉ ??
Rồi xác định thư mục hệ thống như thế nào nhỉ ??
%dirsystem% <-- cái này ko đc
System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcesses();
for (int i = 0; i < process.Length; i++)
{
if (process[i].ProcessName == "notepad.exe")
{
process[i].Kill();
break;
}
}
private string GetSystemSpecialFolderDirectory()
{
//Program files
string sProgramFilesFolder = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.ProgramFiles);
//Personal
string sPersonalFolder = System.Environment.GetFolderPath (
System.Environment.SpecialFolder.Personal);
//Desktop
string sDesktopFolder = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.DesktopDirectory) ;
//Application Data
string sApplicationDataFolder = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.ApplicationData);
//System:
string sSystemFolder = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.System);
MessageBox.Show("Program files: " + sProgramFilesFolder +
"\r\nPersonal: " + sPersonalFolder +
"\r\nDesktop: " + sDesktopFolder +
"\r\nApplication Data: " + sApplicationDataFolder +
"\r\nSystem: " + sSystemFolder);
}
Bookmarks