我有这个程序声明:
procedure (options: UNNotificationPresentationOptions); cdecl;
一个函数(在ios中)返回一个地址/指针,指向一个要执行的过程。程序有我上面写的声明。如何调用这个程序只知道它来自delphi的地址?
答案 0 :(得分:4)
将地址分配给指针变量并对其进行类型转换,例如:
type
TProcType = procedure(options: UNNotificationPresentationOptions); cdecl;
var
Ptr: Pointer;
options: UNNotificationPresentationOptions;
begin
Ptr := ...; // the address here
TProcType(Ptr)(options);
end;
可替换地:
type
TProcType = procedure(options: UNNotificationPresentationOptions); cdecl;
var
Proc: TProcType;
options: UNNotificationPresentationOptions;
begin
@Proc := ...; // the address here
Proc(options);
end;