用模块文件创建DLL,如何进行隐式调用?
我用声明导出函数的办法,做出的DLL能够进行显式调用和隐式调用,但用模块文件导出的DLL,只能进行显式调用,目前还没掌握隐式调用的方法,特来请教各位高手。
//DllTest.h
#ifdef DLL_EXPORT
#define DLL_API extern "C" _declspec(dllexport)
#else
#define DLL_API extern "C" _declspec(dllimport)
#endif
DLL_API int add(int a,int b);
//DllTest.cpp
#define DLL_EXPORT
#include "DllTest.h"
int add(int a,int b)
{
return a+b;
}
//隐式调用代码
#include <stdio.h>
#include <conio.h>
#include "DllTest.h"
#pragma comment(lib, "DllTest.lib")
int main()
{
int a = 8, b = 3;
printf("%d+%d=%d\n", a, b, add(a, b));
getch();
return 0;
}
请问用模块文件创建的DLL没有头文件,我们如何进行隐式调用?
LIBRARY DllTest
EXPORTS
add
//DllTest.cpp
int add(int a, int b)
{
return a+b;
}
//DllTest.h
#ifdef DLL_EXPORT
#define DLL_API extern "C" _declspec(dllexport)
#else
#define DLL_API extern "C" _declspec(dllimport)
#endif
DLL_API int add(int a,int b);
//DllTest.cpp
#define DLL_EXPORT
#include "DllTest.h"
int add(int a,int b)
{
return a+b;
}
//隐式调用代码
#include <stdio.h>
#include <conio.h>
#include "DllTest.h"
#pragma comment(lib, "DllTest.lib")
int main()
{
int a = 8, b = 3;
printf("%d+%d=%d\n", a, b, add(a, b));
getch();
return 0;
}
请问用模块文件创建的DLL没有头文件,我们如何进行隐式调用?
LIBRARY DllTest
EXPORTS
add
//DllTest.cpp
int add(int a, int b)
{
return a+b;
}
...全文
相关推荐
DLL动态链接库生成和使用(隐式调用、显示调用)
Windows10 64位系统,VS2013 编程平台。两个工程,工程一为生成DLL的方法,生成dll、lib文件;工程二为调用DLL的方法,分为隐式调用和显式调用。两个工程都是控制台应用程序consoleapplication。 对应的文章为 https://blog.csdn.net/u012210613/article/details/88904841
C++ 多个类的DLL封装以及隐式链接和显式链接2种方法调用
C++ 多个类的DLL封装以及隐式链接和显式链接2种方法调用
隐式调用dll和显式调用dll
隐式调用dll和显式调用dll,并做了demo在同一个solution下编译就可以尝试,通过宏来控制隐式和显示调用。显示调用即使dll改名依然能够获取函数地址,通过函数指针来使用。
改变隐式加载dll路径的方法实例代码
通过SetDllDirectory可以灵活的设置隐式加载dll的路径,详见源代码.vs2005编译
QT中DLL显示加载和隐式加载的Demo
自己学习QT中DLL显示加载和隐式加载的Demo,相关文章链接:https://www.jianshu.com/p/2851c0f7f4a9


其它技术问题

