X
xhbaiyun
Unregistered / Unconfirmed
GUEST, unregistred user!
我有一個DLL文件,里面就只有一個函數,
但是在調用此函數時,總是出現, “Invaild Pointer operation" 無效的指針操作這樣的錯誤。 現整個DLL代碼如下。請大家幫我看看!
library phosys;
{ 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. }
uses
ShareMem,SysUtils,forms,stdctrls,DB,ADODB,cxTL,Windows,
Classes;
{$R *.res}
Function CreatePhoTreeList(ADO:TADOConnection;TreeList:TcxTreeList;Auser:Boolean=false):integer;Stdcall;
var
ADO1:TADOConnection;
phgroup_qry:TADOQuery;
phname_qry:TADOQuery;
RootNode:TcxTreeListNode;
BMNode:TcxTreeListNode;
begin
TRY
ADO1:=ADO;
PhGroup_qry:=TadoQuery.Create(nil);
Phname_qry:=TADOQuery.Create(nil);
phGroup_qry.Connection:=ADO1;
PhName_qry.Connection:=ADO1;
PhGroup_qry.SQL.Add(Pchar('Select * from UseGroup'));
PhName_qry.SQL.Add(Pchar('Select * from SubPho'));
PhGroup_qry.Active:=true;
Phname_qry.Active:=true;
TreeList.Clear;
except
MessageBox(0,PChar('獲取分機號數據出錯,檢查數據的相關設置!'),Pchar('錯誤報告....'),MB_OK+MB_ICONERROR);
Result:=0;
exit;
end;
try
RootNOde:=TreeList.Add;
RootNOde.Texts[0]:=Pchar('xxxxxxxxxxxxx);
while not PhGroup_qry.Eof do
begin
BMNOde:=RootNOde.AddChild;
BMNode.ImageIndex :=0;
BMNode.Texts[0]:=phgroup_qry.Fields[1].AsString;
BMNode.Texts[1]:=phgroup_qry.Fields[0].AsString;
PhGroup_qry.Next;
end;
Result:=1;
PhGroup_qry.Free;
PhName_qry.Free;
Except
MessageBox(0,PansiChar('讀取部門數據環節出錯,請檢查!'),Pansichar('錯誤報告....'),MB_OK+MB_ICONERROR);
Result:=0;
end;
end;
exports
CreatePhoTreeList;
begin
end.
但是在調用此函數時,總是出現, “Invaild Pointer operation" 無效的指針操作這樣的錯誤。 現整個DLL代碼如下。請大家幫我看看!
library phosys;
{ 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. }
uses
ShareMem,SysUtils,forms,stdctrls,DB,ADODB,cxTL,Windows,
Classes;
{$R *.res}
Function CreatePhoTreeList(ADO:TADOConnection;TreeList:TcxTreeList;Auser:Boolean=false):integer;Stdcall;
var
ADO1:TADOConnection;
phgroup_qry:TADOQuery;
phname_qry:TADOQuery;
RootNode:TcxTreeListNode;
BMNode:TcxTreeListNode;
begin
TRY
ADO1:=ADO;
PhGroup_qry:=TadoQuery.Create(nil);
Phname_qry:=TADOQuery.Create(nil);
phGroup_qry.Connection:=ADO1;
PhName_qry.Connection:=ADO1;
PhGroup_qry.SQL.Add(Pchar('Select * from UseGroup'));
PhName_qry.SQL.Add(Pchar('Select * from SubPho'));
PhGroup_qry.Active:=true;
Phname_qry.Active:=true;
TreeList.Clear;
except
MessageBox(0,PChar('獲取分機號數據出錯,檢查數據的相關設置!'),Pchar('錯誤報告....'),MB_OK+MB_ICONERROR);
Result:=0;
exit;
end;
try
RootNOde:=TreeList.Add;
RootNOde.Texts[0]:=Pchar('xxxxxxxxxxxxx);
while not PhGroup_qry.Eof do
begin
BMNOde:=RootNOde.AddChild;
BMNode.ImageIndex :=0;
BMNode.Texts[0]:=phgroup_qry.Fields[1].AsString;
BMNode.Texts[1]:=phgroup_qry.Fields[0].AsString;
PhGroup_qry.Next;
end;
Result:=1;
PhGroup_qry.Free;
PhName_qry.Free;
Except
MessageBox(0,PansiChar('讀取部門數據環節出錯,請檢查!'),Pansichar('錯誤報告....'),MB_OK+MB_ICONERROR);
Result:=0;
end;
end;
exports
CreatePhoTreeList;
begin
end.