it wouldve been better if C actually was an object-oriented language but i didnt have time to workshop it haha, thankyou everyone for turning a bli..... uh thanks to everyone for not mentioning that! actually Fred can we make my suspension 48hrs instead of 24 lol
btw Omar when youve encrypted a file you can easily embed them directly in your executable, which i guess adds yet another step to make it harder for people to get at as opposed to having them as external files (trickier for them to work out where in your executable the audio file starts and ends):
Code: Select all
MessageRequester("Demo", "The first 2 bytes of the embedded file are: " + PeekS(?MyFile, 2, #PB_Ascii)) ;"MZ" for exes
DataSection
MyFile:
IncludeBinary("c:\windows\notepad.exe") ;ie. your encrypted audio file
EndDataSection
And you're probably aware that PB makes it ridiculously easy to play audio files with LoadSound() and PlaySound(), but you might not yet be aware that PB also has a very nice set of Catch____() API's that are basically like the Load___() ones but work from a memory buffer instead of a file buffer ... this means that you can embed your encrypted audio file directly in your executable with IncludeBinary(), then decrypt it in memory using AESDecoder(), then play the decrypted one from memory using CatchSound(), (and then re-encrypt with AESEncoder() or simply overwrite with nulls if you want to re-protect it) ... all of this without ever writing or otherwise using a file, just the memory buffer of your program, so your audio file is only ever decrypted in memory and never on disk
Also im guessing you'll want your program to continue (respond to GUI events etc) while the audio is playing, to do this you'll of course need to play the audio in a separate thread (create three threads if you want three audios playing simultaneously etc), but again you're in luck because it doesn't get any easier than in PB:
Code: Select all
Procedure MyPlayAudioThread(threadparam)
PlaySound(threadparam) ;threadparam = hSound
EndProcedure
InitSound() ;<-- must call once first to open access to PB's ___Sound() api's
hSound = LoadSound(....) ;(or CatchSound())
CreateThread(@MyPlayAudioThread(), hSound)
;main thread immediately continues...
When using threads its generally recommended to select "Create threadsafe executable" in Compiler -> Options