首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

dpr 处报错解决方案

2012-09-18 
dpr处报错Delphi(Pascal) codeprogram RevarhMutex:hwndret:integer{$R *.res}begintrytryApplication.

dpr 处报错

Delphi(Pascal) code
program Re;var  hMutex:hwnd;  ret:integer;{$R *.res}begin      try            try                  Application.Initialize;                  hmutex:=createMutex(nil,false,'YuYue');                  ret:=getlasterror;                  if ret <>error_already_exists then                               //防止程序多次运行                  begin                        Application.CreateForm(TDM, DM);                        Frm_Login:=TFrm_Login.Create(Application);                  //创建登陆窗口,输入正确登入                        if Frm_Login.ShowModal=idOk then                        begin                              Application.Title := '预约系统';                              Frm_Loading := TFrm_Loading.Create(Application);                              FRM_Loading.Show;                              FRM_Loading.Update;                              Application.CreateForm(TFrm_Main, Frm_Main);                              FRM_Loading.Hide;                              FRM_Loading.Update;                              FRM_Loading.Free;                              Application.Run;                        End;                  end                  else                  begin                        Application.MessageBox('【门诊预约】已经运行','【门诊预约】',MB_OK+MB_IconError);                  end;            except                  on E:Exception do                  begin                        Write_LogErr(C_UnitNo+'0001:项目启动处',IntToStr(E.HelpContext)+':'+E.Message,'');                      end;            end;//end  except      finally            releasemutex(hmutex);               //释放句柄      end;//end finallyend.//end begin


if Frm_Login.ShowModal=idOk then

登入进去再退出来没有问题。

但是在登陆界面,直接退出,就报一堆错!

报错的位置是:
  finally
  releasemutex(hmutex); //释放句柄
  end;//end finally
即使把releasemutex(hmutex); 注释掉,也任然会报错。





[解决办法]
LZ不觉得在finaly里加入DM.Free;会有问题么?你的dm创建是有条件的

热点排行