delphi 调用dll,添加sharemem的位置。

如题

delphi 调用外部的dll,需要在项目的dpr文件中uses第一个添加sharemem,而不是窗体form的pas文件中添加,否则程序关闭后无法正常结束进程。

program Project1;

uses
  ShareMem,Vcl.Forms,
  Unit1 in 'Unit1.pas' {Form1};

另外在form中申明dll的函数/过程时,函数名必须和dll中的保持一致,但是形参的名称可以不同:

var
    Form1: TForm1;

implementation

{$R *.dfm}
function Test1(x, y: integer): integer; external 'dll1';
function TestStr(x,yx:string):string;external 'dll1';

例如TestStr函数申明大小写必须一致,否则显示无法定位这个函数。

形参是x,xy,dll中是x,y

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Delphi 中少见的第三方内存管理器,QStrings 的作者 Andrew Driazgov 发布 QMemory is a new memory manager. You can use it as a replacement of the default system memory manager. To do this simply add QMemory unit in your project (as the first unit listed in the project file). Don‘t forget to call the QMemDecommitOverstock function when your application is idle. This subroutine decommits the unused memory blocks (it‘s only way for program to return the memory to the operation system). All allocated memory blocks are 32 byte aligned. The minimum size of the block is 32 bytes. As it is necessary to store some information with each block a dword is attached to the front of each block at -4 the aligned address. Thus, memory request for up to 28 bytes allocates a 32-bytes block, request for 29 to 60 bytes allocates a 64-bytes block, etc (as power of 2). This idea was adopted from HPMM project of Robert Lee (rhlee@optimalcode.com). The memory is committed and decommitted in 64K blocks. The maximum amount of the memory is specified when QMemInstall function is called (from the initialization section of the unit). You can‘t change this value later. If some parts of your program implemented as DLLs you have to use ShareQmm instead of QMemory unit. ShareQmm must be the first unit in your library‘s USES clause AND your project‘s (select Project-View Source) USES clause if some parts of your program have done as separate DLLs (especially if they export any procedures or functions that pass strings as parameters or function results). ShareQmm is the interface unit to the QMM.DLL shared memory manager, which must be deployed along with your DLL. You can‘t combine using of the standard ShareMem and custom ShareQmm memory managers in the same program project (including EXE-file with all DLLs). You can use either ShareMem or ShareQmm, but not both together. ShareQmm memory manager works at the same speed as a ShareMem memory manager with the blocks up to 4096 bytes and much more faster with the larger blocks.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值