HWND ShowHelpW(HWND hOwner, WCHAR *help_dir, WCHAR *help_file, WCHAR *section) { if (NULL != strstr(WtoA(help_file), "http")) { //从help_file中发现“http”字符,打开URL //Found "http" in help_file string, open web URL. WCHAR path[MAX_PATH]; MakePathW(path, L"", help_file); if (section) wcscpy(path + wcslen(path), section); ::ShellExecuteW(NULL, NULL, path, NULL, NULL, SW_SHOW); return NULL; } else { //从help_file中未发现“http”字符,打开chm //Not found "http" in help_file string, open chm file. #if defined(ENABLE_HTML_HELP) if (!pHtmlHelpW) InitHtmlHelp(); if (pHtmlHelpW) { WCHAR path[MAX_PATH]; MakePathW(path, help_dir, help_file); if (section) wcscpy(path + wcslen(path), section); return pHtmlHelpW(hOwner, path, HH_HELP_FINDER, 0); } #endif return NULL; } }
HWND CloseHelpAll() { #if defined(ENABLE_HTML_HELP) if (!pHtmlHelpW) return NULL; return pHtmlHelpW(0, 0, HH_CLOSE_ALL, 0); #else return NULL; #endif }
BOOL InitHtmlHelpCore() { DWORD cookie=0; HMODULE hHtmlHelp = TLoadLibrary("hhctrl.ocx"); if (hHtmlHelp) pHtmlHelpW = (HWND (WINAPI *)(HWND, WCHAR *, UINT, DWORD_PTR)) ::GetProcAddress(hHtmlHelp, "HtmlHelpW"); if (pHtmlHelpW) pHtmlHelpW(NULL, NULL, HH_INITIALIZE, (DWORD)&cookie); return pHtmlHelpW ? TRUE : FALSE;; }
/* * supShowHelp * * Purpose: * * Display help file if available. * */ VOID supShowHelp( VOID ) { DWORD dwSize; HKEY hKey; LRESULT lRet; HANDLE hHtmlOcx; WCHAR szOcxPath[MAX_PATH + 1]; WCHAR szHelpFile[MAX_PATH * 2]; RtlSecureZeroMemory(&szOcxPath, sizeof(szOcxPath)); RtlSecureZeroMemory(szHelpFile, sizeof(szHelpFile)); lRet = RegOpenKeyEx(HKEY_CLASSES_ROOT, HHCTRLOCXKEY, 0, KEY_QUERY_VALUE, &hKey); if (lRet == ERROR_SUCCESS) { dwSize = MAX_PATH * sizeof(WCHAR); lRet = RegQueryValueEx(hKey, L"", NULL, NULL, (LPBYTE)szHelpFile, &dwSize); RegCloseKey(hKey); if (lRet == ERROR_SUCCESS) { if (ExpandEnvironmentStrings(szHelpFile, szOcxPath, MAX_PATH) == 0) { lRet = ERROR_SECRET_TOO_LONG; } } } if (lRet != ERROR_SUCCESS) { _strcpy(szOcxPath, HHCTRLOCX); } RtlSecureZeroMemory(szHelpFile, sizeof(szHelpFile)); if (!GetCurrentDirectory(MAX_PATH, szHelpFile)) { return; } _strcat(szHelpFile, L"\\winobjex64.chm"); hHtmlOcx = GetModuleHandle(HHCTRLOCX); if (hHtmlOcx == NULL) { hHtmlOcx = LoadLibrary(szOcxPath); if (hHtmlOcx == NULL) { return; } } if (pHtmlHelpW == NULL) { pHtmlHelpW = (pfnHtmlHelpW)GetProcAddress(hHtmlOcx, MAKEINTRESOURCEA(0xF)); if (pHtmlHelpW == NULL) { return; } } pHtmlHelpW(GetDesktopWindow(), szHelpFile, 0, 0); }