如何实现避免运行多个副本呀,一旦有运行就将当前运行的副本bringtotop,

解决方案 »

  1.   

    program Note;uses
      Forms,
      Windows,
      SysUtils,
      main in 'main.pas' {NoteForm},
      InputBox in 'InputBox.pas',
      about in 'about.pas' {Form2},
      inforForm in 'inforForm.pas' {Form3};var
      RvHandle : hWnd;
      AHandle: Word;
      f: textfile;
    {$R *.res}
      
    begin
    if GlobalFindAtom(PChar(Application.ExeName)) = 0 then
      begin
        Application.Initialize;
        Application.CreateForm(TNoteForm, NoteForm);
        Application.Run;
      end
    else
    begin
      RvHandle := FindWindow('TNoteForm', NIL);
      if RvHandle > 0 then
      begin
        if FileExists('NoteId.txt') then
        begin
          AssignFile(f, 'NoteId.txt');
          reset(f);
          readln(f, AHandle);
          closeFile(f);
          if IsIconic(AHandle) then OPENICON(AHandle)
          else
          begin
            ShowWindow(RvHandle,SW_RESTORE);
            SetForegroundWindow(RvHandle);
          end;
        end;
      end;
    end;注:我这里是避免同一目录下的程序反复执行(允许不同目录下的相同程序运行),改一下就可以满足你的要求
      

  2.   

    http://expert.csdn.net/Expert/topic/1879/1879459.xml?temp=5.764407E-02
    方法很多。
      

  3.   

    ShowWindow(handle,SW_RESTORE)好像就可以了
      

  4.   

    ABC组件有这个
    自己写也可以,使用原子即可