如果App.PrevInstance 为true,说明程序已经运行。
通过判断这个属性值就可以了

解决方案 »

  1.   

    If App.PrevInstance = True Then
        MsgBox "程序已经在运行当中", vbInformation, "CallCenter"
        end
    End If
      

  2.   

    在主窗体的load事件中判断App.PrevInstance的值,为true表示已有一个实例在运行
      

  3.   

    他们说的都对,重复一下吧.你可以在msdn里面的详细讲述
    sub form_load()
    If App.PrevInstance = True Then
        MsgBox "程序已经在运行当中", vbInformation, "CallCenter"
        end
    End If
    .
    .
    .
    end sub
      

  4.   

      HANDLE hMut = CreateMutex(NULL,TRUE,"sinlerun")
    if GetLastError = ERROR_ALREADY_EXISTS then
    MsgBox(NULL,"Program already Run","error",MB_OK);
    return 0;
    } MessageBox(NULL,"This is a sample of run single Program","s1",MB_OK); CloseHandle(hMut);
      

  5.   

    use WIN APIHANDLE hMut = CreateMutex NULL,TRUE,"sinlerun"
    if GetLastError = ERROR_ALREADY_EXISTS then
      MsgBox NULL,"Program already Run","error",MB_OK
      end
    end if
    CloseHandle hMut