请查看优秀的Detour库的演示源代码:
implementation
{$R *.dfm}
var
TrampolineGetMemory: function(Size: NativeInt): Pointer;
cdecl = nil;
请看
cdecl = nil;
语句。在这个上下文中,它是什么意思?注意-我已经知道代表调用约定。
program Project1;
{$APPTYPE CONSOLE}
var
i : integer = 5;
begin
WriteLn(i);
ReadLn;
end.
如果将其写在一行中,可能会更清晰:
var
TrampolineGetMemory: function(Size: NativeInt): Pointer; cdecl = nil;
如果定义了类型,那可能会更好:
type
TTrampolineGetMemory = function(Size: NativeInt): Pointer; cdecl;
//...
var
TrampolineGetMemory: TTrampolineGetMemory = nil;
TrampolineGetMemory
是一个过程变量,其初始值为 nil
。
如果改写成以下形式,更容易理解:
type
TTrampolineGetMemory = function(Size: NativeInt): Pointer; cdecl;
var
TrampolineGetMemory: TTrampolineGetMemory = nil;
var i: Integer = 42;
。 - David Heffernan