Hi I need help with a project im working on im wondering if there is a way to include a file in a program. Im making a prank program that hides in the background and plays a funny wav file. Is there a way to include the wav file in the .exe so i dont have to put 2 files on his system? here is the source to my program

#include <windows.h>
#include <mmsystem.h>
#include <conio.h>
#include <winuser.h>
#include <iostream>

using namespace std;

int main()
{
    system("color 0c");
    system("ftype");
    
    PlaySound("C:\\crash.wav",NULL,SND_FILENAME|SND_ASYNC);
    
    SetConsoleTitle("csrsss.exe");
    HWND window = FindWindow(NULL,"csrsss.exe");
    ShowWindow(window,SW_HIDE);
    
    getch();
    return 0;
}

you don't have to do line 16 and 17. GetConsoleWindow() will return the HWND handle of the console program.

line 20: getch is not such a good idea in this program because there is no way for the program to terminate unless the user KNOWS that it is looking for keyboard input.

Okay thanks that reduced the file size :) which means that it wont look as suspicious in the processes tab in the taskman but how do I include crash.wav file with the .exe so i dont need to put 2 files on his computer?

Without getch(); it closes immediately and doesnt play the wave file. I need to keep the program open till the wave file stops playing.

So use cin.get() after a prompt that states "Press RETURN to end"

Or if you know how long it takes for the music to play then you sould just call Sleep() for that many milliseconds.

K thanks. Any idea on how to include the wav file with the exe? If I put the wav file in the project can I call it by just doing PlaySound("crash.wav",NULL,SND_FILENAME|SND_ASYNC);?

More information here and here. You can also read through some of these google links.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.