Hans Leidekker : hhctrl.ocx: Try the Windows help directory if the specified file does not exist.

Alexandre Julliard julliard at winehq.org
Wed Jul 1 09:28:11 CDT 2009


Module: wine
Branch: master
Commit: bbfe59bc93738e95208d215800d716e4b3594794
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bbfe59bc93738e95208d215800d716e4b3594794

Author: Hans Leidekker <hans at meelstraat.net>
Date:   Wed Jul  1 11:54:44 2009 +0200

hhctrl.ocx: Try the Windows help directory if the specified file does not exist.

---

 dlls/hhctrl.ocx/chm.c    |    9 +++++----
 dlls/hhctrl.ocx/hhctrl.c |   32 ++++++++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/dlls/hhctrl.ocx/chm.c b/dlls/hhctrl.ocx/chm.c
index dbf174d..c3a7499 100644
--- a/dlls/hhctrl.ocx/chm.c
+++ b/dlls/hhctrl.ocx/chm.c
@@ -362,15 +362,16 @@ IStream *GetChmStream(CHMInfo *info, LPCWSTR parent_chm, ChmPath *chm_file)
 /* Opens the CHM file for reading */
 CHMInfo *OpenCHM(LPCWSTR szFile)
 {
-    WCHAR file[MAX_PATH] = {0};
     HRESULT hres;
+    CHMInfo *ret;
 
     static const WCHAR wszSTRINGS[] = {'#','S','T','R','I','N','G','S',0};
 
-    CHMInfo *ret = heap_alloc_zero(sizeof(CHMInfo));
+    if (!(ret = heap_alloc_zero(sizeof(CHMInfo))))
+        return NULL;
 
-    GetFullPathNameW(szFile, sizeof(file)/sizeof(file[0]), file, NULL);
-    ret->szFile = strdupW(file);
+    if (!(ret->szFile = strdupW(szFile)))
+        return NULL;
 
     hres = CoCreateInstance(&CLSID_ITStorage, NULL, CLSCTX_INPROC_SERVER,
             &IID_IITStorage, (void **) &ret->pITStorage) ;
diff --git a/dlls/hhctrl.ocx/hhctrl.c b/dlls/hhctrl.ocx/hhctrl.c
index 10e04bc..8268a21 100644
--- a/dlls/hhctrl.ocx/hhctrl.c
+++ b/dlls/hhctrl.ocx/hhctrl.c
@@ -86,11 +86,27 @@ static const char *command_to_string(UINT command)
 #undef X
 }
 
+static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD buflen)
+{
+    static const WCHAR helpW[] = {'\\','h','e','l','p','\\',0};
+
+    GetFullPathNameW(filename, buflen, fullname, NULL);
+    if (GetFileAttributesW(fullname) == INVALID_FILE_ATTRIBUTES)
+    {
+        GetWindowsDirectoryW(fullname, buflen);
+        strcatW(fullname, helpW);
+        strcatW(fullname, filename);
+    }
+    return (GetFileAttributesW(fullname) != INVALID_FILE_ATTRIBUTES);
+}
+
 /******************************************************************
  *		HtmlHelpW (HHCTRL.OCX.15)
  */
 HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR data)
 {
+    WCHAR fullname[MAX_PATH];
+
     TRACE("(%p, %s, command=%s, data=%lx)\n",
           caller, debugstr_w( filename ),
           command_to_string( command ), data);
@@ -120,7 +136,13 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
             index += 2; /* advance beyond "::" for calling NavigateToChm() later */
         }
 
-        info = CreateHelpViewer(filename);
+        if (!resolve_filename(filename, fullname, MAX_PATH))
+        {
+            WARN("can't find %s\n", debugstr_w(filename));
+            return 0;
+        }
+
+        info = CreateHelpViewer(fullname);
         if(!info)
             return NULL;
 
@@ -142,7 +164,13 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
         if (!filename)
             return NULL;
 
-        info = CreateHelpViewer(filename);
+        if (!resolve_filename(filename, fullname, MAX_PATH))
+        {
+            WARN("can't find %s\n", debugstr_w(filename));
+            return 0;
+        }
+
+        info = CreateHelpViewer(fullname);
         if(!info)
             return NULL;
 




More information about the wine-cvs mailing list