make .wav not seperated from .exe

Hey guys.


Is it possible to somehow 'merge' the used .wav files into the compiled program?
For example, when I compile my program that have:
PlaySound ("lol.wav",NULL,SND_FILENAME|SND_ASYNC);
Would need the .wav to be inside the same folder in order for the .exe to play the sound. I want the .exe to be 'independent'

Any help appreciated!
Last edited on
Put it inside of resources?
You could write a program that copies the data of a wav file to a text file byte-by-byte with comma's seperating each byte. Then just turn that text file into a CPP file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <fstream>
#include <iostream>
int main(int argc, char* argv[])
{
	char* data;
	std::ifstream wav(argv[1], std::ios::binary);
	std::ofstream cpp(argv[2], std::ios::binary);
	
	std::ifstream::pos_type size = wav.tellg();
	data = new char[size];
	wav.seekg(0, std::ios::beg);
	wav.read(data, size);
	wav.close();
	
	char* header = "char wav[] = {";
	char* footer = "};";
	char* comma = ", ";
	
	cpp.write(header,14);

	for (int i = 0; i < size; i++)
	{
		cpp.write(data++,1);
		cpp.write(comma,1);
	}
	
	cpp.write(footer,2);
	cpp.close();
	
	return 0;
}


This would be a massive cpp file, but it would work and the data would be available when it was compiled.

There's probably a more elegant solution.

EDIT: Use atrium's suggestion below. The solution I just posted is awful in comparison.
Last edited on
Topic archived. No new replies allowed.