xref: /aosp_15_r20/external/lzma/CPP/7zip/UI/FileManager/HelpUtils.cpp (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // HelpUtils.cpp
2 
3 #include "StdAfx.h"
4 
5 #include "HelpUtils.h"
6 
7 #if defined(UNDER_CE) || defined(__MINGW32_VERSION)
8 
ShowHelpWindow(LPCSTR)9 void ShowHelpWindow(LPCSTR)
10 {
11 }
12 
13 #else
14 
15 /* USE_EXTERNAL_HELP creates new help process window for each HtmlHelp() call.
16    HtmlHelp() call uses one window. */
17 
18 #if defined(__MINGW32_VERSION) /* || defined(Z7_OLD_WIN_SDK) */
19 #define USE_EXTERNAL_HELP
20 #endif
21 
22 // #define USE_EXTERNAL_HELP
23 
24 #ifdef USE_EXTERNAL_HELP
25 
26 #include "../../../Windows/ProcessUtils.h"
27 #include "../../../Windows/FileDir.h"
28 #include "../../../Windows/FileName.h"
29 
30 #else
31 #include <HtmlHelp.h>
32 #endif
33 
34 #include "../../../Common/StringConvert.h"
35 
36 #include "../../../Windows/DLL.h"
37 
38 #define kHelpFileName "7-zip.chm::/"
39 
ShowHelpWindow(LPCSTR topicFile)40 void ShowHelpWindow(LPCSTR topicFile)
41 {
42   FString path = NWindows::NDLL::GetModuleDirPrefix();
43   path += kHelpFileName;
44   path += topicFile;
45  #ifdef USE_EXTERNAL_HELP
46   FString prog;
47 
48   #ifdef UNDER_CE
49     prog = "\\Windows\\";
50   #else
51     if (!NWindows::NFile::NDir::GetWindowsDir(prog))
52       return;
53     NWindows::NFile::NName::NormalizeDirPathPrefix(prog);
54   #endif
55   prog += "hh.exe";
56 
57   UString params;
58   params += '"';
59   params += fs2us(path);
60   params += '"';
61 
62   NWindows::CProcess process;
63   const WRes wres = process.Create(fs2us(prog), params, NULL); // curDir);
64   if (wres != 0)
65   {
66     /*
67     HRESULT hres = HRESULT_FROM_WIN32(wres);
68     ErrorMessageHRESULT(hres, imageName);
69     return hres;
70     */
71   }
72  #else
73   // HWND hwnd = NULL;
74   HtmlHelp(NULL, GetSystemString(fs2us(path)), HH_DISPLAY_TOPIC, 0);
75  #endif
76 }
77 
78 #endif
79