win32下PrevInstance根本没有意义

解决方案 »

  1.   

    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        nFind = FindWindow(vbNullString, "窗口名")
        If nFind <> 0 Then
          'Ex.  end the program:
          SendMessage nFind, WM_CLOSE, 0, 0
        ...
    不知是否有用。
      

  2.   

    可以通过共享DLL或注册表或文件实现.
      

  3.   

    Public Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
    hFile=GetModuleHandle(strFilePath)
    if hFile=0 then
    msgbox strFilePath & "is not running"
    else
    msgbox strFilePath & "is running"
    end if
      

  4.   

    代码:
    http://www.applevb.com/sourcecode/moudle.zip
    这个代码可以获得当前运行的所有程序、模块的名称,你可以根据列表
    判断程序是否已经执行
    另外一种方法是在某个地方写入信息(文件、注册表),当程序运行写入
    再有程序执行时通过注册信息就可以得知已经有程序执行了,另外当现行
    程序退出后不要忘记将注册信息改过来(有点象信号灯原理)
    www.applevb.com