如何在C++中连接代码执行过程中的dll文件
How to connect the dll files in the process of code execution in C++?
有一个用QT(C++)编写的编译程序。在程序文件夹中添加了dll文件,所有的名称都是Lib1.dll、Lib2.dll等。在程序的执行过程中,我如何获得这些库?也就是说,最初程序是在没有的情况下编译的
例如:
int n = 10;
for(int i=0;i<n;i++)
{
include("lib"+i+".dll");
}
使用QLibrary 解决了问题
for(int i=0; i<n;i++)
{
QString* pLoadLib =&sDrivers[i]; //запоминаем адрес переменной
std::cout<<sDrivers[i].toUtf8().constData()<<"n";//выводим в консоль
QLibrary lib(*pLoadLib); //Разименование адреса - текст пути к ДЛЛ
if (!lib.load())
{
std::cout<<"driver not loadedn";//error
}
else
{ typedef QString (*FuncType) (const QString&);
FuncType func = (FuncType)(lib.resolve("FuncName")); //Определяем функцию func как функция OddUpper из dll
if (func)
{
QString test = func("working");
qDebug()<<test;
}
if (!func)
{
std::cout<<"func not loaded";
}
lib.unload();
}
}
相关文章:
- 如何编写在函数执行过程中垃圾回收的测试用例?
- CPP DLL 自定义操作代码在安装过程中未执行
- 如何在启动过程中崩溃时使用 gdb 调试可执行文件
- 如果在执行过程中替换二进制文件,"const"数组是否驻留在内存中?
- 我的代码在执行过程中运行良好.但是当我去提交它的显示分割错误时
- 使用链接器"ld"在 ASM 文件中执行C++过程
- 在C++中嵌入 Python:解释器在执行过程中的持久性
- 在我的代码中执行存储过程时出现问题
- 执行过程中的变量更改.C
- C 可以在程序执行过程中移动内存映射的文件(boost :: intercecess)移动
- 在计时器执行过程中使用 c++ KillTimer() 是否安全?
- 当可执行文件在执行过程中被替换时如何处理"/proc/self/exe"的readlink()?
- 在std::for_each的执行过程中累积结果,该异常被中断
- C++,exe在执行过程中已停止工作
- 在执行过程中睡一根线
- cuda 执行块是否可以在执行过程中中断
- 变量的地址在执行过程中可以更改吗?
- C++:链接库在执行过程中消失并给出segfault
- 如何在编译过程中编辑可执行文件,而不更改其源代码
- 如何让C预处理器在编译过程中执行代码