请教给位高手,在c#中如何防止一个程序被同时启动多次(不用FindWindow方法),
另外,为什么我调用GetLastError(),返回127(在delphi中返回0)。
请高人指点一下,万分感谢!!!
另外,为什么我调用GetLastError(),返回127(在delphi中返回0)。
请高人指点一下,万分感谢!!!
解决方案 »
- 请教如何自动注册EMAIL
- 用XML做WEB SERVICE的小数据库,保存成XML的时机问题。
- 【急切求助】如何改变文本框内部分内容的字体颜色?
- C# dataTable 数据筛选问题,请教!!!
- label控件怎么让他的背景为透明的呢
- 急。。。。html转pdf文件的
- 问问各位,获取摄像头的程序和获取视频采集卡的程序是不是一样的?
- 如何编写具有翻页功能的用户自定义控件
- (求助)gridcontrol dGridView 单元格内容改变后背景颜色改变。
- 关于MVC + WebService 的模式是否可行?
- 高分求教:怎样知道当前文本框中被删除的字符是哪个字符,以及被删除的字符是第几个字符?
- 怎样在win应用程序中打开变量为aaa的本程序的窗口
看看这里,我也是收集的
但是如果程序意外终止,ini来不及改回去,那下次不就开不了了?
获得windows打开的所有进程,然后比较进程明,看有没有你的程序的进程,以及进程数量
这样就可以控制打开数量了
using System.Diagnostics;
using System.ComponentModel;namespace MyProcessSample
{
/// <summary>
/// Shell for the sample.
/// </summary>
public class MyProcess
{
public void BindToRunningProcesses()
{
// Get the current process.
Process currentProcess = Process.GetCurrentProcess();
// Get all instances of Notepad running on the local
// computer.
Process [] localByName = Process.GetProcessesByName("notepad");
// Get all instances of Notepad running on the specifiec
// computer.
// 1. Using the computer alias (do not precede with "\\").
Process [] remoteByName = Process.GetProcessesByName("notepad", "myComputer");
// 2. Using an IP address to specify the machineName parameter.
Process [] ipByName = Process.GetProcessesByName("notepad", "169.0.0.0");
// Get all processes running on the local computer.
Process [] localAll = Process.GetProcesses();
// Get all processes running on the remote computer.
Process [] remoteAll = Process.GetProcesses("myComputer");
// Get a process on the local computer, using the process id.
Process localById = Process.GetProcessById(1234);
// Get a process on a remote computer, using the process id.
Process remoteById = Process.GetProcessById(2345, "myComputer");
}
public static void Main()
{
MyProcess myProcess = new MyProcess();
myProcess.BindToRunningProcesses(); }
}
}