将资源(声音文件)添加到exe?[MS Visual Studio 2012] [英] Add resources (sound files) to exe? [MS Visual Studio 2012]

查看:78
本文介绍了将资源(声音文件)添加到exe?[MS Visual Studio 2012]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个data"文件夹,我从中加载了我在应用程序中使用的 .wav 声音文件.我像这样加载它们

I currently have a "data" folder from which I load the .wav sound files that I use in my application. I load them like this

sf::Soundbuffer ss;
ss.loadFromFile("./data/sfx/sound.wav")

是否可以以某种方式将所有这些声音文件集成到我的 .exe 中,这样我就不必另外分发它们?有点像静态链接库而不是动态链接,因此无需将它们作为单独的 dll 提供(我已经这样做了).是否可能?如果是,我将如何加载它们?

Is is possible to somehow integrate all those sound files into my .exe so I don't have to distribute them additionally? Kind of like statically linking libraries instead of dynamically so there's no need to provide them as separate dlls (I do that already). Is it possible and if yes, how would I load them then?

我已经考虑过转换声音文件,然后将它们硬编码到一个字符数组中并从内存中加载它们,但是如果将它们添加到 exe 工作中,我不必这样做,而且会更方便!谢谢~

I already thought about converting the sound files and then hardcoding them in a char array and load them from memory, but if adding them to the exe works I don't have to do that and it would be much more convenient! Thanks ~

推荐答案

将文件作为资源添加到您的项目中,然后您就可以使用诸如 LoadResource 来使用它们.声音文件将内置到您的 exe 映像中.

Add the files to your project as resources, then you can use functions such as LoadResource to use them. The sound files would be built into your exe image.

这篇关于将资源(声音文件)添加到exe?[MS Visual Studio 2012]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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