windows执行完LoadLibrary()后,可以删除源动态库文件,函数不会锁库文件。文章来源:https://www.toymoban.com/news/detail-645826.html
#include <iostream>
#include <Windows.h>
int main()
{
char path[MAX_PATH]{};
GetCurrentDirectoryA(sizeof(path), path);
HMODULE lib = LoadLibraryA("testdll.dll");
int rmret = remove("testdll.dll");
std::cout << "remove ret=" << rmret << "," << path << "," << GetLastError() << std::endl;
auto func = (const char*(*)())GetProcAddress(lib, "test1");
std::cout << "Hello World!\n" << func() << std::endl;
return 0;
}
运行结果:文章来源地址https://www.toymoban.com/news/detail-645826.html
remove ret=-1,C:\Users\Administrator\source\repos\testdll\ConsoleApplication1,2
Hello World!
0.1.0
到了这里,关于windows执行完LoadLibrary()后,可以删除源动态库文件,函数不会锁库文件的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!