-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.cpp
More file actions
124 lines (98 loc) · 3.38 KB
/
Copy pathhelp.cpp
File metadata and controls
124 lines (98 loc) · 3.38 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
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
///
/// help.cpp:
/// Provides methods for displaying help information.
///
#include "help.h"
#include "macro.h"
#include "utility.h"
#include <string>
#include <htmlhelp.h>
#include <tchar.h>
#include <shlwapi.h>
#include "mdichild.h"
#include <windowsx.h>
void ShowCmdHelpDialog(HWND hwnd)
{
MessageBox(hwnd, (STR("Syntax: \n")
+ STR(" RegPlus.exe [<PATH>] [/go] [/?] [/h] [/help]\n\n")
+ STR("Parameters:\n")
+ STR(" <PATH> The registry path to open. Can include short\n")
+ STR(" root key names (e.g, HKEY_LOCAL_MACHINE\n")
+ STR(" -> HKLM) (optional)\n\n")
+ STR("Options:\n")
+ STR(" /go Open the Go to Key dialog to open RegPlus\n")
+ STR(" directly to a key.\n")
+ STR(" /?, /h, /help Show this help message.")
).c_str(), TEXT("Command-line usage"), MB_ICONINFORMATION);
}
void OpenHelpFile(HWND hwnd, LPCWSTR lpTopic)
{
HMODULE hLib = LoadLibrary(TEXT("hhctrl.ocx"));
if (hLib)
{
typedef HWND(WINAPI* PFN_HtmlHelpW)(
HWND hwndCaller,
LPCWSTR pszFile,
UINT uCommand,
DWORD_PTR dwData
);
PFN_HtmlHelpW pHtmlHelpW = (PFN_HtmlHelpW)GetProcAddress(hLib, "HtmlHelpW");
if (pHtmlHelpW)
{
TCHAR bufExe[MAX_PATH] = TEXT("");
GetModuleFileName(nullptr, bufExe, MAX_PATH);
PathRemoveFileSpec(bufExe);
WCHAR bufChm[MAX_PATH] = L"";
if (lpTopic)
swprintf_s(bufChm, MAX_PATH, TEXT("%s\\help.chm::/%s"), bufExe, lpTopic);
else
swprintf_s(bufChm, MAX_PATH, TEXT("%s\\help.chm"), bufExe);
auto result = pHtmlHelpW(hwnd, bufChm, HH_DISPLAY_TOC, NULL);
if (!result)
{
HH_LAST_ERROR hhle = {};
hhle.cbStruct = sizeof(hhle);
result = pHtmlHelpW(hwnd, NULL, HH_GET_LAST_ERROR, PTR(DWORD_PTR, LPHH_LAST_ERROR, &hhle));
if (result && FAILED(hhle.hr) && hhle.description)
{
TCHAR buffer[256] = TEXT("");
_stprintf_s(buffer, 256, TEXT("Could not display the help contents.\n\n%s"), hhle.description);
MessageBox(hwnd, buffer, NULL, MB_ICONWARNING);
SysFreeString(hhle.description);
}
}
else
{
EnumChildWindows(result, [](HWND hChild, LPARAM lp) -> BOOL CALLBACK {
TCHAR bufClass[256] = TEXT("");
GetClassName(hChild, bufClass, 256);
TCHAR bufText[256] = TEXT("");
GetWindowText(hChild, bufText, 256);
TCHAR bufOut[600] = TEXT("");
_stprintf_s(bufOut, 600, TEXT("Class: %s\nText: %s\n"), bufClass, bufText);
OutputDebugString(bufOut);
if (_tcscmp(bufClass, WC_TREEVIEW) == 0)
{
HMODULE hUxtheme = LoadLibrary(TEXT("Uxtheme.dll"));
if (hUxtheme)
{
PFN_SetWindowTheme SetWindowTheme = (PFN_SetWindowTheme)GetProcAddress(hUxtheme, "SetWindowTheme");
if (SetWindowTheme)
{
SetWindowTheme(hChild, L"Explorer", NULL);
}
FreeLibrary(hUxtheme);
}
//TreeView_SetExtendedStyle(hChild, TVS_EX_FADEINOUTEXPANDOS, TVS_EX_FADEINOUTEXPANDOS);
return FALSE; // stop enumeration
}
return TRUE;
}, NULL);
}
return;
}
FreeLibrary(hLib);
}
MessageBox(hwnd, TEXT("Could not display the help contents. The Compiled HTML Help (CHM) help format is not supported on your operating system.\n\nNOTE: This message should not appear on Windows Vista+! If it does, please report at: http://github.com/fireblade211/regplus/issues/new/choose."),
NULL, MB_ICONWARNING);
}