大虾~~~~~~~~~帮忙!!!!(20分)

  • 主题发起人 主题发起人 huangjihua
  • 开始时间 开始时间
H

huangjihua

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure MakeTree(Query: TADOQuery; TableName: string; TreeView: TTreeView);stdcall;export;
begin
TreeView.Items.BeginUpdate;
list.Clear;
TreeView.items.clear;
if query.Active then query.Close;
Query.SQL.Text := 'SELECT * FROM ' + TableName + ' ORDER BY B, ID';
Query.Open;
query.DisableControls;
TreeView.Items.Clear;
list.Clear;
List.Sorted := True;
query.First;
while not Query.Eof do
begin
addtreenode(Query, TreeView);
Query.Next;
end;
TreeView.Items.EndUpdate;
query.EnableControls;
if treeview.Items.Count < 1 then exit;
treeview.Select(treeview.Items.Item[0]);
treeview.SetFocus;
end;
exports
MakeTree;
begin
end;
现在有一个问题:我在Dll工程文件里写了这个过程,但是我在单元文件里调用的时候却有错误:Access violation at address 003CA603 in Module 'TreeControls.dll'.Read Of address 00000000.出现了这样的错误??不知道怎么解决,我在单元文件是这样调用的:
procedure MakeTree(Query: TADOQuery; TableName: string; TreeView: TTreeView);
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
MakeTree(ADOQuery,'dir',TreeView1);
end;
不知道我这样调用有没有错。那如果是动态调用那如何写呢??请大虾们!帮忙,谢谢了~~~~~~~~~~~
 
不好意思:写漏了,Dll的名字。
procedure MakeTree(Query: TADOQuery; TableName: string; TreeView: TTreeView);
stdcall;external 'treecontrols.dll';
 
uses ShareMem;
Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters.

你的dll封装了带String的参数。。。一般建议用PChar。。。
 
不是这个问题啊!我用pchar也是这样的错误!?????况且我用string的时候我也在uses 里 放入了sharemem。
 
ShareMem是否放在首位,是否Build?
如果还不行,你先把dll里写的函数,copy出来,
建个exe先测试一下,看看有什么没释放的。。。
完全没问题了,再封装成dll调用。。。
 
别急。。。轻松点。。。一定能解决的。。。无非就这几个问题。。。呵呵
 
sharemem 是放在首位啊!~我也Build了!!可是还是那个问题啊???不知道怎么解决??
 
建一个应用程序,把你写的函数测试一下,看看什么没释放咯。。。
无非都是这个问题。。。要不你把你的代码都发给我,
我来帮你找bug,呵呵,如果你不想发的话,就只能自己建个工程去测了。。。
terryapp@163.com
 
后退
顶部