标题:我用CB4改写了一个DELPHI写的DLL但是。。。(50分)

  • 主题发起人 主题发起人 六窍通
  • 开始时间 开始时间

六窍通

Unregistered / Unconfirmed
GUEST, unregistred user!
详细内容:<br>源码太长,故简化如下。<br><br>#include &lt;vcl.h&gt;<br>#pragma hdrstop<br>extern "C" __declspec(dllexport) double changeValue(double);<br>int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)<br>{ &nbsp;return 1;<br>}<br><br>double changeValue(double Value)<br>{ &nbsp;return Value * 100;<br>}<br><br>/*---------------------------------------------------------------<br>Exports from MyDll.dll<br>&nbsp; 4 exported name(s), 4 export addresse(s). &nbsp;Ordinal base is 1.<br>&nbsp; Sorted by Name:<br>&nbsp; &nbsp; RVA &nbsp; &nbsp; &nbsp;Ord. Hint Name<br>&nbsp; &nbsp; -------- ---- ---- ----<br>&nbsp; &nbsp; 0000213A &nbsp; &nbsp;1 0000 ___CPPdebugHook<br>&nbsp; &nbsp; 00002388 &nbsp; &nbsp;2 0001 ___dll_argc<br>&nbsp; &nbsp; 0000238C &nbsp; &nbsp;3 0002 ___dll_argv<br>&nbsp; &nbsp; 00001418 &nbsp; &nbsp;4 0003 _changeValue<br>-----------------------------------------------------------------*/ &nbsp; <br>1. ORD 1,2,3如何屏蔽掉<br>2. changeValue 为何变成 _changeValue<br>3. 如果不用VCL,INCLUDE应如何写,我将 #include &lt;vcl.h&gt; 改为#include &lt;windows.h&gt;<br>&nbsp; 出现连接错误。<br>4.这段话是什么意思?<br>//---------------------------------------------------------------<br>// &nbsp; Important note about DLL memory management when your DLL uses the<br>// &nbsp; static version of the RunTime Library:<br>//<br>// &nbsp; If your DLL exports any functions that pass String objects (or structs/<br>// &nbsp; classes containing nested Strings) as parameter or function results,<br>// &nbsp; you will need to add the library MEMMGR.LIB to both the DLL project and<br>// &nbsp; any other projects that use the DLL. &nbsp;You will also need to use MEMMGR.LIB<br>// &nbsp; if any other projects which use the DLL will be perfomring new or delete<br>// &nbsp; operations on any non-TObject-derived classes which are exported from the<br>// &nbsp; DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling<br>// &nbsp; EXE's to use the BORLNDMM.DLL as their memory manager. &nbsp;In these cases,<br>// &nbsp; the file BORLNDMM.DLL should be deployed along with your DLL.<br>//<br>// &nbsp; To avoid using BORLNDMM.DLL, pass string information using "char *" or<br>// &nbsp; ShortString parameters.<br>//<br>// &nbsp; If your DLL uses the dynamic version of the RTL, you do not need to<br>// &nbsp; explicitly add MEMMGR.LIB as this will be done implicitly for you<br>//---------------------------------------------------------------------------<br>
 
2. c调用规则, 函数名前自动加"_", 改成PASCAL规则就成了<br>4. 就是说dll参数或者返回值如果是string型, 必须加载MEMMGR.LIB(共享内存管理). 建议<br>使用用PChar或者指针传递字串变量.
 
Another_eYes:<br>变成PASCAL规则是这样写吗?<br>double __pascal _export &nbsp;changeValue(double);<br>double __pascal changeValue(double Value)<br>{ &nbsp;return Value * 100;<br>}<br><br>这样写后,<br>用TDUMP看变成这样:<br><br>000013F8 &nbsp; &nbsp;1 0000 changevalue(double)<br><br>另外,我根本不用VCL,所以将#include &lt;vcl.h&gt; &nbsp;--&gt; #include &lt;windows.h&gt;<br>结果出现以下LINK ERROR:<br>[Linker Error] Unresolved external '__InitVCL' referenced from D:/PROGRAM FILES/BORLAND/CBUILDER4/LIB/CP32MT.LIB|crtlvcl.<br>[Linker Error] Unresolved external '__ExitVCL' referenced from D:/PROGRAM FILES/BORLAND/CBUILDER4/LIB/CP32MT.LIB|crtlvcl.<br>如何解决?<br><br>
 
C BUILDER实在玩不转,<br>将函数定义改为<br>extern "C" double _export _stdcall changeValue(double);<br>该死的changeValue终于被正常的倒出了。这样我的DELPHI主程序<br>就不用再改了。<br><br>但是倒出表中 __CPPdebugHook 是什么东西。<br>不加VCL支持又如何处理呢?<br>还请再次援手。<br>
 
New-&gt;consolo App -&gt; Dll 可以去掉VCL支持。<br>但是,但是倒出表中 __CPPdebugHook 是什么东西。<br>
 
我建议用Visual C++
 
附加功能 &nbsp; 将问题提前 &nbsp; &nbsp;
 
六窍通:如果还想接着讨论请定期提前自己的帖子,如果不想继续讨论请结束帖子。<br>
 
后退
顶部