将资源添加到 Visual C++/CLI 混合 DLL
我正在编写一个包含托管类和非托管类的混合 C++/CLI DLL。 两者都需要访问字符串和其他类型的资源,例如 Direct3D 纹理。
如何最好地将它们嵌入到 DLL 中? 似乎有几种方法可以做到这一点; .resx(新样式,托管)、.rc(旧样式)可用于生成 .resources 文件并(可选)嵌入到程序集中。
目前我正在使用 .rc 文件和 ::LoadString() 来获取我的字符串。 我有一个托管包装器,用于将 String^ 值返回到托管代码。 以及将 WCHAR* 返回本机代码的类似方法。
有更好的方法吗? 有哪些权衡? 例如,我可以使用 .resx 文件和 ResourceManager 类作为托管代码,使用 .rc 作为本机代码,但这意味着我无法共享资源等。是否有推荐的方法?
谢谢,
阿德
I'm writing a mixed C++/CLI DLL with both managed and unmanaged classes. Both need access to string and other types of resources, like Direct3D textures.
How best to embed them within the DLL? It seems like there are several ways to do this; .resx (new style, managed), .rc (old style) which can be used to generate .resources files and (optionally) embedded within the assembly.
Currently I'm using a .rc file and ::LoadString() to get my strings. I have a managed wrapper for this to return String^ values to managed code. And a similar method to return WCHAR* to native code.
Is there a better way of doing this? What are the tradeoffs? I could for instance use a .resx file and the ResourceManager class for managed code and an .rc for native but this means I can't share resources etc. Is there a recommended approach?
Thanks,
Ade
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只使用 .resx,如果本机代码需要任何字符串,我会设法从 .resx 文件中获取内容并将其转换为下一行的 CString。
尽管您已经有一个包装器可以做到这一点,所以它会更容易。
.rc 文件太 1997 年了!
I just use a .resx and if there is any strings the native code needs I use managed to get stuff out of my .resx file and convert it into a CString on the next line.
Although you already have a wrapper to do this so it would be even easier.
.rc files are so 1997 man!