主题:菜鸟求救!!
#include <stdio.h>
#include <windows.h>
void main(void)
{
HINSTANCE hInst;
hInst=LoadLibrary("dllTest.dll");
if (!hInst)
{
MessageBox(NULL,"加载DLL错误","error",MB_OK);
return;
}
typedef int (*PdllFun)(int,int);
PdllFun PdllFun1;
PdllFun1=(PdllFun)GetProcAddress(hInst,"k_add");
if (!PdllFun1)
{
MessageBox(NULL,"获取函数地址错误","error",MB_OK);
return;
}
}
运行会弹出"获取函数地址错误",为什么会获取函数地址错误呢?
--------------------------------------
那个DLL文件编好了,应该没什么问题:
#include <math.h>
int k_add(int a,int b)
{
return a+b;
}
int k_sub(int a,int b)
{
return abs(a-b);
}
#include <windows.h>
void main(void)
{
HINSTANCE hInst;
hInst=LoadLibrary("dllTest.dll");
if (!hInst)
{
MessageBox(NULL,"加载DLL错误","error",MB_OK);
return;
}
typedef int (*PdllFun)(int,int);
PdllFun PdllFun1;
PdllFun1=(PdllFun)GetProcAddress(hInst,"k_add");
if (!PdllFun1)
{
MessageBox(NULL,"获取函数地址错误","error",MB_OK);
return;
}
}
运行会弹出"获取函数地址错误",为什么会获取函数地址错误呢?
--------------------------------------
那个DLL文件编好了,应该没什么问题:
#include <math.h>
int k_add(int a,int b)
{
return a+b;
}
int k_sub(int a,int b)
{
return abs(a-b);
}