Dll文件出錯了!!! "Invalid pointer operation"(100分)

  • 主题发起人 主题发起人 xhbaiyun
  • 开始时间 开始时间
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.
 
寻觅Delphi高手
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3576949
 
可能是调用部分的错误吧 如果调用的时候函数指针有问题也会出这个错误
 
1。主程序使用了ShareMM单元了?而且是第一个引用。
2.楼上所说
 
不要用Sharemm,把String类型改成用PChar类型
 
跟踪看是哪哪个语句出错了啊。
 

Similar threads

I
回复
0
查看
638
import
I
I
回复
0
查看
750
import
I
I
回复
0
查看
771
import
I
I
回复
0
查看
2K
import
I
后退
顶部