W
wp231957
Unregistered / Unconfirmed
GUEST, unregistred user!
#include <windows.h>
#include "max.h"
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) int maxnum(int a,int b)
{
if(a>b)
return a;
else
return b;
}
上面是主程序,在进入VC60时选择32位DLL--空DLL(非MFC的)
max.h的代码如下:
extern "C" __declspec(dllexport) int maxnum(int a,int b);
编译可以通过,在DELPHI下调用在SHOWMESSAGE到正确的结果后
出现内存地址非法访问的错误是何原因
DELPHI 调用如下:
function maxnum(a,b:integer):integer;stdcall;external 'g:/tdll2.dll';
procedure TForm1.Button6Click(Sender: TObject);
begin
showmessage(inttostr(maxnum(5,19)));
end;
#include "max.h"
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) int maxnum(int a,int b)
{
if(a>b)
return a;
else
return b;
}
上面是主程序,在进入VC60时选择32位DLL--空DLL(非MFC的)
max.h的代码如下:
extern "C" __declspec(dllexport) int maxnum(int a,int b);
编译可以通过,在DELPHI下调用在SHOWMESSAGE到正确的结果后
出现内存地址非法访问的错误是何原因
DELPHI 调用如下:
function maxnum(a,b:integer):integer;stdcall;external 'g:/tdll2.dll';
procedure TForm1.Button6Click(Sender: TObject);
begin
showmessage(inttostr(maxnum(5,19)));
end;