如果不是动太加载,可以这样写:
procedure AProcdure; stdcall; external 'ADll.dll' index 22;
如果用 GetProcAddress,如何取这类函数指针?
procedure AProcdure; stdcall; external 'ADll.dll' index 22;
如果用 GetProcAddress,如何取这类函数指针?
cFileNameLibrary = 'ADll.dll';procedure TForm1.Button2Click(Sender: TObject);
type
TProcedure = procedure; stdcall;
var
vHandle: THandle;
begin
vHandle := LoadLibrary(cFileNameLibrary);
try
TProcedure(GetProcAddress(vHandle, PChar(22)));
finally
FreeLibrary(vHandle);
end;
end;
//---------------------------------------------------
The GetProcAddress function returns the address of the specified exported dynamic-link library (DLL) function. FARPROC GetProcAddress( HMODULE hModule, // handle to DLL module
LPCSTR lpProcName // name of function
);
ParametershModuleIdentifies the DLL module that contains the function. The LoadLibrary or GetModuleHandle function returns this handle. lpProcNamePoints to a null-terminated string containing the function name, or specifies the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the high-order word must be zero. it must be in the low-order word; the high-order word must be zero.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~