5个回答
展开全部
//动态调用方式、先定义函数、后面在通过Button过程调入个函数接口地址
_GetPassWord:function (Pass:string):string;stdcall;
_CheckPassWord:Function(SourcePass:string;EncryPass:string):boolean;stdcall;
_StrEncrypt:Function(s: string; key: word): string;StdCall;
_StrDecrypt:Function(s: string; key: word): string;StdCall;
_GetRegistCode:Function(Pass:string):String;StdCall;
_CheckRegistCode:Function(CompanyName,RegistCode:string):Boolean;StdCall;
//下面为静态调用方式
function GetPassWord(Pass:string):ShortString;stdcall;external 'MyHRDLL.dll';
function CheckPassWord(SourcePass,EncryPass:string):Boolean;stdcall;external 'MyHRDLL.dll';
function StrEncrypt(s: string; key: word): ShortString;stdcall;external 'MyHRDLL.dll';
function StrDecrypt(s: string; key: word): ShortString;stdcall;external 'MyHRDLL.dll';
function GetRegistCode(Pass:string):ShortString;stdcall;external 'MyHRDLL.dll';
function CheckRegistCode(CompanyName,RegistCode:string):Boolean;stdcall;external 'MyHRDLL.dll';
动态调用的button实现:
procedure TForm1.Button5Click(Sender: TObject);
begin
try
_DLLMoudle := Loadlibrary('MyHRDLL.dll');
ShowMessage('初始化成功!!!');
except
ShowMessage('初始化失败!!!');
Exit;
end;
if _DLLMoudle > 32 then begin
Try
@_GetPassWord:=GetProcAddress(_DLLMoudle,'GetPassWord'); //打开串口
@_CheckPassWord:=GetProcAddress(_DLLMoudle,'CheckPassWord'); //关闭串口
@_StrEncrypt:=GetProcAddress(_DLLMoudle,'StrEncrypt'); //对卡号冲值
@_StrDecrypt:=GetProcAddress(_DLLMoudle,'StrDecrypt'); //删除卡号
@_GetRegistCode:=GetProcAddress(_DLLMoudle,'GetRegistCode'); //终端机清除刷卡记录
@_CheckRegistCode:=GetProcAddress(_DLLMoudle,'CheckRegistCode'); //
ShowMessage('DLL装载成功.............');
Except
ShowMessage('出错!!DLL打开失败!!不能做其他操作!!');
End
end;
end;
_GetPassWord:function (Pass:string):string;stdcall;
_CheckPassWord:Function(SourcePass:string;EncryPass:string):boolean;stdcall;
_StrEncrypt:Function(s: string; key: word): string;StdCall;
_StrDecrypt:Function(s: string; key: word): string;StdCall;
_GetRegistCode:Function(Pass:string):String;StdCall;
_CheckRegistCode:Function(CompanyName,RegistCode:string):Boolean;StdCall;
//下面为静态调用方式
function GetPassWord(Pass:string):ShortString;stdcall;external 'MyHRDLL.dll';
function CheckPassWord(SourcePass,EncryPass:string):Boolean;stdcall;external 'MyHRDLL.dll';
function StrEncrypt(s: string; key: word): ShortString;stdcall;external 'MyHRDLL.dll';
function StrDecrypt(s: string; key: word): ShortString;stdcall;external 'MyHRDLL.dll';
function GetRegistCode(Pass:string):ShortString;stdcall;external 'MyHRDLL.dll';
function CheckRegistCode(CompanyName,RegistCode:string):Boolean;stdcall;external 'MyHRDLL.dll';
动态调用的button实现:
procedure TForm1.Button5Click(Sender: TObject);
begin
try
_DLLMoudle := Loadlibrary('MyHRDLL.dll');
ShowMessage('初始化成功!!!');
except
ShowMessage('初始化失败!!!');
Exit;
end;
if _DLLMoudle > 32 then begin
Try
@_GetPassWord:=GetProcAddress(_DLLMoudle,'GetPassWord'); //打开串口
@_CheckPassWord:=GetProcAddress(_DLLMoudle,'CheckPassWord'); //关闭串口
@_StrEncrypt:=GetProcAddress(_DLLMoudle,'StrEncrypt'); //对卡号冲值
@_StrDecrypt:=GetProcAddress(_DLLMoudle,'StrDecrypt'); //删除卡号
@_GetRegistCode:=GetProcAddress(_DLLMoudle,'GetRegistCode'); //终端机清除刷卡记录
@_CheckRegistCode:=GetProcAddress(_DLLMoudle,'CheckRegistCode'); //
ShowMessage('DLL装载成功.............');
Except
ShowMessage('出错!!DLL打开失败!!不能做其他操作!!');
End
end;
end;
展开全部
两种方法:
第一种,静态调用声明
function TestFun(p:integer):Integer;stdcall;external 'MyDll.Dll' name 'TestFun';
第二种,动态声明
var
hDll:DWORD;
TestFun:function(p:integer):Integer;stdcall;
begin
hDll:=Loadlibrary('MyDll');//加载Dll
@TestFun:=GetProcAddress(hDll, 'TestFun');//获取Dll函数地址
TestFun(...);//使用函数
end;
第一种,静态调用声明
function TestFun(p:integer):Integer;stdcall;external 'MyDll.Dll' name 'TestFun';
第二种,动态声明
var
hDll:DWORD;
TestFun:function(p:integer):Integer;stdcall;
begin
hDll:=Loadlibrary('MyDll');//加载Dll
@TestFun:=GetProcAddress(hDll, 'TestFun');//获取Dll函数地址
TestFun(...);//使用函数
end;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
动态链接库是一个能够被应用程序和其它的DLL调用的过程和函数的集合体,它里面包含的是公共代码或资源。由于DLL代码使用了内存共享技术,在某些地方windows也给了DLL一些更高的权限,因而DLL中可以实现一些一般程序所不能实现的功能,如实现windows的HOOK、ISAPI等。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
为什么要混编啊,所有功能都可以用delphi完成的。要么用delphi写一个activeX,然后在VB中调用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询