你用这种方法呢
program test;uses
Forms,Windows,SysUtils;
{$R *.RES}Var
hMutex:HWND;
Ret:Integer;
begin
Application.Initialize;
Application.Title := 'test';
hMutex:=CreateMutex(nil,False,'test');
Ret:=GetLastError;
If Ret<>ERROR_ALREADY_EXISTS Then 
Begin
Application.CreateForm(TForm1, Form1);
Application.Run;
End
Else
Application.MessageBox('已经运行!','警告!',MB_OK);
ReleaseMutex(hMutex);
end.

解决方案 »

  1.   

    begin
    if not assigned(someform) then begin
    application.createform.(Tsomeform,someform);
    try 
    someform.showmodal;
    finally
    domeform.free;
    someform:=nil;
    end;
    end
    else
    someform.showmodal;
    end; 
      

  2.   

    这样做我也试过,不能达到再次双击exe文件就把已运行的程序还原到最前窗口,只是出一个MessageBox而已。
      

  3.   

    to hxshanji(山鸡):不好意思,我的回答是针对summer1978(夏)的,我试试你的!
      

  4.   

    抱歉我那段一定要showmodal;针对有模窗体有用
      

  5.   

    也发给我一份,OK?
    [email protected]
      

  6.   

      if findwindow('TMainForm',nil)<>0 then
      begin
        halt; {退出程序}
     end;
    'TMainForm' 是主 Form
      

  7.   

    to zou5655(周围):我还没收到。
    我很急啊,真的没人能解决吗?
      

  8.   

    给我发一个。    [email protected]