获取DLL所在位置的方法
时间:2024-02-19
浏览:201
作者:佚名
对于一个Golang开发者来说,牢固扎实的基础是十分重要的,golang学习网就来带大家一点点的掌握基础知识点。今天本篇文章带大家了解《获取DLL所在位置的方法》,主要介绍了,希望对大家的知识积累有所帮助,快点收藏起来吧,否则需要时就找不到了!
问题内容
我将在golang中构建c-shared -o config.dll。
假设目录是 c:\test\config.dll
在mail.dll中,我将打开一个配置文件。
该文件位于config.dll目录中。
c:\test\config.json
我在 c++ 中调用它 c:\test\c++.dll。
在 c++ 中我使用
{ // nb: xp+ solution!
hmodule hmodule = null;
getmodulehandleex(
get_module_handle_ex_flag_from_address,
(lpctstr)getcurrentmodule,
&hmodule);
return hmodule;
}
wchar path3[max_path + 1] = { 0 };
hmodule hm = getcurrentmodule();
::getmodulefilename(hm, path3, max_path);
pathremovefilespec(path3);
// path3 c:\test\c++.dll
go 中相当于什么?
我尝试使用
os.Getwd() runtime.Caller(1) os.Args[0] os.Executable()
我想获取目录c:\test\
解决方案
您可以使用 cgo 在任何存在的库中调用相同的函数。
到这里,我们也就讲完了《获取DLL所在位置的方法》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
11.20
11.20
11.20
11.20
热门专题
