现想调用一DLL,但弄了N久调用不了,关于这个DLL手上只有一个用BCB调用的实例,下面列出其中的一个过程这是DLL的过程在BCB中的引用InitVCDSystem
EXTERN class   __stdcall VideoDetect
{
  public:
    bool InitVCDSystem();
}1.在DELPHI中静态引用:
function InitVCDSystem(): Boolean; stdcall  external 'VCD.dll';
调用时提示:
无法定位程序输入点InitVCDSystem于动太链接库VCD.DLL上
2.在DELPHI中动态引用:type
  TIntFunc= function(): Boolean; stdcall;
var
  Th:Thandle;
  Tf:TIntFunc;
  Tp:TFarProc;
  test: boolean;
begin
  Th:=LoadLibrary('VCDDll.dll'); {装载DLL}
  if Th>0 then
  try
    Tp:=GetProcAddress(Th,'InitVCDSystem');
    if Tp<>nil then
    begin
      Tf:=TIntFunc(Tp);
      test := Tf; 
    end
    else
      ShowMessage('InitVCDSystem函数没有找到');
  finally
    FreeLibrary(Th); {释放DLL}
  end
  else
    ShowMessage('VCDDll.dll没有找到');执行时Tp=nil3.后来通过一个查看一个DLL的工具查出InitVCDSystem的函数名为@VideoDetect@InitVCDSystem$qqsv,于是把
代码改为:
  Th:=LoadLibrary('VCDDll.dll'); {装载DLL}
  if Th>0 then
  try
    Tp:=GetProcAddress(Th,'@VideoDetect@InitVCDSystem$qqsv');//<---改了这里的函数名称
    if Tp<>nil then
    begin
      Tf:=TIntFunc(Tp);
      test := Tf; //<----执行到这里出错
    end
    else
      ShowMessage('InitVCDSystem函数没有找到');
  finally
    FreeLibrary(Th); {释放DLL}
  end
  else
    ShowMessage('VCDDll.dll没有找到');
错误提示如下: 
access violation at 0x00f4883;write of address 0x004499d8有个非常不明白的地方就是:在BCB中的引用名称是InitVCDSystem,为什么在DELPHI中用此名称返回的地址为空?难道是DLL本身的问题?各位指点一下吧,实在找不出原因了

解决方案 »

  1.   

    Tp:TFarProc;是个什么定义? 为什么要做这个强制转换?if Tp<>nil then
    begin
      Tf:=TIntFunc(Tp);
      test := Tf; //<----执行到这里出错
    end修改为Tp<> nil then
    test := tp();试试。另外能确认dll里面是@VideoDetect@InitVCDSystem$qqsv' 这个妖怪名字么? 用静态的方式再试试
      

  2.   

    晕啊,你的BCB用的是带类的DLL,最好的方法是用bcb重新封装成标准的DLL供delphi调用
    类的成员函数是8位指针(BCB中为__closure类型),你用普通的方法是不能调用的
      

  3.   

    你把那个dll发给我,我帮你调试!QQ:459834034