2 * winhelp.c: centralised functions to launch Windows help files,
\r
3 * and to decide whether to use .HLP or .CHM help in any given
\r
15 #include <htmlhelp.h>
\r
16 #endif /* NO_HTMLHELP */
\r
18 static int requested_help;
\r
19 static char *help_path;
\r
20 static int help_has_contents;
\r
22 DECL_WINDOWS_FUNCTION(static, HWND, HtmlHelpA, (HWND, LPCSTR, UINT, DWORD));
\r
23 static char *chm_path;
\r
24 #endif /* NO_HTMLHELP */
\r
26 void init_help(void)
\r
28 char b[2048], *p, *q, *r;
\r
31 GetModuleFileName(NULL, b, sizeof(b) - 1);
\r
33 p = strrchr(b, '\\');
\r
34 if (p && p >= r) r = p+1;
\r
35 q = strrchr(b, ':');
\r
36 if (q && q >= r) r = q+1;
\r
37 strcpy(r, PUTTY_HELP_FILE);
\r
38 if ( (fp = fopen(b, "r")) != NULL) {
\r
39 help_path = dupstr(b);
\r
43 strcpy(r, PUTTY_HELP_CONTENTS);
\r
44 if ( (fp = fopen(b, "r")) != NULL) {
\r
45 help_has_contents = TRUE;
\r
48 help_has_contents = FALSE;
\r
51 strcpy(r, PUTTY_CHM_FILE);
\r
52 if ( (fp = fopen(b, "r")) != NULL) {
\r
53 chm_path = dupstr(b);
\r
58 HINSTANCE dllHH = load_system32_dll("hhctrl.ocx");
\r
59 GET_WINDOWS_FUNCTION(dllHH, HtmlHelpA);
\r
66 #endif /* NO_HTMLHELP */
\r
69 void shutdown_help(void)
\r
71 /* Nothing to do currently.
\r
72 * (If we were running HTML Help single-threaded, this is where we'd
\r
73 * call HH_UNINITIALIZE.) */
\r
79 * FIXME: it would be nice here to disregard help_path on
\r
80 * platforms that didn't have WINHLP32. But that's probably
\r
81 * unrealistic, since even Vista will have it if the user
\r
82 * specifically downloads it.
\r
87 #endif /* NO_HTMLHELP */
\r
91 void launch_help(HWND hwnd, const char *topic)
\r
94 int colonpos = strcspn(topic, ":");
\r
99 assert(topic[colonpos] != '\0');
\r
100 fname = dupprintf("%s::/%s.html>main", chm_path,
\r
101 topic + colonpos + 1);
\r
102 p_HtmlHelpA(hwnd, fname, HH_DISPLAY_TOPIC, 0);
\r
105 #endif /* NO_HTMLHELP */
\r
107 char *cmd = dupprintf("JI(`',`%.*s')", colonpos, topic);
\r
108 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
\r
112 #ifndef NO_HTMLHELP
\r
114 p_HtmlHelpA(hwnd, chm_path, HH_DISPLAY_TOPIC, 0);
\r
116 #endif /* NO_HTMLHELP */
\r
118 WinHelp(hwnd, help_path,
\r
119 help_has_contents ? HELP_FINDER : HELP_CONTENTS, 0);
\r
122 requested_help = TRUE;
\r
125 void quit_help(HWND hwnd)
\r
127 if (requested_help) {
\r
128 #ifndef NO_HTMLHELP
\r
130 p_HtmlHelpA(NULL, NULL, HH_CLOSE_ALL, 0);
\r
132 #endif /* NO_HTMLHELP */
\r
134 WinHelp(hwnd, help_path, HELP_QUIT, 0);
\r
136 requested_help = FALSE;
\r