Delphi疑难问题整理!!!

一.Dll调用时报错,例如:



  TGetResPrice = function(var AName: string; AFileName: string): TResourceRecArray; stdcall;

var

  LFunction: TGetResPrice;

调用:

      @LFunction := GetProcAddress(LDllHandle, ResPriceLoad_FuncName);
      if Assigned(LFunction) then

        LResc := LFunction(AName, AFileName);

dll实现:

function GetResPriceInfo(var AName: string; AFileName: string): TResourceRecArray; stdcall;

begin

。。。。。

end;

有可能是参数缺少或不一致,两者必须一致!

二.delphi dll释放报错 FreeLibrary报错

FreeLibrary(LDllHandle);

1.有可能是调用和DLL的两者调用FastMM不一致,一个引用了,另外一个没有引用;

uses
  FastMM4,
  ExceptionLog,
  SysUtils,
  Classes,
  TableTypes,
  CoDialogs,

  PriceLoad in '..SourcePriceLoad.pas';

2.另外一个可能就是两者引用包不一样,Component--Install Packages---勾选Build with runtime packages;

3.另外参数如果是字符串,要主程序和dll都要引用sharemem,在项目文件开头处引用;

4.如果是调用了Com组件,需要
开始处:
  CoInitialize(nil);
结尾处:
  CoUninitialize;

三.TAppBuilder.CheckDog 提示注册类已经存在:DPR文件引用包的问题

例如:A class named TcxRect already exists

在EXE+DLL架构中,多个使用DEV控件的DLL中出现“A class named TcxRect already exists”错误。

把cxLibraryVCLD7.bpl拷到运行目录下,并且在工程的options中,把cxLibraryVCLD7.bpl加入到runtime packages中,可解决“A class named TcxRect already exists”错误。

类似的错误,一般都是缺少运行时包所致,仔细排查都能解决。

Qd8.exe 加载modArchRptData.dll,在QD8.exe---Component--Install Packages---Build with runtime packages --- 后面添加cxLibraryVCLD7;

四、[Error] Packages 'DTree70' and 'dxEditorsD7' both contain unit ***

项目引用包问题,重复引用了;找到菜单---components--Install Packeages 更改为正确的值:

VCL;RTL;DBRTL;VCLDB;Common;FIB70;TB2K70;TBX70;Berg70;DTree70;IoData;dac70

.Could not find interface IAppServer in type library

遇到情况:Delphi7---File--new Other---Multitier--Remote data Module

解决方法:没有注册Midas.dll,找到DELPHI7安装目录下的dll,在运行窗口输入:

regsvr32 "C:Program Files (x86)Delphi7Binmidas.dll"

原文地址:https://www.cnblogs.com/xtfnpgy/p/9285357.html