我们可以动态链接 DLL 的不同方法是什么

What are the different ways with which we can dynamically Link a DLL

本文关键字:方法 是什么 DLL 动态 链接 我们      更新时间:2023-10-16

我想动态链接.dll。有多种方法可以做到这一点?

我知道的一种方法是使用HMODULE WINAPI LoadLibrary(_In_ LPCTSTR lpFileName)功能。还有其他办法吗?我正在尝试理解以下代码:

#if defined WIN32
    // We want to define DTE_DLL_EXPORT if we are making
    // a dll, but not if we are making a static library...
    #if defined DTE_STATIC
        #define GFITDTE_ENTRYPT
    #else
        #if defined _GFITDTE_BUILD_
            #define GFITDTE_ENTRYPT __declspec(dllexport)
        #else
            #if defined DTE_IMPORT
                #define GFITDTE_ENTRYPT __declspec(dllimport)
            #else
                #define GFITDTE_ENTRYPT
            #endif
        #endif
    #endif
#else // Not WIN32

有些人可以解释上面的代码吗?

显示的代码与LoadLibrary无关。这是头文件的典型特征,这反过来意味着您正在构建一个不应该通过 LoadLibrary 加载的 DLL。相反,编译器从标头中知道函数原型,链接器使用导入库来设置 DLL 链接。