如何嵌入/链接二进制数据到C ++ DLL [英] How to Embed/Link binary data into a C++ DLL

查看:161
本文介绍了如何嵌入/链接二进制数据到C ++ DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个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?

我看了一些google链接,到目前为止我还没有想出任何东西 - 我想出的唯一可能的解决方案是使用类似 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.

任何建议?

推荐答案


  1. 右键单击资源脚本(.rc文件)
  2. 选择导入
  1. Right click the resource script (.rc file)
  2. Choose Import

http://msdn.microsoft.com/en-us/library/saced6x2.aspx

你可以嵌入你想要的任何自定义文件,以及像.bmps和东西VisualStudio知道如何编辑。然后,您可以使用框架的资源功能访问它们,例如 FindResource LoadResource etc ...

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...

如果您没有资源脚本。


  1. $ b
  2. 添加新项目
  3. 资源脚本
  1. Click Project
  2. Add New Item
  3. Resource Script

http://msdn.microsoft.com/en-us/library/sxdy04be(v = VS.71).aspx

这篇关于如何嵌入/链接二进制数据到C ++ DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆