delphi 运行后闪退

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了delphi 运行后闪退相关的知识,希望对你有一定的参考价值。

我的delphi编完一段程序之后按F9可以运行,但是关掉并保存Delphi之后再打开Delphi然后打开之前那个编辑的程序按F9就直接闪退了。

程序如下:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
private
Private declarations
public
Public declarations
end;

var
Form1: TForm1;
i1,i2,i3: integer;

implementation

$R *.dfm

procedure TForm1.Button1Click(Sender: TObject);
begin
i1:=StrToInt(Edit1.Text);
i2:=StrToInt(Edit2.Text);
i3:=i1+i2;
showmessage(inttostr(i3));
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Not(key in ['0'..'9',#8]) then
key := #0;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if Not(key in ['0'..'9',#8]) then
key := #0;
end;

end.

看都不用仔细看就知道不是代码问题,这些代码有没导致闪退的可能。
从别的地方找原因吧

1 也许文件遭其他软件破坏
测试办法:复制代码到别的电脑上试试
2 delphi有问题, 可以重新安装试试
3 别的软件冲突导致 你可以关闭一些软件试试
4 window问题追问

哦,我知道了
我想再问下delphi中Save as 和 Save Project as有何区别

追答

save as 是单元文件另外保存
Save Project as 是工程另外保存

另外保存的意思: 就是比如说 aaa.pas 你save 就是继续保存到aaa.pas 而save as 会弹出个对话框 可以保存为bbb.pas

参考技术A 代码没问题,你的程序我也试了保存后再打开运行,也没问题

Anaconda-Navigator启动后闪退的解决方案(图文详解)

第一步:使用管理员运行:conda prompt

 

 第二步:执行命令 conda update anaconda-navigator

(C:\\Anaconda3) C:\\Users\\lenovo> conda update anaconda-navigator
Fetching package metadata .........
Solving package specifications: ..........

Package plan for installation in environment C:\\Anaconda3:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    vc-14                      |                0          703 B
    chardet-3.0.4              |           py35_0         202 KB
    qtpy-1.3.1                 |           py35_0          41 KB
    requests-2.14.2            |           py35_0         705 KB
    anaconda-client-1.6.3      |           py35_0         184 KB
    anaconda-project-0.6.0     |           py35_0         223 KB
    pyopenssl-16.2.0           |           py35_0          70 KB
    anaconda-navigator-1.6.4   |           py35_0         3.9 MB
    conda-4.3.30               |   py35hec795fb_0         541 KB
    ------------------------------------------------------------
                                           Total:         5.8 MB

The following NEW packages will be INSTALLED:

    anaconda-project:   0.6.0-py35_0
    chardet:            3.0.4-py35_0
    conda-env:          2.6.0-0
    vc:                 14-0

The following packages will be UPDATED:

    anaconda-client:    1.5.1-py35_0  --> 1.6.3-py35_0
    anaconda-navigator: 1.3.1-py35_0  --> 1.6.4-py35_0
    conda:              4.2.9-py35_0  --> 4.3.30-py35hec795fb_0
    pyopenssl:          16.0.0-py35_0 --> 16.2.0-py35_0
    qtpy:               1.1.2-py35_0  --> 1.3.1-py35_0
    requests:           2.11.1-py35_0 --> 2.14.2-py35_0

Proceed ([y]/n)? y

 

Fetching packages ...
vc-14-0.tar.bz 100% |###############################| Time: 0:00:00 350.65 kB/s
chardet-3.0.4- 100% |###############################| Time: 0:00:00 275.41 kB/s
qtpy-1.3.1-py3 100% |###############################| Time: 0:00:00 103.41 kB/s
requests-2.14. 100% |###############################| Time: 0:00:01 563.00 kB/s
anaconda-clien 100% |###############################| Time: 0:00:00 257.49 kB/s
anaconda-proje 100% |###############################| Time: 0:00:00 246.00 kB/s
pyopenssl-16.2 100% |###############################| Time: 0:00:00 175.56 kB/s
anaconda-navig 100% |###############################| Time: 0:00:07 510.25 kB/s
conda-4.3.30-p 100% |###############################| Time: 0:00:01 459.78 kB/s
Extracting packages ...
[ COMPLETE ]|##################################################| 100%
Unlinking packages ...
INFO menuinst_win32:__init__(182): Menu: name: 'Anaconda${PY_VER} ${PLATFORM}', prefix: 'C:\\Anaconda3', env_name: 'None', mode: 'None', used_mode: 'user'
[ COMPLETE ]|##################################################| 100%
Linking packages ...
INFO menuinst_win32:__init__(182): Menu: name: 'Anaconda${PY_VER} ${PLATFORM}', prefix: 'C:\\Anaconda3', env_name: 'None', mode: 'None', used_mode: 'user'
[ COMPLETE ]|##################################################| 100%

 

(C:\\Anaconda3) C:\\Users\\lenovo>

   第三步:执行anaconda-navigator --reset

(C:\\Anaconda3) C:\\Users\\lenovo>anaconda-navigator --reset

Anaconda Navigator configuration reset...


Anaconda Navigator configuration reset successful!


(C:\\Anaconda3) C:\\Users\\lenovo>

第四步:执行conda update anaconda-client

(C:\\Anaconda3) C:\\Users\\lenovo>conda update anaconda-client
Fetching package metadata .............
Solving package specifications: .

Package plan for installation in environment C:\\Anaconda3:

The following packages will be UPDATED:

    anaconda-client: 1.6.3-py35_0          --> 1.6.6-py35h690133a_0
    conda:           4.3.30-py35hec795fb_0 --> 4.3.31-py35_0
    conda-env:       2.6.0-0               --> 2.6.0-h36134e3_1

Proceed ([y]/n)? y

conda-env-2.6. 100% |###############################| Time: 0:00:00 316.26 kB/s
anaconda-clien 100% |###############################| Time: 0:00:00 251.02 kB/s
conda-4.3.31-p 100% |###############################| Time: 0:00:01 473.96 kB/s

(C:\\Anaconda3) C:\\Users\\lenovo>

第五步:执行conda update -f anaconda-client

 

(C:\\Anaconda3) C:\\Users\\lenovo>conda update -f anaconda-client
Fetching package metadata .............
Solving package specifications: .

Package plan for installation in environment C:\\Anaconda3:

The following NEW packages will be INSTALLED:

    anaconda-client: 1.6.6-py35h690133a_0

Proceed ([y]/n)? y


(C:\\Anaconda3) C:\\Users\\lenovo>


以上是关于delphi 运行后闪退的主要内容,如果未能解决你的问题,请参考以下文章

apk打包后闪退怎么办

myeclipse 2017 crack.bat运行后闪退

C语言程序函数调用闪退

c语言编程做出程序后闪退是怎么回事?求大神 本人菜鸟!

为啥C语言程序运行时打开后自动闪退??

C语言程序闪退!求解!在线等!