简体   繁体   English

向exe添加资源(声音文件)? [MS Visual Studio 2012]

[英]Add resources (sound files) to exe? [MS Visual Studio 2012]

I currently have a "data" folder from which I load the .wav sound files that I use in my application. 我目前有一个“数据”文件夹,从中可以加载在应用程序中使用的.wav声音文件。 I load them like this 我像这样加载它们

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

Is is possible to somehow integrate all those sound files into my .exe so I don't have to distribute them additionally? 是否可以将所有这些声音文件集成到我的.exe中,这样我就不必额外分发它们了? Kind of like statically linking libraries instead of dynamically so there's no need to provide them as separate dlls (I do that already). 有点像静态链接库而不是动态链接库,因此不需要将它们作为单独的dll提供(我已经这样做了)。 Is it possible and if yes, how would I load them then? 是否可以,如果可以,我该如何加载它们?

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! 我已经考虑过转换声音文件,然后将其硬编码为char数组并从内存中加载它们,但是如果将它们添加到exe文件中,则我不必这样做,这样会更加方便! Thanks ~ 谢谢〜

Add the files to your project as resources, then you can use functions such as LoadResource to use them. 将文件作为资源添加到项目中,然后可以使用诸如LoadResource之类的功能来使用它们。 The sound files would be built into your exe image. 声音文件将内置到您的exe映像中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM