如何将二进制数据嵌入/链接到 Windows 模块中

How to Embed/Link binary data into a Windows module(如何将二进制数据嵌入/链接到 Windows 模块中)

本文介绍了如何将二进制数据嵌入/链接到 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.

有什么建议吗?

推荐答案

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

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. 点击项目
  2. 添加新项目
  3. 资源脚本
  1. Click Project
  2. Add New Item
  3. Resource Script

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

这篇关于如何将二进制数据嵌入/链接到 Windows 模块中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何将二进制数据嵌入/链接到 Windows 模块中

基础教程推荐