怎么通过我的程序来帧听另外一个应用程序是否在运行

解决方案 »

  1.   

    在timer的ontimer事件里面加上if findwindow(nil,windowcaption) <> 0 then
        showmessage('program is now running');windowcaption为你要监视的窗体的caption
      

  2.   

    在.dpr文件中:
     h : HWND;
     ret : integer; APplication.initialized;
     h := CreateMutex(nil, false, pchar(Application.Title));
     ret:=GetLastErro;
     if h=ERROR_ALREADY_EXISTS then
     begin
       showmessage('程序已经运行');
       ReleaseMutex(h);
       Application.Terminate;
     end;
     ReleaseMutex(h);
     Application.run;
      

  3.   

    错了:在.dpr文件中:
     h : HWND;
     ret : integer; APplication.initialized;
     h := CreateMutex(nil, false, pchar(Application.Title));
     ret:=GetLastError;   //少了一个r
     if h=ERROR_ALREADY_EXISTS then
     begin
       showmessage('程序已经运行');
       ReleaseMutex(h);
       Application.Terminate;
     end;
     ReleaseMutex(h);
     Application.run;