Win32当然不能这样,各个process是独立的
可以该这样:
hwnd =  FindWindow( "TLogin", NULL );
if(hwnd)  
{
  MessageBox(NULL,"Already run!","Login", MB_OK);
  return 0;
}

解决方案 »

  1.   

    想搞木马程序啊~~居心叵测......
    我的网站上现在正在上传一个开机后自动login的程序
    (有源代码)
    晚上就可以看到了
    http://cppsource.yeah.net
      

  2.   

    program MZXT;uses
      WINDOWS,
      Forms,
      MainApp in 'MainApp.pas' {MainForm},
    {$R *.RES}
    const
      classname = 'TMainForm';
    var
      handle : integer;
    begin
      handle := findwindow(classname,nil);
      if handle <> 0 then  begin
         showwindow(handle,SW_SHOW);
         halt;
      end;
      Application.Initialize;
      Application.Title := 'aaa';
      Application.CreateForm(TMainForm, MainForm);
      Application.Run;
    end.
      

  3.   

    ghj1976的方法可以,不过在DELPHI环境下运行必须关闭TMainForm,否则程序不会运行.
    因为Found the Window.可以试试以下的方法.本人已经测试过.1、主窗口的修改  TFormCapture = class(TForm)  ...  protected //增加
        procedure CreateParams(var Params: TCreateParams); override;
        procedure RequestRestore(var Message: TMessage); message CM_RESTORE;
      end;implementation{$R *.DFM}...procedure TFormCapture.CreateParams(var Params: TCreateParams);
    begin
      Inherited CreateParams(Params);
      Params.WinClassName := 'MAINFORM'; //新的类名
    end;procedure TFormCapture.RequestRestore(var Message: TMessage);
    begin
      if IsIconIc(Application.Handle) then
        Application.Restore
      else
        Application.BringToFront;
    end;
    2、工程文件的修改program TEST;uses
      ...  Main in 'Main.pas' {MainForm},
    {$R *.RES}
    var
      M_Handle : THandle;
    begin
      Application.Initialize;
      M_Handle := findwindow('MAINFORM',nil); //查找修改的类名
      if M_Handle <> 0 then
      begin
        PostMessage(M_Handle, CM_RESTORE, 0, 0);
        Exit;
      end;
      Application.CreateForm(TMainForm, MainForm);
      Application.Run;
    end.
      

  4.   

    firewing:
      本网站的delphi资料库中有很多小技巧,你的问题的答案就在其中,没必要浪费分数!
      xixi(^^)
      

  5.   

    本网站的delphi资料库或ZDG出的两片盘中均有相应控件,找出来直接用就是。
      

  6.   

    想在Delphi IDE中实现的话要用到EnumWindow(),自己查查它的帮助吧……
      

  7.   

    还用控件吗?看看下面的代码,在工程文件中加入:
    program Project1;uses
     Forms,Windows,SysUtils,
     unit1 in 'unit1.pas' {Form1};
     {$R *.RES}
     Var
        hMutex:HWND;
        Ret:Integer;
     begin
      Application.Initialize;
      Application.Title := 'hello';
      hMutex:=CreateMutex(nil,False,'NoTwice');
      Ret:=GetLastError;
      If Ret<>ERROR_ALREADY_EXISTS Then
       Begin
        Application.CreateForm(TForm1, Form1);
        Application.Run;
       End
      Else
       Application.Terminate;
       ReleaseMutex(hMutex);
     end.上文已调试通过.
      

  8.   

    本人在本站的delphi技术资料系统控制下找到关于“避免两次运行”的答案,确实可行。
    不妨前去一试!
      

  9.   

    我有一个这样的控件,可以MAIL给你。 我的MAIL:[email protected]