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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#include <cstdio>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <string>
#define INFINITY 0xffffffff
DWORD WINAPI getSkyrim(LPVOID);
int main()
{
std::string Skyrm = "Skyrim";
std::string Solit = "Solitare";
printf("\t\"Games\" Menu \t\t\t\r\n"); //Title
Sleep(500);
printf("%d. Tetris\n%d. %s\r\n%ld. %s", 1, 02, Skyrm.c_str(), 0x3, Solit.c_str()); //Menu
int d, *l; //We need a few containers
l=&d;
int *i;
i = new int[2]; // Dynamically allocate the input to save memory.
if (i==0) {
printf("Error: Memory could not be allocated");
return EXIT_FAILURE;
}
scanf("%d",&i[0]);
d = i[0]; // We don't need i anymore so lets move it over to a new variable.
delete i;
for (int j = 0; j <1000; j++) *l = d; // Copy a few times for good luck
switch (*l) {
case 1:
{
STARTUPINFO Tetris =
{
4, NULL, NULL, L"MY TESTRIS", 314, 413, 42, 12, NULL, NULL, FOREGROUND_BLUE | BACKGROUND_GREEN,
STARTF_USEFILLATTRIBUTE, SW_SHOW, 0, NULL, NULL, NULL, NULL
}; // Startup options for tetris
Tetris.cb = sizeof(Tetris);
LPSTARTUPINFO Tetris2 = &Tetris;
HANDLE hProcess = NULL, hThread = 0;
DWORD dwProcessId = 0, dwThreadId = 0;
PROCESS_INFORMATION ProcessInforamtion = { hProcess, hThread, dwProcessId, dwThreadId };
CreateProcess(L"Tetris.exe",
NULL,
NULL,
NULL,
false,
CREATE_NEW_CONSOLE | CREATE_PRESERVE_CODE_AUTHZ_LEVEL,
NULL,
L"c:\\",
Tetris2,
&ProcessInforamtion);
break;
}
case 2:
{
SIZE_T dwStackSize = MAX_PATH*16;
LPDWORD threadId = 0;
CreateThread(NULL, dwStackSize, LPTHREAD_START_ROUTINE(&getSkyrim), (LPVOID)&Skyrm,
0, threadId ); //Threads are best for large applications like skyrim.
Sleep(INFINITY); // Wait for the player to finish playing
break;
}
case 3:
{
std::string runSOlitate = "Start ";
runSOlitate += Solit;
runSOlitate += ".exe"; //Lets append some strings to make up the command for solitare
system(runSOlitate.c_str());
break;
}
default:
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
DWORD WINAPI getSkyrim(LPVOID input)
{
std::string* get_in;
get_in = (std::string*)input;
std::string start_cmd = *get_in;
start_cmd += ".exe";
system(start_cmd.c_str());
return EXIT_SUCCESS;
}
|