8 个解决方案
#1
msdn下process类。
#2
msdn下process类。
#4
using System.Diagnostics;
string str = "";
Process[] processes;
//Get the list of current active processes.
processes = System.Diagnostics.Process.GetProcesses();
//Grab some basic information for each process.
Process process;
for(int i = 0;i<processes.Length-1;i++)
{
process = processes[i];
str = str + Convert.ToString(process.Id) + " : " +
process.ProcessName + "\r\n";
}
//Display the process information to the user
System.Windows.Forms.MessageBox.Show(str);
string str = "";
Process[] processes;
//Get the list of current active processes.
processes = System.Diagnostics.Process.GetProcesses();
//Grab some basic information for each process.
Process process;
for(int i = 0;i<processes.Length-1;i++)
{
process = processes[i];
str = str + Convert.ToString(process.Id) + " : " +
process.ProcessName + "\r\n";
}
//Display the process information to the user
System.Windows.Forms.MessageBox.Show(str);
#5
process能获取到其他登录用户已经打开的进程么?现在的需求是有一个winfrom程序在服务器上运行,而且是开机自启的。就是当服务器重启的时候这个程序就会启动,当有远程桌面连接到这个服务器的时候winfrom也会自动启动,也就是说这个时候系统上就会有2个winfrom在运行了。现在就是有没有办法只能让本机运行这个winfrom
#6
谁知道啊
#7
就是怎么判断远程桌面不让运行
#8
如果可以修改这个WinForm程序的话,把这个WinForm程序改为单实例的。方法是在程序的入口处Main中加入如下代码:
bool isRunning;
System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OnlyRunOneInstance", out isRunning);
if (isRunning)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
else
{
MessageBox.Show("程序已启动", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#1
msdn下process类。
#2
msdn下process类。
#3
#4
using System.Diagnostics;
string str = "";
Process[] processes;
//Get the list of current active processes.
processes = System.Diagnostics.Process.GetProcesses();
//Grab some basic information for each process.
Process process;
for(int i = 0;i<processes.Length-1;i++)
{
process = processes[i];
str = str + Convert.ToString(process.Id) + " : " +
process.ProcessName + "\r\n";
}
//Display the process information to the user
System.Windows.Forms.MessageBox.Show(str);
string str = "";
Process[] processes;
//Get the list of current active processes.
processes = System.Diagnostics.Process.GetProcesses();
//Grab some basic information for each process.
Process process;
for(int i = 0;i<processes.Length-1;i++)
{
process = processes[i];
str = str + Convert.ToString(process.Id) + " : " +
process.ProcessName + "\r\n";
}
//Display the process information to the user
System.Windows.Forms.MessageBox.Show(str);
#5
process能获取到其他登录用户已经打开的进程么?现在的需求是有一个winfrom程序在服务器上运行,而且是开机自启的。就是当服务器重启的时候这个程序就会启动,当有远程桌面连接到这个服务器的时候winfrom也会自动启动,也就是说这个时候系统上就会有2个winfrom在运行了。现在就是有没有办法只能让本机运行这个winfrom
#6
谁知道啊
#7
就是怎么判断远程桌面不让运行
#8
如果可以修改这个WinForm程序的话,把这个WinForm程序改为单实例的。方法是在程序的入口处Main中加入如下代码:
bool isRunning;
System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OnlyRunOneInstance", out isRunning);
if (isRunning)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
else
{
MessageBox.Show("程序已启动", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}