【发布时间】:2016-05-06 21:07:40
【问题描述】:
我正在用 delphi XE8 编写一个 dll,供用 Delphi XE8 编写的应用程序使用。
我的 DLL 看起来像这样。
function GetInt : Integer; stdcall;
begin
Result := 300;
end;
exports GetInt;
我的应用看起来像这样。
dllHandle := LoadLibrary(PChar('myDLL.dll'));
ShowMessage(SysErrorMessage(GetLastError));
if dllHandle <> 0 then
begin
@GetInt := GetProcAddress(dllHandle, 'GetInt');
ShowMessage(SysErrorMessage(GetLastError));
if Assigned(GetInt) then
ShowMessage(IntToStr(GetInt))
else
ShowMessage('Nope');
end;
我收到“找不到指定的过程”错误。因此,我将 export 语句和 @GetInt 语句从“GetInt”更改为“getInt”。现在一切都很好。
所以现在我的问题是:为什么我的 dll 函数和导出需要是同一个词,但区分大小写?
【问题讨论】:
-
GetProcAddress确实区分大小写。您的代码看起来正确。我建议您检查图像的导出目录(例如tdump) -
无法使用提供的代码重现。
-
这绝不是一个好兆头。
-
我正在使用 Delphi XE8。