制作DLL的代码 :#define MakeDll_API _declspec(dllexport)
#include "MakeDll.h"
int MyFun(int i)
{
i = i+2;
return i;
}LoadLibrary 调用资格库时,GetProcAddress这句话始终得到空。这是为什么啊。如何改进呢?#include <stdio.h> 
#include <windows.h> 
typedef int(*lpAddFun)(int); void CLoadLibraryTestDlg::OnButton1() 
{
HINSTANCE hDll; 
lpAddFun addFun; 
hDll = LoadLibrary("MakeDll.dll"); 
if (hDll != NULL) 

addFun = (lpAddFun)GetProcAddress(hDll,"MyFun(int i)"); 
if (addFun != NULL) //为什么addFun总为空呢?
{
int result = 0 ;
result = addFun(2);

FreeLibrary(hDll); 

}

解决方案 »

  1.   

    问下,如果不loadLIB,直接包含库,能用吗
      

  2.   

    GetLastError();函数的返回值是什么看看
      

  3.   

    addFun = (lpAddFun)GetProcAddress(hDll,"MyFun"); 
      

  4.   

    127 The specified procedure could not be found. 
    路径不对
      

  5.   

    addFun = (lpAddFun)GetProcAddress(hDll,"MyFun(int i)"); 
    ----------------------------------------------
    囧,你这个写的真是有创意。
      

  6.   

    导到函数在头文件最好用C编译方式,防止函数名字改编:
    extern "C" MakeDll_API int MyFun(int i);//注意你写的这个有问题
    addFun = (lpAddFun)GetProcAddress(hDll,"MyFun(int i)");
    改成
    addFun = (lpAddFun)GetProcAddress(hDll,"MyFun");//只要此导出函数名称
      

  7.   

     addFun = (DWORD)GetProcAddress(hDll,"MyFuck"); 
    另外你的MyFuck函数必须声明为导出函数.相当于给书建了个目录.
    可以通过目录名(函数名)找到页数(函数地址),但是必须声明为导出
      

  8.   

    加c修饰。另,只要函数就行,不要跟变量。
    楼上也挺搞笑的,看错哪个单词不行,非要把人家的myfun看成myfuck。天才啊……