GetProcAddress如何取类似 AProcdure@22 的函数?

lfstudy 2003-03-26 07:54:46
如果不是动太加载,可以这样写:
procedure AProcdure; stdcall; external 'ADll.dll' index 22;
如果用 GetProcAddress,如何取这类函数指针?
...全文
59 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
王集鹄 2003-03-27
  • 打赏
  • 举报
回复
const
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
);


Parameters

hModule

Identifies the DLL module that contains the function. The LoadLibrary or GetModuleHandle function returns this handle.

lpProcName

Points 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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Eastunfail 2003-03-26
  • 打赏
  • 举报
回复
如果该导出的API函数的名字是你说的这样的“怪名字”~~~那么说明一个问题,他不是以cdecl方式导出的。~~~~~

你将stdcall改成别的试试

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧