D
dirk
Unregistered / Unconfirmed
GUEST, unregistred user!
一个dll,其中一个函数接受一个TTreeView对象参数,然后为这个TTreeView添加若干
Node,然后在主程序中放置一个TTreeView:TreeView1,做为传给dll的参数,传递前
已经创建好了,也在主程序关闭时自动释放,但是,在TreeView1在clear时,就会出
下面这个错误:
Project Project1.exe raised exception class EInvalidPointer with message 'Invalid pointer operation'.Process stopped.Use Step or Run to continue.
如果不clear,那么这个错误在程序退出时也会出现。
我试过了,只要是在dll中添加的Node,不管是在dll中clear,还是在主程序中clear,
都会出这个错,而在主程序中添加Node,在主程序中clear,就不会出错,为什么?
请大家帮个忙,我急!
///////以下是dll Project:
library Project3;
uses
SysUtils,
Controls,
Dialogs,
windows,
Classes,
ComCtrls,
Db, ADODB,
ActiveX;
type
{$R *.RES}
//var
// TT:TTreeView;
procedure GetTV_Node(var TV:TTreeView);stdcall;
begin
TV.Items.Clear
// <--出错啊!!!!!
TV.Items.Add(nil,'Root');
TV.Items.Add(nil,'Node1');
TV.Items.Add(nil,'Node2');
// TT:=TV;
end;
exports
GetTV_Node,
begin
CoInitialize(nil);
// ADOC:=TADOConnection.Create(nil);
// ADOQ1:=TADOQuery.Create(nil);
// ADOC.LoginPrompt :=false;
// ADOC.ConnectionString :='DRIVER={SQL Server};server=10.10.10.10;database=mydb;uid=sa;pwd=';
// ADOC.Open
// ADOQ1.Connection :=ADOC;
// ADOQ1.SQL.Add('select * from tbuser');
// ADOQ1.Open
end.
///////以下是主程序 Project:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
Button5: TButton;
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure GetTV_Node(var TV:TTreeView);stdcall;External'project3.dll';
procedure TForm1.Button5Click(Sender: TObject);
begin
GetTV_Node(TreeView1);
end;
end.
Node,然后在主程序中放置一个TTreeView:TreeView1,做为传给dll的参数,传递前
已经创建好了,也在主程序关闭时自动释放,但是,在TreeView1在clear时,就会出
下面这个错误:
Project Project1.exe raised exception class EInvalidPointer with message 'Invalid pointer operation'.Process stopped.Use Step or Run to continue.
如果不clear,那么这个错误在程序退出时也会出现。
我试过了,只要是在dll中添加的Node,不管是在dll中clear,还是在主程序中clear,
都会出这个错,而在主程序中添加Node,在主程序中clear,就不会出错,为什么?
请大家帮个忙,我急!
///////以下是dll Project:
library Project3;
uses
SysUtils,
Controls,
Dialogs,
windows,
Classes,
ComCtrls,
Db, ADODB,
ActiveX;
type
{$R *.RES}
//var
// TT:TTreeView;
procedure GetTV_Node(var TV:TTreeView);stdcall;
begin
TV.Items.Clear
// <--出错啊!!!!!
TV.Items.Add(nil,'Root');
TV.Items.Add(nil,'Node1');
TV.Items.Add(nil,'Node2');
// TT:=TV;
end;
exports
GetTV_Node,
begin
CoInitialize(nil);
// ADOC:=TADOConnection.Create(nil);
// ADOQ1:=TADOQuery.Create(nil);
// ADOC.LoginPrompt :=false;
// ADOC.ConnectionString :='DRIVER={SQL Server};server=10.10.10.10;database=mydb;uid=sa;pwd=';
// ADOC.Open
// ADOQ1.Connection :=ADOC;
// ADOQ1.SQL.Add('select * from tbuser');
// ADOQ1.Open
end.
///////以下是主程序 Project:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
Button5: TButton;
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure GetTV_Node(var TV:TTreeView);stdcall;External'project3.dll';
procedure TForm1.Button5Click(Sender: TObject);
begin
GetTV_Node(TreeView1);
end;
end.