procedure TDynamicModule.LoadRoutine(var Routine: Pointer; const Name: string);
(* Note that the name of the entry point is case-sensitive. *)
begin
if Routine = nil then
begin
{$if defined(CPUX86_64) }
Assert(PtrUInt(@Routine) mod 8 = 0, 'Internal error: processor-specific stack misalignment for GetProcedureAddress(2) A');
Assert(PtrUInt(@Name) mod 8 = 0, 'Internal error: processor-specific stack misalignment for GetProcedureAddress(2) B');
{$endif }
Routine := GetProcedureAddress(ModuleHandle, Trim(Name));
FLastError := GetLoadErrorStr;
if Routine = nil then
raise DynamicModuleException.Create(FLastError)
end
end;
function TDynamicModule.LoadRoutine(const Name: string): Pointer;
(* This is an overloaded addition to Martin's original code. It can *)
(* result in neater code but is much less efficient since can't check *)
(* whether it has already been called. *)
begin
{$if defined(CPUX86_64) }
Assert(PtrUInt(@result) mod 8 = 0, 'Internal error: processor-specific stack misalignment for GetProcedureAddress(1) A');
Assert(PtrUInt(@Name) mod 8 = 0, 'Internal error: processor-specific stack misalignment for GetProcedureAddress(1) B');
{$endif }
RESULT:= GetProcedureAddress(ModuleHandle, Trim(Name));
FLastError := GetLoadErrorStr;
if RESULT = nil then
raise DynamicModuleException.Create(FLastError)
end;