从主程序中传入dll的TClientDataSet指针,为什么会在dll没有返回Tform类型时可以操作,以但返回窗体显示后就不能操作此指针了,出显示地址错误。

  • 主题发起人 主题发起人 sjg23690428
  • 开始时间 开始时间
S

sjg23690428

Unregistered / Unconfirmed
GUEST, unregistred user!
从主程序中传入dll的TClientDataSet指针,为什么会在dll没有返回Tform类型时可以操作,以但返回窗体显示后就不能操作此指针了,出显示地址错误。 ( 积分: 200 )<br />谢谢,很急
 
谢谢,很急
 
TClientDataSet 是主程序的,把他传给dll 是吧,后面是啥意思?
地址错误,就是释放了或被清了。
看不太明白,看来写程序写的都有语言障碍了。直接贴代码。
 
library DPdbgirdset;

uses
ShareMem,
Windows,
ADODB,
DBClient,
Forms,
// Ucalssbox,
comobj,
activex,
SysUtils,
Classes,
Ucalssbox in 'Ucalssbox.pas',
UndbgridSet in 'UndbgridSet.pas',
UnitWriteLog in 'Unitwritelog.pas';

{$R *.res}
var
DllApp: Tapplication;


procedure ExitDll(Reason:integer);
begin
if Reason=DLL_PROCESS_DETACH then
begin
oleuninitialize;
CoUnInitialize;
application:=DllApp;
end;
end;

////////////////////主控台application//主控台screen////
function CreateFormDll(app: Tapplication; MainHandleTemp:THandle; operatorNo, operatorName:Pchar;
var ClientroleTemp: TClientDataSet; ADOSubTemp: TADOConnection):TForm; stdcall;
///工号////工号姓名///////////// 控台传来权限表/////////////////主控台传来连接//////////////
var
roleTemp: Pclintrole;
begin
application:= app;
MainHandle:= MainHandleTemp;
roleTemp:= @ClientroleTemp;
result:= TicketDeal(roleTemp,ADOSubTemp,operatorNo,operatorName);
end;
exports
CreateFormDll;

begin
OleInitialize(nil);
CoInitialize(nil);
Dllapp:=application;
Dllproc:=@exitdll;
end.

function TicketDeal(Clientrole: Pclintrole; ADOConnTemp: TADOConnection; ManagerNOTemp,ManagerNameTemp: Pchar):TForm;
var
appath: string;
operTemp: PoperList;
i:integer;
Listtemp: PoperList;
begin
ProleTable:= Clientrole;
AdoConn:= ADOConnTemp;
ManagerNO:= string(ManagerNOTemp);
application.CreateForm(TFndbgridSet,FndbgridSet);
FndbgridSet.DBGrid1.Columns.Add;
FndbgridSet.DBGrid1.Columns[0].FieldName:='chinese_name';
FndbgridSet.DBGrid1.Columns[0].Width:=100;
FndbgridSet.DBGrid1.Columns[0].Title.caption:='操作项目';
FndbgridSet.DBGrid1.Columns[0].Title.Alignment:= taCenter;
try
Clientoper:= TClientDataSet.Create(nil);
Clientoper.Data:= ProleTable^.Data;
except
on E:exception do
begin
Clientoper:=nil;
Clientoper.Free;
writelog(e.Message);
result:=nil;
exit;
end;
end;
FilterRoleTemp('item_type='+QuotedStr('dbgridset'),Clientoper);
FndbgridSet.DataSource1.DataSet:= Clientoper;
Expression:= Tlist.Create;
i:=0;
while not Clientoper.Eof do
begin
new(operTemp);
operTemp.chinaName:= Clientoper.fieldbyname('chinese_name').AsString;
operTemp.ChinaBds:='';
operTemp.EngleshBds:='';
operTemp.Plist:= nil;
Expression.Add(operTemp);
if i&amp;gt;0 then
begin
operTemp^.Plist:= Expression.Items[i-1];
end;
inc(i);
Clientoper.Next;
end;
Listboxclass:=TListboxclass.Create(ProleTable,'goods_kind','1');
Listboxclass.jszdBox:= @FndbgridSet.ListBox4;
Listboxclass.dataOperBox:= @FndbgridSet.ListBox1;
Listboxclass.operBox:= @FndbgridSet.ListBox3;
Listboxclass.funcBox:= @FndbgridSet.ListBox2;
Listboxclass.dataOperStr:= Clientoper.fieldbyname('english_name').AsString;
appath:= ExtractFilePath(application.ExeName)+'hcpos.ini';
Listboxclass.operPath:=appath;
Listboxclass.funcPath:=appath;

if FndbgridSet.dbgrid2.Columns.Count&amp;lt;&amp;gt;0 then FndbgridSet.dbgrid2.Columns.Clear;
with FndbgridSet.dbgrid2 do
begin
Columns.Add;
Columns[0].FieldName:='chinese_name';
Columns[0].Title.caption:= '操作项目';
Columns[0].Width:= 60;
Columns[0].Title.Alignment:= taCenter;
Columns.Add;
Columns[1].FieldName:='total';
Columns[1].Title.caption:= '合计选项';
Columns[1].Width:= 60;
Columns[1].Title.Alignment:= taCenter;
Columns[1].PickList.add('fvtnon');
Columns[1].PickList.add('fvtcount');
Columns[1].PickList.add('fvtstatictext');
Columns[1].PickList.add('fvtsum');
Columns[1].PickList.add('fvtAvg');
end;
if FndbgridSet.DataSource2.DataSet=nil then FndbgridSet.DataSource2.DataSet:= ProleTable^;
FndbgridSet.dbgrid2.DataSource:= FndbgridSet.DataSource2;
i:=0;
for i:= Expression.Count-1 downto 0 do
begin
Listtemp:= Expression.Items;
if Listtemp^.chinaName= Clientoper.fieldbyname('chinese_name').AsString then
begin
// excindex:=I;
FndbgridSet.memo1.Text:= Listtemp^.ChinaBds+Listtemp^.EngleshBds;
break;
end;
end;
dj:=0;
excindex:=0;
result:= FndbgridSet;



在主程序中操作ProleTable 进出地址错误

 
我所说的是,在dll中通过指针能不能操作,主程序TClientDataSet
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
694
import
I
I
回复
0
查看
831
import
I
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部