[英]How to get the directory of the current DLL
I will build c-shared in golang -o config.dll
.我将在 golang
-o config.dll
构建 c-shared 。
Let's say the directory is c:\\test\\config.dll
假设目录是
c:\\test\\config.dll
In mail.dll, I'm going to open a configuration file.在mail.dll 中,我将打开一个配置文件。 This file is in the directory of config.dll.
该文件位于 config.dll 目录中。
c:\\test\\config.json
I'm calling it in c++ c:\\test\\c++.dll
.我在 c++
c:\\test\\c++.dll
调用它。
In c++ I use在 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
What is the equivalent of this in Go? Go 中的 this 等价物是什么?
I try to use我尝试使用
os.Getwd()
runtime.Caller(1)
os.Args[0]
os.Executable()
I want to get directory c:\\test\\
我想获取目录
c:\\test\\
您可以使用 cgo 在它存在的任何库中调用相同的函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.