I
insert
Unregistered / Unconfirmed
GUEST, unregistred user!
我在调用sakemail的邮件接收程序的dll时,关闭窗体时报错。请各位高手指点。
怎样把pchar转换成string?
Tsakmsglist不知在哪释放??
是dll的问题还是调用的问题???
我的dll:
library p2;
uses
sharemem,
forms,
sakemail,
SysUtils,
Classes;
var
pop:Tsakpop;
list:Tsakmsglist;
procedure connect1(host1,user1,passwd1char;
var newmail1,mail1:integer);stdcall;
begin
try
pop:=Tsakpop.Create(Application);
list:=Tsakmsglist.Create(Application);
pop.Host:=host1;
pop.UserId:=user1;
pop.Passwd:=passwd1;
pop.Connect ;
pop.Login ;
newmail1:=pop.Init ;
mail1:=pop.MsgsCount ;
pop.RetrieveAllMessages(list);
pop.Quit ;
finally
pop.free;
end;
end;
procedure show1(s:integer;var from1,subject1,date1,msgid1,text1,anamechar);
stdcall;
var
i:integer;
msg:Tsakmsg;
begin
msg:=list.Items;
from1:=pchar(msg.From);
subject1:=pchar(msg.Subject);
date1:=pchar(msg.Date);
msgid1:=pchar(msg.MessageId );
text1:=pchar(msg.Text.Text);
if msg.AttachedFiles.Count >0 then
begin
for i:=0 to msg.AttachedFiles.Count-1 do
aname:=pchar(msg.AttachedFiles.FileName );
end;
end;
procedure del1(s:integer); stdcall;
begin
list.Delete(s);
end;
exports
connect1,
show1,
del1;
begin
end.
调用dll:unit pop3u2;
interface
uses
sharemem,Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,sakemail;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ComboBox1: TComboBox;
ListBox1: TListBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
procedure connect1(host1,user1,passwd1char;
var newmail1,mail1:integer);stdcall;external'p2.dll';
procedure show1(s:integer;var from1,subject1,date1,msgid1,text1,anamechar);
stdcall;external'p2.dll';
procedure del1(s:integer); stdcall;external'p2.dll';
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
host1,user1,passwd1char;
mail1,newmail1:integer;
begin
host1:=pchar(edit1.Text) ;
user1:=pchar(edit2.Text) ;
passwd1:=pchar(edit3.Text) ;
connect1(host1,user1,passwd1,newmail1,mail1);
edit4.text:=inttostr(newmail1);
edit5.text:=inttostr(mail1);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
s:integer;
from1,subject1,date1,msgid1,text1,anamechar;
begin
s:=strtoint(edit6.text);
show1(s,from1,subject1,date1,msgid1,text1,aname);
edit7.text:=from1;
edit8.text:=subject1;
edit9.text:=date1;
edit10.text:=msgid1;
combobox1.Items.Clear ;
combobox1.Items.Add(aname);
//combobox1.Items.text:=aname;
listbox1.Items.Text:=text1;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
s:integer;
begin
s:=strtoint(edit6.text);
del1(s);
end;
end.
关闭窗体报错:
Project *.exe raised exception class EInvalidpointer with
message 'Invalid pointer operation'.Process stopped.Use Step
or Run to continue.
怎样把pchar转换成string?
Tsakmsglist不知在哪释放??
是dll的问题还是调用的问题???
我的dll:
library p2;
uses
sharemem,
forms,
sakemail,
SysUtils,
Classes;
var
pop:Tsakpop;
list:Tsakmsglist;
procedure connect1(host1,user1,passwd1char;
var newmail1,mail1:integer);stdcall;
begin
try
pop:=Tsakpop.Create(Application);
list:=Tsakmsglist.Create(Application);
pop.Host:=host1;
pop.UserId:=user1;
pop.Passwd:=passwd1;
pop.Connect ;
pop.Login ;
newmail1:=pop.Init ;
mail1:=pop.MsgsCount ;
pop.RetrieveAllMessages(list);
pop.Quit ;
finally
pop.free;
end;
end;
procedure show1(s:integer;var from1,subject1,date1,msgid1,text1,anamechar);
stdcall;
var
i:integer;
msg:Tsakmsg;
begin
msg:=list.Items
from1:=pchar(msg.From);
subject1:=pchar(msg.Subject);
date1:=pchar(msg.Date);
msgid1:=pchar(msg.MessageId );
text1:=pchar(msg.Text.Text);
if msg.AttachedFiles.Count >0 then
begin
for i:=0 to msg.AttachedFiles.Count-1 do
aname:=pchar(msg.AttachedFiles.FileName );
end;
end;
procedure del1(s:integer); stdcall;
begin
list.Delete(s);
end;
exports
connect1,
show1,
del1;
begin
end.
调用dll:unit pop3u2;
interface
uses
sharemem,Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,sakemail;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ComboBox1: TComboBox;
ListBox1: TListBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
procedure connect1(host1,user1,passwd1char;
var newmail1,mail1:integer);stdcall;external'p2.dll';
procedure show1(s:integer;var from1,subject1,date1,msgid1,text1,anamechar);
stdcall;external'p2.dll';
procedure del1(s:integer); stdcall;external'p2.dll';
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
host1,user1,passwd1char;
mail1,newmail1:integer;
begin
host1:=pchar(edit1.Text) ;
user1:=pchar(edit2.Text) ;
passwd1:=pchar(edit3.Text) ;
connect1(host1,user1,passwd1,newmail1,mail1);
edit4.text:=inttostr(newmail1);
edit5.text:=inttostr(mail1);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
s:integer;
from1,subject1,date1,msgid1,text1,anamechar;
begin
s:=strtoint(edit6.text);
show1(s,from1,subject1,date1,msgid1,text1,aname);
edit7.text:=from1;
edit8.text:=subject1;
edit9.text:=date1;
edit10.text:=msgid1;
combobox1.Items.Clear ;
combobox1.Items.Add(aname);
//combobox1.Items.text:=aname;
listbox1.Items.Text:=text1;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
s:integer;
begin
s:=strtoint(edit6.text);
del1(s);
end;
end.
关闭窗体报错:
Project *.exe raised exception class EInvalidpointer with
message 'Invalid pointer operation'.Process stopped.Use Step
or Run to continue.