动态库的函数调用
发布时间:2020-12-15 10:01:34 所属栏目:大数据 来源:网络整理
导读:type xx = function(): string; stdcall;是什么意思解决方案 type xx = function(): string; stdcall;是什么意思 function?xx():?string; type ??xx=?function():?string;?stdcall; var ??func:?xx; begin ??Result?:=?'0'; ??@func?:=?yy('xx'); ??if?Assig
type xx = function(): string; stdcall;是什么意思解决方案
type xx = function(): string; stdcall;是什么意思
如上:我想知道每一步代表什么意思,求大神告诉啊。其中的?yy('xx')是接口的初始化函数。
delphi?
type?
@fun?
function()
------解决方案--------------------
------解决方案-------------------- DLL动态调用就是这么弄的 函数定位?@func?:=?yy('xx');? ------解决方案-------------------- 定义了函数指针,多数用于动态库的调用场合;如下示例: procedure?TFrmFirewatcherDllTest.btnCmdStartTestClick(Sender:?TObject); type??pStartCmd=function?(pbuff:PChar;nLen:Word):integer;?stdcall; var ??hDll:Cardinal; ??startCmd:pStartCmd; ??arrCmd:array?[0..255]?of?Char; ??nLen:Word; ??i:Integer; ??str:string; begin ??btnCmdStartTest.Enabled?:=?False; ??hDll?:=?LoadLibrary('..SourceDLLFirewatcherDLL.dll'); ??try ????if?hDll>32?then ????begin ??????@startCmd?:=?GetProcAddress(?hDll,'START'); ??????if?Assigned(?startCmd?)?then ??????begin ????????nlen?:=??startCmd(?arrCmd,?256?); ????????for?i:=?0?to?nLen-1?do ????????begin ??????????str?:=?str?+'?'+?IntToHex(?Ord(arrcmd[i]),?2?); ????????end; ????????Memo1.Lines.Add(IntToStr(?Memo1.Lines.Count+1)+?'?【开机】指令长度:'+inttostr(nLen)+?';?指令数据:'+quotedstr(?trim(?str?)?)???????) ??????end; ????end; ??finally ????FreeLibrary(?hDll?); ????btnCmdStartTest.Enabled?:=?True; ??end; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |