根据函数名载入库函数(GetProcAddress、dlsym)
不废话上代码:
#ifdef WIN32
#include <windows.h>
typedef HINSTANCE HandleType;
#define LoadLib(filename) LoadLibraryA(filename)
#define UnLoadLib(handle) FreeLibrary(handle)
#define GetProcessAddressByName(handle,name) GetProcAddress(handle, name)
#else
#include <dlfcn.h>
#include <pthread.h>
#include <linux/unistd.h>
#include <sys/syscall.h>
#include <iconv.h></

本文介绍了如何根据函数名在Windows环境下使用GetProcAddress和在Linux环境下使用dlsym动态载入库函数。强调了使用GetProcAddress时的注意事项,如参数类型、导出函数名的规范以及避免使用ordinal值。同时提出了一个关于动态获取类方法并执行的疑问,探讨了编译时链接库的影响,并提及在Linux下dlopen和dlsym的使用。
最低0.47元/天 解锁文章
784

被折叠的 条评论
为什么被折叠?



