var
  hMutex:THandle;
begin
  Application.Initialize;
  hMutex:=CreateMutex(nil,false,'MarryNet');
  if GetLastError<>ERROR_ALREADY_EXISTS then
  begin
    Application.Title := '&Uacute;&auml;&Auml;°&raquo;é&frac12;é&sup1;&Uuml;&Agrave;í&Iuml;&micro;&Iacute;&sup3;';
    Application.CreateForm(Tado_conn, ado_conn);
    frm_login:=Tfrm_login.Create(nil);
    frm_login.ShowModal;
    Application.Run;
  end;
  ReleaseMutex(hMutex);
end.
在login form 中点击取消
程序就出错!
取消执行:Application.Termation各位高手怎么解决?

解决方案 »

  1.   

    改成这样的试试:
    var
      hMutex:THandle;
    begin
      Application.Initialize;
      hMutex:=CreateMutex(nil,false,'MarryNet');
      if GetLastError<>ERROR_ALREADY_EXISTS then
      begin
        Application.Title := '&Uacute;&auml;&Auml;°&raquo;é&frac12;é&sup1;&Uuml;&Agrave;í&Iuml;&micro;&Iacute;&sup3;';
        Application.CreateForm(Tado_conn, ado_conn);
        frm_login:=Tfrm_login.Create(nil);
        try
          if frm_login.ShowModal<>mrok then
          Application.Termation;
        finally
          frm_login..free;    
        end;
        Application.Run;
      end;
      ReleaseMutex(hMutex);
    end.
    //注意:login form 中的取消按钮设置它的modaltrsult属性为:mrCancel就行不需要任何事件,而确定按钮的事件为:如果登录成功则:modalresult:=mrok;就可以了.
      

  2.   

    将登陆窗体设为非自动创建,再取消事件中,
    close;
    application.termation;试试
      

  3.   

    我再来改var
      hMutex:THandle;
    begin
      Application.Initialize;
      hMutex:=CreateMutex(nil,false,'MarryNet');
      if GetLastError<>ERROR_ALREADY_EXISTS then
      begin
        Application.Title := '&Uacute;&auml;&Auml;°&raquo;é&frac12;é&sup1;&Uuml;&Agrave;í&Iuml;&micro;&Iacute;&sup3;';
        Application.CreateForm(Tado_conn, ado_conn);
        frm_login:=Tfrm_login.Create(nil);
        try
          if frm_login.ShowModal=mrok then
            Application.Run;
        finally
          frm_login..free;    
        end;
      end;
      ReleaseMutex(hMutex);
    end.
    //注意:login form 中的取消按钮设置它的modaltrsult属性为:mrCancel就行不需要任何事件,而确定按钮的事件为:如果登录成功则:modalresult:=mrok;就可以了.
      

  4.   

    >>> frm_login.ShowModal=mrok
    出错:Undeclared identifiers 'mrok'
      

  5.   

    在这个单元里引用Forms单元看看!