如题,尽量做到 当我重命名程序名的时候也无法多开!

解决方案 »

  1.   

    Mutex啊。
    参考这篇文章http://blog.csdn.net/gaoyunpeng/archive/2008/05/16/2452052.aspx
      

  2.   


    Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" (ByVal lpMutexAttributes As Integer, ByVal bInitialOwner As Integer, ByVal lpName As String) As Integer
        Declare Function GetLastError Lib "kernel32" Alias "GetLastError" () As Integer
        Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Integer) As IntegerConst ERROR_ALREADY_EXISTS = 183&
    Dim hwnd As Integer
    Private Function CMutex() As Boolean
            hwnd = CreateMutex(0, 1, "随便起个名字")
            If GetLastError = ERROR_ALREADY_EXISTS Then
                MessageBox.Show("一个应用程序的实例已被打开", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop)
                Return False
            End If
            Return True
        End Function'最后程序退出的时候要
    CloseHandle(hwnd)
      

  3.   

    单实例http://topic.csdn.net/u/20091118/18/9f3f7c0a-20fa-4006-9ccd-823734b10353.html
      

  4.   

    http://topic.csdn.net/u/20100717/22/a1dbc706-2a04-4cd8-872e-fdcba7c77fb3.html
      

  5.   

    string name = Application.ProductName;
    Process[] prc = Process.GetProcessesByName(name);
    if (prc.Length > 1)
    {
        MessageBox.Show("当前程序已启动");
        return;
    }
      

  6.   

    在网上找到了 方法 是用Mutex 类的  楼上的思路也对 但是 我也试了下 可以捕捉到 相同进程 但是 少了一个结束进程的 kill方法!不过 要做实现也不难!结贴给分!