我在 c++ builder 中有一个简单的 DLL。
//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma hdrstop
#pragma argsused
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
return TRUE;
}
//---------------------------------------------------------------------------
extern "C" __declspec(dllexport) void show_m(void)
{
MessageBox(NULL, "MSG", "COTI DLL", MB_OK |MB_ICONINFORMATION);
}
当我在 delphi 中调用它时,我得到错误,即 dll 中没有过程:
procedure TForm1.Button1Click(Sender: TObject);
var
DLL : THandle;
show_m1 : procedure; cdecl;
begin
DLL := LoadLibrary('mylib.dll');
@show_m1:= GetProcAddress(DLL, 'show_m');
show_m1;
FreeLibrary(DLL);
end;
有什么问题,它应该可以正常工作,但事实并非如此?