我做smtp邮件发送的动态连接库,调用时关闭窗体时报错。不知怎么回事??(200分)

  • 主题发起人 主题发起人 fsy
  • 开始时间 开始时间
F

fsy

Unregistered / Unconfirmed
GUEST, unregistred user!
我的dll:
library s2;

uses
sharemem,
forms,
nmsmtp,
SysUtils,
Classes;

var
smtp:Tnmsmtp;
procedure send1(host2,user2,from2,name2,to2,subject2,cc2,aname2,text2:pchar);
stdcall;
begin
try
smtp:=Tnmsmtp.Create(Application);
smtp.host:=host2;
smtp.UserID:=user2;
smtp.Connect ;
smtp.PostMessage.FromAddress:=from2;
smtp.PostMessage.FromName:=name2;
smtp.PostMessage.ToAddress.Text:=to2;
smtp.PostMessage.Subject:=subject2;
smtp.PostMessage.ToCarbonCopy.Text:=cc2;
smtp.PostMessage.Attachments.text:=aname2;
smtp.PostMessage.Body.Text :=text2;
smtp.SendMail ;
finally

smtp.free;
end;
end;
exports
send1;


begin
end.
调用dll:
unit smtp1;

interface

uses
sharemem,Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Psock, NMsmtp, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
ComboBox1: TComboBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Button2: TButton;
OpenDialog1: TOpenDialog;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
procedure send1(host2,user2,from2,name2,to2,subject2,cc2,aname2,text2:pchar) ;
external's2.dll';
implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
host2,user2,from2,name2,to2,subject2,cc2,aname2,text2:pchar;
begin
host2:=pchar(edit1.Text) ;
user2:=pchar(edit2.text);
from2:=pchar(edit3.text);
name2:=pchar(edit4.Text) ;
to2:=pchar(edit5.Text) ;
subject2:=pchar(edit6.text);
cc2:=pchar(edit7.text);
aname2:=pchar(combobox1.Items.Text );
text2:=pchar(memo1.Lines.Text );
send1(host2,user2,from2,name2,to2,subject2,cc2,aname2,text2);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if opendialog1.Execute then
combobox1.items.Add(opendialog1.filename);
end;

end.
 
procedure send1(host2,user2,from2,name2,to2,subject2,cc2,aname2,text2:pchar) ;
external's2.dll';
改为
procedure send1(host2,user2,from2,name2,to2,subject2,cc2,aname2,text2:pchar) ;
stdcall;external's2.dll';
 
接受答案了.
 
后退
顶部