如何将二进制数据嵌入/链接到 Windows 模块中
所以我有一个 Visual Studio 2008 项目,其中包含大量当前引用的二进制数据.我想像使用 C# 一样打包二进制数据,将其添加为资源"并将其编译为 DLL.
So I have a Visual Studio 2008 project which has a large amount of binary data that it is currently referencing. I would like to package the binary data much like you can do with C# by adding it as a "resource" and compiling it as a DLL.
假设我的所有数据都具有.data"的扩展名,并且当前正在从 Visual Studio 项目中读取.
Lets say all my data has an extension of ".data" and is currently being read from the visual studio project.
有没有一种方法可以将数据编译或链接到它正在调用的 .dll 中?
Is there a way that you can compile or link the data into the .dll which it is calling?
我已经查看了一些谷歌链接,但到目前为止我还没有想出任何东西 - 我想出的唯一可能的解决方案是使用类似 ResGen 创建一个 .resources 文件,然后使用 AssemblyLinker 带有/Embed 或/Link 标志.我认为它不能正常工作,因为我没有文本文件来创建 .resources 文件,而是二进制文件本身.
I've looked at some of the google link for this and so far I haven't come up with anything - the only possible solution I've come up with is to use something like ResGen to create a .resources file and then link it using AssemblyLinker with /Embed or /Link flags. I dont think it'd work properly though because I dont have text files to create the .resources files, but rather binary files themselves.
有什么建议吗?
推荐答案
- 右键单击资源脚本(.rc 文件)
- 选择导入
- Right click the resource script (.rc file)
- Choose Import
http://msdn.microsoft.com/en-us/library/saced6x2.aspx
您可以嵌入任何您想要的自定义"文件,以及诸如 .bmps 之类的内容以及 VisualStudio知道"如何编辑的内容.然后,您可以使用框架的资源函数访问它们,例如 FindResource LoadResource 等...
You can embed any "custom" file you want, as well as things like .bmps and stuff VisualStudio "knows" how to edit. Then you can access them with your framework's resource functions like FindResource LoadResource etc...
如果您没有资源脚本.
- 点击项目
- 添加新项目
- 资源脚本
- Click Project
- Add New Item
- Resource Script
http://msdn.microsoft.com/en-us/library/sxdy04be(v=VS.71).aspx
相关文章