小弟刚刚在看关于dll的书,有一点疑惑请教一下
我创建一个dll的框架dll wizard
怎么保存的时候是dpr后缀名的,是不是应该是.dll后缀名啊在dll的exports中声名的函数是不是要由另一个.pas文件来实现啊(是不是也可以在dll中直接实现啊)如果是静态调用,是不是还要一个接口单元来声明什么external东西啊再问一下它们之间的包含关系是什么样的?
library Project1;//dll单元?{ 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
  SysUtils,
  Classes,
  mydll in 'mydll.pas'
  {$R *.res}
exports
  area,volume;
begin
end.unit mydll;//实现部分??interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;
function area(r:integer):integer;stdcall;export;
function volume(r:integer):integer;stdcall;export;implementation
 function area(r:integer):integer;stdcall
begin
 showmessage('求一个的面积');
 result:=r*2;
 end;
function volume(r:integer):integer;stdcall;
begin
  result:=r*3;
  showmessage('求一个圆的体积');
  end;
end.
unit jiekou;//借口单元???interface
function area(r:integer):integer;stdcall;
function volume(r:integer):integer;stdcall;
implementation
function area;external 'mydll1.dll' name 'area';
function volume;external 'mydll1.dll' name 'volume';
end.请问以下我概念是不是有问题啊????

解决方案 »

  1.   

    dpr=Delphi Project 没有错阿?你编译后才使dll文件
    exports可以和代码在同一个文件中,没有必要单独放在另外一个文件里如果你用静态调用的时候说什么找不到入口点,那么你用用VS自带的 Depends Walker来看看导出函数借口吧。
      

  2.   

    1.楼主是不是这个意思 'mydll1.dll' ==> 'Project1.dll'2.实现在哪里都可以,只要Project1包含了它,当然如果有函数重名的,自己要处理一下uses顺序。3.你的代码就是静态链接的。4.后面的同志就不要再补充啦
      

  3.   

    我的意思是是哪个文件是被保存为.dll的(关键),是project1还是mydll,一开始的project1的文件我保存的时候,其默认为.dpr
    而mydll是.pas的,我就有点不明白了,请教alphax,能不能把我的那个程序写的更清楚点(步骤,先是什么,后是什么?)
    我现在是写了,可是怎么也调试不通过,书也看了,可是讲得不详细,还望赐教,先谢了呵呵!!
      

  4.   

    你的dll是build以后自动生成的,不需要保存
    如果你的dll文件的名称和liarary的名字相同在主程序中
    function area;external 'mydll1.dll' name 'area';
    function volume;external 'mydll1.dll' name 'volume';
    implementation
      

  5.   

    library Project1;//
    如果你主程序中用mydlll.dll
    这里改为
    library  mydlll;
      

  6.   

    function area;external 'mydll1.dll' name 'area';
                               /\
                               |
                     这里要放DLL的文件名,而不是实现的单元名
    DLL Project的名称就是DLL的文件名,像你的情况,上面那个mydll1.dll应该用Project1.dll
    来代替。还有就是如果你有一个Project2.exe要静态连接这个Project1.DLL,那么Project1.DLL应该在Project2.exe的搜索路径上
      

  7.   

    只要你把Project1编译一下就可以了,自己就回生成一个dll
    我以前也遇到这样的 问题,后来发先,只要编译一下就可以,
      

  8.   

    在请问一下,在project中只有函数的声名,而在另一个unit中来实现dll中的函数是不是可以啊
    或者就在dll中实现?当你编译后就会自动生成dll文件?那么这个dll是不是就依赖那个实现的unit文件了。
      

  9.   

    >>在project中只有函数的声名,而在另一个unit中来实现dll中的函数是不是可以啊,
    试一下吧>>那么这个dll是不是就依赖那个实现的unit文件了
    实现的unit会被连接到dll的,也就是dll已经包含这个unit了