将确定性路径代码从 C# 转换为 C++
有谁知道如何将其(从 C#)转换为 C++?
string location = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ZigbeeCommUSB)).CodeBase);
location = location.Substring(location.IndexOf("\\") + 1);
谢谢。
编辑:附加信息
这是从 C# 转换为本机 C++。如果有另一种方法来获取当前正在执行的可执行文件的文件路径,我愿意接受想法。谢谢。
Does anyone know how I can convert this (from C#) to C++?
string location = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ZigbeeCommUSB)).CodeBase);
location = location.Substring(location.IndexOf("\\") + 1);
Thanks.
EDIT: Additional Information
This is to convert from C# to native C++. If there is another way to get the file path of the currently executing executable, I am open to ideas. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
子字符串
C++ 中的 IndexOf
上面链接中的 Assembly.GetAssembly 示例
如果您结合上述内容,您可能会更接近您想要的做。 如果这是在 Native C++ 中完成的,你会遇到更多的问题,有一个叫做 "Fusion API" 可能会帮助您在 GAC 中查找程序集。
Substring
in C++IndexOf
in C++Example of Assembly.GetAssembly from the above link
If you combind the above, you will probably come a bit closer to what you want to do. If this is going to be done in Native C++, you will have a bit more problem, there is something called "Fusion API" that might help you look for assemblies in the GAC.
要检索当前可执行文件的路径,请使用 GetModuleFileName 使用 NULL hModule 参数。
To retrieve the path of the current executable, use GetModuleFileName using a NULL hModule argument.