-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
75 lines (55 loc) · 1.84 KB
/
main.cpp
File metadata and controls
75 lines (55 loc) · 1.84 KB
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
#include <iostream>
#include <Windows.h>
#include <string>
#include <Shlobj.h>
#include <stdio.h>
#include "main.h"
#include <shellapi.h>
#pragma comment(lib, "shell32.lib")
int main() {
char currentDir[MAX_PATH];
std::string InputPath;
SetConsoleTitleA("Discord BloatWare game emulator");
std::cout << "Please enter the full path of the game (like 'common\\Destiny 2\\destiny2.exe'): " << std::endl;
std::getline(std::cin, InputPath);
for (int i = 0; i < InputPath.length(); i++) {
if (InputPath[i] == '/') {
InputPath[i] = '\\';
}
}
std::vector<std::string> x = split(InputPath, "\\");
if (x.empty()) return 1;
GetCurrentDirectoryA(MAX_PATH, currentDir);
// get path
std::string folderPath = std::string(currentDir);
for (size_t i = 0; i < x.size() - 1; i++) {
folderPath += "\\" + x[i];
}
std::cout << "Creating Folders: " << folderPath << std::endl;
int result = SHCreateDirectoryExA(NULL, folderPath.c_str(), NULL);
if (result == ERROR_SUCCESS || result == ERROR_ALREADY_EXISTS) {
std::cout << "Folder structure verified!" << std::endl;
}
else {
std::cout << "Folder creation failed, Code: " << result << std::endl;
}
std::string app = x[x.size() - 1];
if (app.size() > 4) {
app = app.substr(0, app.size() - 4); //removes .exe
}
std::string createdFile = CreateEmulatorExe(folderPath, app);
if (!createdFile.empty()) {
std::cout << "Opening emulator..." << std::endl;
ShellExecuteA(
NULL,
"open",
createdFile.c_str(),
NULL,
NULL,
SW_SHOW
);
}
std::cout << "Done! Press Enter to exit.";
std::cin.get();
return 0;
}