forked from xz00311/AutoEye
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoEyeMenu.cpp
206 lines (162 loc) · 4.78 KB
/
AutoEyeMenu.cpp
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// AutoEyeDlg.cpp : 实现文件
//
#include "pch.h"
#include "AutoEye.h"
#include "AutoEyeDlg.h"
#include "Registry.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define FOLDER_SHELL_PATH _T("Folder\\Shell\\")
#define SHELL_SUB_PATH _T("\\Shell\\")
#define SHELL_COMMAND _T("\\command")
BOOL CAutoEyeDlg::WinIntegrated(CString strRegName, CString strMenuName, CString strCmdFile)
{
BOOL bRet = FALSE;
do
{
CRegistry regInfo(HKEY_CLASSES_ROOT);
if (!regInfo.VerifyKey(FOLDER_SHELL_PATH + strRegName))
{
if (!regInfo.CreateKey(FOLDER_SHELL_PATH + strRegName))
{
break;
}
}
if (!regInfo.Write(_T(""), strMenuName))
{
break;
}
if (!regInfo.VerifyKey(FOLDER_SHELL_PATH + strRegName + SHELL_COMMAND))
{
if (!regInfo.CreateKey(FOLDER_SHELL_PATH + strRegName + SHELL_COMMAND))
{
break;
}
}
CString strRegCommand = _T("\"") + strCmdFile + _T("\"") + _T(" \"") + _T("%1") + _T("\"");
if (!regInfo.Write(_T(""), strRegCommand))
{
break;
}
bRet = TRUE;
} while (FALSE);
return bRet;
}
BOOL CAutoEyeDlg::WinIntegrated(CString strRegName, CString strMenuName, CString strCmdFile, CString strFileExt, CString strFileTypeDetail)
{
BOOL bRet = FALSE;
do
{
CString strRegKey;
CRegistry regInfo(HKEY_CLASSES_ROOT);
if (!regInfo.VerifyKey(_T(".") + strFileExt))
{
if (!regInfo.CreateKey(_T(".") + strFileExt))
{
break;
}
if (!regInfo.Write(_T(""), strFileTypeDetail))
{
break;
}
strRegKey = strFileTypeDetail;
}
else
{
if (!regInfo.Read(_T(""), strRegKey))
{
break;
}
}
if (!regInfo.VerifyKey(strRegKey + SHELL_SUB_PATH + strRegName))
{
if (!regInfo.CreateKey(strRegKey + SHELL_SUB_PATH + strRegName))
{
break;
}
}
if (!regInfo.Write(_T(""), strMenuName))
{
break;
}
if (!regInfo.VerifyKey(strRegKey + SHELL_SUB_PATH + strRegName + SHELL_COMMAND))
{
if (!regInfo.CreateKey(strRegKey + SHELL_SUB_PATH + strRegName + SHELL_COMMAND))
{
break;
}
}
CString strRegCommand = _T("\"") + strCmdFile + _T("\"") + _T(" \"") + _T("%1") + _T("\"");
if (!regInfo.Write(_T(""), strRegCommand))
{
break;
}
bRet = TRUE;
} while (FALSE);
return bRet;
}
CString CAutoEyeDlg::GetAppFullName()
{
TCHAR szPath[MAX_PATH] = {};
GetModuleFileName(GetModuleHandle(NULL), szPath, _countof(szPath) - 1);
return CString(szPath);
}
BOOL CAutoEyeDlg::UnWinIntegrated(CString strRegName)
{
LSTATUS status = SHDeleteKey(HKEY_CLASSES_ROOT, FOLDER_SHELL_PATH + strRegName);
return (status == ERROR_SUCCESS);
}
BOOL CAutoEyeDlg::UnWinIntegrated(CString strRegName, CString strFileExt)
{
BOOL bRet = FALSE;
CRegistry regInfo(HKEY_CLASSES_ROOT);
do
{
if (!regInfo.VerifyKey(_T(".") + strFileExt))
{
break;
}
CString strRegKey;
if (!regInfo.Read(_T(""), strRegKey))
{
break;
}
LSTATUS status = SHDeleteKey(HKEY_CLASSES_ROOT, strRegKey + SHELL_SUB_PATH + strRegName);
if (status != ERROR_SUCCESS)
{
break;
}
bRet = TRUE;
} while (FALSE);
return bRet;
}
BOOL CAutoEyeDlg::CheckInterStatus()
{
BOOL bFolderIntegrated = FALSE;
BOOL bExeIntegrated = FALSE;
BOOL bA3XIntegrated = FALSE;
// check for directory
CRegistry regInfo(HKEY_CLASSES_ROOT);
CString strAutoDecPath = _T("Autoit3 PATH Decompiler");
bFolderIntegrated = regInfo.VerifyKey(FOLDER_SHELL_PATH + strAutoDecPath + SHELL_COMMAND);
// check for *.exe
if (regInfo.VerifyKey(_T(".exe")))
{
CString strRegKey;
regInfo.Read(_T(""), strRegKey);
CString strAutoDecEXE = _T("Autoit3 EXE Decompiler");
bExeIntegrated = regInfo.VerifyKey(strRegKey + SHELL_SUB_PATH + strAutoDecEXE + SHELL_COMMAND);
strRegKey.Empty();
}
// check for *.a3x
if (regInfo.VerifyKey(_T(".a3x")))
{
CString strRegKey;
regInfo.Read(_T(""), strRegKey);
CString strAutoDecA3X = _T("Autoit3 A3X Decompiler");
bA3XIntegrated = regInfo.VerifyKey(strRegKey + SHELL_SUB_PATH + strAutoDecA3X + SHELL_COMMAND);
}
return (bExeIntegrated && bA3XIntegrated && bFolderIntegrated);
}