1.动态库也有lib文件,称为导入库,一般大小只有几k;

2.动态库有静态调用和动态调用两种方式:

静态调用:使用.h和.lib文件

动态调用:

先LoadLibrary,再GetProcAddress(即找到DLL中函数的地址),不用后FreeLibrary。具体示例代码(摘自网上)如下:

{
    HINSTANCE hDllInst = LoadLibrary("youApp.DLL");
    if(hDllInst){
        typedef DWORD (WINAPI *MYFUNC)(DWORD,DWORD);
        MYFUNC youFuntionNameAlias = NULL; // youFuntionNameAlias 函数别名
        youFuntionNameAlias = (MYFUNC)GetProcAddress(hDllInst,"youFuntionName");
        // youFuntionName 在DLL中声明的函数名
        if(youFuntionNameAlias){
            youFuntionNameAlias(param1,param2);
        }
    FreeLibrary(hDllInst);
    }
}
posted on 2018-05-17 16:59  Mr_Seven77  阅读(218)  评论(0编辑  收藏  举报