N newfood123 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-06 #1 我想用DLL封装一个选择窗体,用户双击后就返加一个字符串到我数据库窗体的EDIT上,要求在我的数据库窗体上传一个adoquery给DLL窗体,DLL窗体中相应的查询信息也用数据库应用程序中的adoquery,我试过,用adoquery传递老是出错,有没有高手能帮我解决一下??
我想用DLL封装一个选择窗体,用户双击后就返加一个字符串到我数据库窗体的EDIT上,要求在我的数据库窗体上传一个adoquery给DLL窗体,DLL窗体中相应的查询信息也用数据库应用程序中的adoquery,我试过,用adoquery传递老是出错,有没有高手能帮我解决一下??
H hongfeng0727 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-06 #2 报什么错?<br>可以在dll中定义tadoquery,不作为参数传给dll.
C ch2001023 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-06 #3 DLL返回字符串的,必须得转换,否则会直接报错的,,<br>uses delphiMM
N newfood123 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-07 #4 function selectform(fieldname,tablename:string;adoc:tADOConnection):string;stdcall;<br> var<br> selectfm:Tselectfm;<br>begin<br>selectfm:=Tselectfm.Create(Application);<br>selectfm.query.Connection:=adoc;<br>selectfm.ds.DataSet:=selectfm.query;<br>selectfm.tablename:=tablename;<br>selectfm.fieldname:=fieldname;<br>try<br> selectfm.ShowModal;<br>result:=selectfm.oth;<br>finally<br> FreeAndnil(selectfm);<br>end;<br>end;<br><br><br>以上是我在DLL中定义的函数,这个能传递吗??怎么传递都是出错呢??
function selectform(fieldname,tablename:string;adoc:tADOConnection):string;stdcall;<br> var<br> selectfm:Tselectfm;<br>begin<br>selectfm:=Tselectfm.Create(Application);<br>selectfm.query.Connection:=adoc;<br>selectfm.ds.DataSet:=selectfm.query;<br>selectfm.tablename:=tablename;<br>selectfm.fieldname:=fieldname;<br>try<br> selectfm.ShowModal;<br>result:=selectfm.oth;<br>finally<br> FreeAndnil(selectfm);<br>end;<br>end;<br><br><br>以上是我在DLL中定义的函数,这个能传递吗??怎么传递都是出错呢??
G godelphi2004 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-07 #5 为什么总是有人不看这样一段注释???<br><br>library Project1;<br><br>[green]{ Important note about DLL memory management: ShareMem must be the<br> first unit in your library's USES clause AND your project's (select<br> Project-View Source) USES clause if your DLL exports any procedures or<br> functions that pass strings as parameters or function results. This<br> applies to all strings passed to and from your DLL--even those that<br> are nested in records and classes. ShareMem is the interface unit to<br> the BORLNDMM.DLL shared memory manager, which must be deployed along<br> with your DLL. To avoid using BORLNDMM.DLL, pass string information<br> using PChar or ShortString parameters. }[/green]<br><br>uses<br> SysUtils,<br> Classes;<br><br>{$R *.res}<br><br>begin<br>end.
为什么总是有人不看这样一段注释???<br><br>library Project1;<br><br>[green]{ Important note about DLL memory management: ShareMem must be the<br> first unit in your library's USES clause AND your project's (select<br> Project-View Source) USES clause if your DLL exports any procedures or<br> functions that pass strings as parameters or function results. This<br> applies to all strings passed to and from your DLL--even those that<br> are nested in records and classes. ShareMem is the interface unit to<br> the BORLNDMM.DLL shared memory manager, which must be deployed along<br> with your DLL. To avoid using BORLNDMM.DLL, pass string information<br> using PChar or ShortString parameters. }[/green]<br><br>uses<br> SysUtils,<br> Classes;<br><br>{$R *.res}<br><br>begin<br>end.
T ThenLong Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-07 #7 dll给dephi用可以用string<br>但是要包含shareMem单元<br>如果要通用,比如给vc调用那么还是用PChar或CharArray传递
N newfood123 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-07 #8 各位大虾,有没有会的呢>>我该怎么做呢??
D delphfans Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-07 #9 作成 类com 接口直接传过去
L liyinwei Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-07 #10 1.调用者和被调用者的工程单元的 Use 都要第一个引用 ShareMem 单元。<br>2.要在 selectform 函数添加代码<br>begin<br> CoInitialize(nil);<br>......<br> CoUninitialize;<br>end;
1.调用者和被调用者的工程单元的 Use 都要第一个引用 ShareMem 单元。<br>2.要在 selectform 函数添加代码<br>begin<br> CoInitialize(nil);<br>......<br> CoUninitialize;<br>end;
S sgxcn Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-07 #11 Delphi调用DLL窗体的演示源码<br>http://www.programbbs.com/code/105.htm
N newfood123 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-08 #12 做成COM类传递,这个我不会,用CoInitialize(nil);时不知道期定义,各位有没能什么好的例程,上面的函数经过我修改之后可以传递,但重复调用两次后就出错了,不知道怎么解决
A andrew57 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-08 #13 clientdataset,datasetprovider,传递variant行
N newfood123 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-08 #14 上面说的不太明白,我在家改了程式,基本上符合了我的要求,调用DLL也正常,关闭DLL也正常(我是采用静态调用),可问题又出来了,当关闭DLL时,会出现一个这样的错误"应用程序发生异常,未知的软件异常(0x0eedfade),位置为0x7c812a5b,单击确认后显示runtime error 217 at 004A2808,在DELPHI中调试时显示"invalid pointer operation"好像是这指针错误,有没有人能帮我解决这个问题,先谢谢了
上面说的不太明白,我在家改了程式,基本上符合了我的要求,调用DLL也正常,关闭DLL也正常(我是采用静态调用),可问题又出来了,当关闭DLL时,会出现一个这样的错误"应用程序发生异常,未知的软件异常(0x0eedfade),位置为0x7c812a5b,单击确认后显示runtime error 217 at 004A2808,在DELPHI中调试时显示"invalid pointer operation"好像是这指针错误,有没有人能帮我解决这个问题,先谢谢了
L liyinwei Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-08 #15 留下 EMail ,我发一个 Demo 给你吧。
D Delphiguanshui Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-08 #16 楼上的可以给我一分吗?谢谢,了,<br>gshksh032@163.com
N newfood123 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-10 #18 我的邮箱是newfood123@163.com,先谢谢了
N newfood123 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-10 #19 怎么没有高手来解决我的问题呀??小弟请你们啦
银 银雨辰 Unregistered / Unconfirmed GUEST, unregistred user! 2007-12-10 #20 用指针 PADOQ = ^TADOQuery;<br>Function CalSQL(ASQL: String; Const AADOQ: PADOQ = Nil): Integer;<br><br>Procedure BBBB;<br>Var<br> TempADOQ: TADOQuery;<br> SQLStr: String;<br> VNo: Integer;<br>Begin<br> TempADOQ := TADOQuery.Create(Nil);<br> SQLStr := 'SELECT aaa FROM CCC';<br> Try<br> If CalSQL(SQLStr, @TempADOQ) > 0 Then<br> Begin<br> TempADOQ.First;<br> While Not TempADOQ.Eof Do<br> Begin<br> VNo := TempADOQ.FieldByName('aaa').AsInteger;<br> TempADOQ.Next;<br> End;<br> End;<br> Finally<br> TempADOQ.Close;<br> FreeAndNil(TempADOQ);<br> End;<br>End;
用指针 PADOQ = ^TADOQuery;<br>Function CalSQL(ASQL: String; Const AADOQ: PADOQ = Nil): Integer;<br><br>Procedure BBBB;<br>Var<br> TempADOQ: TADOQuery;<br> SQLStr: String;<br> VNo: Integer;<br>Begin<br> TempADOQ := TADOQuery.Create(Nil);<br> SQLStr := 'SELECT aaa FROM CCC';<br> Try<br> If CalSQL(SQLStr, @TempADOQ) > 0 Then<br> Begin<br> TempADOQ.First;<br> While Not TempADOQ.Eof Do<br> Begin<br> VNo := TempADOQ.FieldByName('aaa').AsInteger;<br> TempADOQ.Next;<br> End;<br> End;<br> Finally<br> TempADOQ.Close;<br> FreeAndNil(TempADOQ);<br> End;<br>End;