#include <stdio.h>
#include <windows.h>
typedef int (*lpAddFun)(int,int);
int main(int argc, char *argv[])
{
HINSTANCE hInst_1 = LoadLibrary("dllTest.dll"); //DLL句柄
lpAddFun addFun; //函数指针
if (hInst_1 != NULL)
{
addFun = (lpAddFun)GetProcAddress(hInst_1,"add");
if (addFun != NULL)
{
int result = addFun(2,3);
printf("%d",result);
}
FreeLibrary(hInst_1);
}
system("pause");
return 0;
}
不是学计算机的,基础不牢编程出现好多低端错误。正在学动态库,上面是一个例程,DLL句柄处运行时一直出错。hInst_1返回值一直是NULL,求各位大神指点。