cplusplus.com
C++ : Forum : Windows Programming : run a program in background
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs


question run a program in background

twgxslugger (2)
so I want to make a program that plays a random sound when a certain key is hit but I am not sure how to run it in the background so it doesn't have to be in the application itself just as long as its running and I guess hide it as well


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <windows.h>

using namespace std;

int main(){
    string mystring;

    cin>>mystring;
    if (GetKeyState(VK_SHIFT)){
       //play a sound
    }
    system("pause");
    return 0;
}


is just a simple way to think of it but still need to do all of what I stated above
ResidentBiscuit (3169)
Need to make a process I believe
SH4773R (32)
Nope just need to use this nifty code chunk ;)

1
2
3
4
HWND window;
AllocConsole();
window = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(window,0);
twgxslugger (2)
sweet if thats all that is needed ill have this written in no time! I thought I was going to have to thread to make it work
SH4773R (32)
Yup that's all you should need ;) Happy coding!
Last edited on
Topic archived. No new replies allowed.