if Trim(SQLServer)='' then
begin
MsgBox('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk]);
Application.Terminate;
exit;
end;Terminate是程序中止,为什么已经中止了,后面还要接一个terminate?谢谢 :)
begin
MsgBox('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk]);
Application.Terminate;
exit;
end;Terminate是程序中止,为什么已经中止了,后面还要接一个terminate?谢谢 :)
解决方案 »
- 新人想学习DELPHI,请教下各位前辈。
- twebBrowser中响应html的事件
- 如何实现让软件响应“取消”事件?
- 怎样用SQL查询姓名字段的第一个字,判断中文或英文?
- 求助:如何实现对Edit中输入的日期数据的检验?
- 请教,关于“name not Unique in this context”的错误。50分,急!!!!
- 怎样让动态生成的控件出现在一个panel里?
- s6283,请进,中国期刊网领取剩下的95分
- 怎样在intraweb下用rave控件来实现报表预览呢?
- 用什么方法可以将文本文件加密(只要用别的软件看不了就行),程序用的时候再解密?
- 请问在Internet上,能不能通过计算机名获得该机器的IP?
- 关于access做后台,在Delphi作时间查询的SQL语句,急!!!!!!!!!
if Trim(SQLServer)='' then
begin
MsgBox('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk]);
Application.Terminate;
exit;
end;Terminate是程序中止,为什么已经中止了,后面还要接一个exit?谢谢 :)
begin
MsgBox('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk]);
Application.Terminate;
exit;
end;不会吧!都终止了还exit有意义吗?
去掉exit就知道它的作用了嘛!或者用断点看看
Application.Terminate确实并非直接终止应用程序,所以那个Exit不能说是多余的!procedure TApplication.Terminate;
begin
if CallTerminateProcs then PostQuitMessage(0);
end;
如:procedure aaa;
beginif Trim(SQLServer)='' then
begin
MsgBox('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk]);
Application.Terminate;
exit;
end;do something;//这块不执行了end;
去掉Exit就行了!
HALT后立即终止应用程序,而不释放其创建的对象.
大家的讨论还挺热烈的
这个exit是一定要要的!
exit是使程序回到刚才!
exit是使程序回到刚才!请问回到刚才什么啊?
你跟踪一下代码看看! 如果执行的话,它就起到Exit的作用。但它根本就不执行
呢! 怎么能够回到刚才呢??
但是把EXIT换成showmessage('');
你们觉得还会执行吗
一但application.terminate就会结束。
procedure TForm1.FormCreate(Sender: TObject);
begin
messagedlg('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk],0);//断点
Application.Terminate;
showmessage('ni SB') ;
// exit;
sleep(1000000) ;
end;运行二:
procedure TForm1.FormCreate(Sender: TObject);
begin
messagedlg('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk],0);//断点
Application.Terminate;
showmessage('ni SB') ;
exit;
sleep(1000000) ;
end;
明显的,第一次时间很长!
TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating. Terminating a process causes the following: 1. All of the object handles opened by the process are closed.
2. All of the threads in the process terminate their execution.
3. The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate.
4. The states of all threads of the process become signaled, satisfying any threads that had been waiting for the threads to terminate.
5. The termination status of the process changes from STILL_ACTIVE to the exit value of the process. Terminating a process does not cause child processes to be terminated.
Terminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed.
halt;这样就直接结束程序的执行了。
或者 PostMessage(handle, WM_CLOSE, 0, 0);
halt从工程文件里也可以直接结束程序运行。而
Application.Terminate;
只是给系统发了个结束消息,但是不从当前过程退出,所以放了个exit。
Application.Terminate;只是给系统发了个结束消息,但是不从当前过程退出,
exit在这里是有意义的
为什么会执行呢? 你看看这几行代码吧! Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
在一个窗体创建的时候,还没有执行“Application.Run;”,即没有进入消息
循环。所以你的"Exit"是执行的。如果你在“Application.Run”,执行后再
测试看看! 我认为这段代码: messagedlg('数据库服务器名称不能为空,请重新配置系统',mtError,[mbOk],0);
Application.Terminate;
showmessage('ni SB') ;
exit;
在没有执行"Application.Run"之前是有效的。希望大家继续!
procedure TForm1.Button1Click(Sender: TObject);
begin
messagedlg('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk],0);
Application.Terminate;
showmessage('ni SB') ;
// exit;
sleep(1000000) ;
end;运行二:
procedure TForm1.Button1Click(Sender: TObject);
begin
messagedlg('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk],0);
Application.Terminate;
showmessage('ni SB') ;
exit;
sleep(1000000) ;
end;
明显的,第一次时间很长!老兄,还是动动手吧!
但是如下的代码就跟踪不到他执行后面的代码了,
老兄别说我不动手,其实我们的写法上不同,而
导致不同的结果!
procedure TForm1.Button1Click(Sender: TObject);
begin
messagedlg('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk],0);
Application.Terminate;
ShowMessage('OK');
exit;
end;