社区
Delphi
帖子详情
请问怎样在DELPHI中调用BCB做的DLL
kmyangyl
2000-01-24 02:35:00
我用LOADLIBRARY和GETPROCADDRESS来做,当做LOADLIBRARY后返回码正常,但做了
我调用的函数后,返回的值不对。这个DLL我用BCB调很正常。
...全文
129
4
打赏
收藏
请问怎样在DELPHI中调用BCB做的DLL
我用LOADLIBRARY和GETPROCADDRESS来做,当做LOADLIBRARY后返回码正常,但做了 我调用的函数后,返回的值不对。这个DLL我用BCB调很正常。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
光明山人
2000-01-25
打赏
举报
回复
请问你在BCB DLL中做的函数的原型是怎样的?是否加了pascal调用限定?能否贴出?
一般在WIN中编输入函数时都用pascal调用方式,绝大多数的WIN API都是,因为pascal调用较快。
kxy
2000-01-24
打赏
举报
回复
我是指缺省情况.
kxy
2000-01-24
打赏
举报
回复
delphi中函数的声明后面加上cdecl,stdcall
参数压栈的顺序不同,c中从右向左,delphi,pascal中从左向右.
929
2000-01-24
打赏
举报
回复
C与PASCAL在调用函数时的参数处理方式不同,比如说,在DELPHI中函数有STDCALL,SAFECALL,REGISTER等几种调用方式,因此,在DELPHI中编写DLL时需指明函数使用STDCALL方式执行。在BCB中DLL函数通过,而在DELPHI中调用错误,可能两种语言在对DLL函数的参数解释方式不同造成的。请在DLL中用STDCALL来指示函数的参数入栈顺序。
实战
delphi
dll
的创建和
调用
library fun
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 ShareMem, // ShareMem 一定放第一个 Windows, Messages, SysUtils, math, strutils, registry , StdCtrls, ExtCtrls, ADODB, DB,dateutils,Dialogs; // fucs in 'fucs.pas'; const INPASSSTR='89ABCDEFGcdefghijkHIJ%^KLMN0123opqrstuOP -_\|/?@#$&*' ; //切记:Library 的名字大小写没关系,可是
DLL
-Func的大小写就有关系了。 // 在
DLL
-Func-Name写成MyMax与myMAX是不同的。如果写错了,立即的结果是你
调用
到此
DLL
的AP根本开不起来。 //参数的大小写就没关系了。甚至不必同名。如原型
中
是 (X,Y:integer)但引用时写成(A,B:integer),那是没关系的。 //切记:要再加个stdcall。书上讲,如果你是用
Delphi
写
DLL
,且希望不仅给
Delphi
-AP也希望
BCB
/VC-AP等使用的话,那你最好加个Stdcall ; //参数型态:
Delphi
有很多种它自己的变量型态,这些当然不是
DLL
所喜欢的,Windows/
DLL
的母语应该是C。所以如果要传进传出
DLL
的参数,我们尽可能照规矩来用。这两者写起来,后者会麻烦不少。如果你对C不熟的话,那也没关系。我们以后再讲。 //3.将这些可共享的Func送出
DLL
,让外界﹝就是你的
Delphi
-AP啦﹞使用: //光如此,你的AP还不能用到这些,你还要加个Exports才行。 代码: //=============比较大小的函数=============== Function MyMax ( X , Y : integer ) : integer ; stdcall ; //stdcall 可以让
BCB
/VC-AP等使用的 begin if X > Y then Result := X else Result := Y ; end ; //==============加密======================= function Inpass(s:string):string; stdcall ; var i:integer; passstr,dd:string; begin for i:=1 to length(s) do begin dd:=inttohex(ansipos(s[i],inpassstr),4); if dd='0000' then begin result:='0';exit end; passstr:=passstr+dd ; end; Result :=passstr; end; //==============解密======================= function Outpass(s:string):string;stdcall ; var pass,dd:string; i,leng:integer; begin leng:= floor(length(s)/4); pass:=''; for i:=1 to leng do begin dd:=ansimidstr(s,(i-1)*4+1,4); if strtoint('$'+dd)=0 then begin result:='0';exit;end; if strtoint('$'+dd)>78 then begin result:='0'; exit end; pass:=pass+ansimidstr(inpassstr,strtoint('$'+dd),1) ; end; Result :=pass ; end; //==========test========================= function jsjyh(strym:string):string;stdcall; var newstr1,he,oldstr:string; tj:boolean; i:integer; begin i:=1; he:=''; tj:=true; // 取出要参与校验和计算的字符串给oldstr if (length(strym) mod 2)0 then begin showmessage('你输入的源码个数有错,不能是奇数个,请重输入!'); exit; end; oldstr:=trim(strym); while tj=true do begin newstr1:=copy(oldstr,i,2); oldstr:=copy(oldstr,i+2,length(oldstr)-2); //开始计算校验和并给he变量 if he='' then begin he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+'00',16),2); he:=rightstr(he,2); end else begin he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+he,16),2); he:=rightstr(he,2); end; if length(oldstr) =0 then tj:=false; end; result:=strym+he; end; //============================================== {$R *.RES} //将这些可共享的Func送出
DLL
,让外界﹝就是你的
Delphi
-AP啦﹞使用: //光如此,你的AP还不能用到这些,你还要加个Exports才行。 代码: exports MyMax,Inpass,Outpass,jsjyh; begin end.
BCB
&
Delphi
调用
vs2015动态库报错解决
vs2015封装动态库后c++builder&
delphi
调用
报xx140d.
dll
,需要将压缩文件放到运行程序的目录下
黄历日期
DLL
组件 支持
Delphi
VC VB 完全免费
黄历日期
DLL
组件 版本:1.0 开发:小焱软件 网址:http://www.zystudios.cn 函数说明: 输出函数原型:AlmanacOutPut(LicenseKey:string;Y,M,D:integer); 参数说明: LicenseKey:授权密钥,请输入zystudios.cn Y,M,D分别为年月日 返回类型:PChar字符串,以"/"分割 返回错误说明: invalid date:日期错误,有效范围1901-1-1至2099-12-31 License Key Error:授权密钥错误,请输入 zystudios.cn 本组件对于个人使用完全免费,请在使用过程
中
遵守三方协议,如需应用商业,请联系作者! 本组件有完整的
Delphi
,VC和
BCB
调用
例子,VB,.net,java也可以
调用
,这里就不给出例子了O(∩_∩)O 任何建议欢迎反馈 2009年12月21日
delphi
中
的脚本控件paxscript3.0
TPaxScripter for
Delphi
5, 6, 7, 2005,
BCB
5,
BCB
6, Kylix 3. ------------------------------------------------------------------------------ Version: 3.0. Build: 29 May, 2006. Copyright (c) 2003-2006 Alexander Baranovsky Author: Alexander Baranovsky E-Mail: ab@cable.netlux.org Website : http://www.p
AES加密CBC模式
DLL
delphi
调用
原型: Function AESCBC(kb:integer;resStr:PChar;inKey:PChar;initVector:PChar;error:Pchar):PChar; cdecl; external 'AES.
dll
'; kb:128,192,256, resStr:源字符串 inKey:密匙 initVector:初始向量 返回值为base64编码串
Delphi
5,388
社区成员
262,730
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章