使用DLL2LIB将VC的DLL还原成LIB后,在Delphi中可以使用,来扩充DLL的功能呢?

解决方案 »

  1.   

    VC的dll用delphi不能掉用吗??
      

  2.   

    VC的lib应该是dll函数的导入库,而不是静态库。没有在Delphi中使用的必要
      

  3.   

    哦,是这样啊?
    那我要扩充一个DLL的功能,Delphi下应该如何实现。
      

  4.   

    function 函数名(参数列表):返回值类型;调用约定;external 'DLL文件名' name '入口点';
      

  5.   

    也可以用loadlibrary动态调用dll
      

  6.   

    Delphi可以直接连接VC++的DLL,做法如下:
     1、在VC++的.cpp文件中说明输出函数的名字、类型、调用方式、定义函数执行体:
        extern "C" __declspec(dllexport) void VCvoidfunction(......)
          {
             .......
    return;
          }    extern "C" __declspec(dllexport) DWORD VCdwordfunction(......)
          {
             .......
    return ....;
          } 2、在Delphi中说明,假定做一个单独的引入单元:
        
       1)说明函数类型:
       Type TVCvoidfunction=Function(......); Cdecl;  //函数类型
       Type TVCdwordfunction=Function(......); Cdecl; //函数类型   2)定义函数变量:
       Var VCvoidfunction:  TVCvoidfunction;
           VCdwordfunction: TVCdwordfunction; 3、在Delphi程序中首先动态连接DLL:   DLL_Handle:=LoadLibrary(PChar(DLLPath));
       DLL_Handle>0 Then                                 //若加载成功,
         Begin                                           //则依次定位函数
           Try
             @VCvoidfunction :=GetProcAddress(DLL_Handle,'VCvoidfunction');
             @VCdwordfunction:=GetProcAddress(DLL_Handle,'VCdwordfunction);
           Except
             FreeLibrary(DLL_Handle);
           End
         End
           
     4、在Delphi程序中调用VC的DLL中函数:
          
        直接使用函数名,按Delphi的要求使用。
        注意,VC参数中的&对应Delphi的Var。