VC调用静态库、动态库

静态库

// 相对路径 或者 绝对路径
#include "yourlib.h"

//相对路径 或者 绝对路径
#pragma comment(lib, "yourlib.lib")

int main()
{
    int ret = 0;
       
        // lib里的函数      
        ret = funcInYourLib(int param1);
}

动态库

#include <Windows.h>

typedef int (__stdcall *Func)(int param);

int main()
{
    int ret = 0;

        // 相对路径 或者 绝对路径
    HINSTANCE hdllInst = LoadLibrary("yourDll.dll");  

    Func func=(Func)GetProcAddress(hdllInst,"funcNameInDll");  

    ret = func(0);
}

 

posted @ 2018-03-15 10:50  cnblogs_z_s  阅读(2502)  评论(0编辑  收藏  举报