type xx = function(): string; stdcall;是什么意思解决方案
type xx = function(): string; stdcall;是什么意思
如上:我想知道每一步代表什么意思,求大神告诉啊。其中的 yy('xx')是接口的初始化函数。
------解决方案--------------------
------解决方案--------------------
DLL动态调用就是这么弄的
函数定位 @func := yy('xx');
------解决方案--------------------
定义了函数指针,多数用于动态库的调用场合;如下示例:
function xx(): string;
type
xx= function(): string; stdcall;
var
func: xx;
begin
Result := '0';
@func := yy('xx');
if Assigned(@func) then
begin
Result := func();
end;
end;
如上:我想知道每一步代表什么意思,求大神告诉啊。其中的 yy('xx')是接口的初始化函数。
delphi
type
@fun
function()
------解决方案--------------------
function xx(): string; // 定义一个 xx 函数
type
xx= function(): string; stdcall;// 定义一个名为xx的函数指针类型
var
func: xx; // 声明一个名叫func、类型为xx的函数指针变量
begin
Result := '0';
@func := yy('xx');// func函数指针指向yy这个函数
if Assigned(@func) then // 如果func成功指向yy这个函数
begin
Result := func(); 执行func这个函数指针指向的函数,并返回其返回值
end;
end;
------解决方案--------------------
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('..\SourceDLL\FirewatcherDLL.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;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。