Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
7.9 KiB

  1. // Simple module for using MLLoadLibrary().
  2. // This cannot be merged with shared.cpp, because it uses shlwapi.h. which conflict with
  3. // come constant in shared.h
  4. // Created: 07/08/98 by YST
  5. #include "pch.hxx"
  6. #include <shlwapi.h>
  7. #include <shlwapip.h>
  8. #include "htmlhelp.h"
  9. #include "shared.h"
  10. #include "htmlhelp.h"
  11. #include <demand.h>
  12. typedef HINSTANCE (STDAPICALLTYPE *PFNMLLOADLIBARY)(LPCSTR lpLibFileName, HMODULE hModule, DWORD dwCrossCodePage);
  13. typedef int (STDAPICALLTYPE *PFNMLWINHELP)(HWND hWndCaller, LPCSTR lpszHelp, UINT uCommand, DWORD_PTR dwData);
  14. typedef HWND (STDAPICALLTYPE *PFNMLHTMLHELP)(HWND hWndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData, DWORD dwCrossCodePage);
  15. static const char c_szShlwapiDll[] = "shlwapi.dll";
  16. static const char c_szDllGetVersion[] = "DllGetVersion";
  17. static PFNMLWINHELP pfnWinHelp = NULL;
  18. static PFNMLHTMLHELP pfnHtmlHelp = NULL;
  19. static BOOL fWinHelChecked = FALSE;
  20. static BOOL fHtmlHelpChecked = FALSE;
  21. static BOOL fNT5 = FALSE;
  22. const OENONSTDCP OENonStdCPs[] =
  23. {
  24. // CodePage Read ReadMenu Title SendMenu SmSend Use SIO
  25. 50001, 50001, 50001, 0, 0, 0, 0, // General Autoselect
  26. 50932, 50932, 50932, 0, 0, 50220, 0, // Japanice Auto Select
  27. 50949, 50949, 50949, 949, 0, /*51*/949, 0, // Korean Auto Select
  28. // 50939, 50939, 50939, 0, 0, 0, 0, // Chinese Auto Select
  29. 51932, 51932, 51932, 0, 0, 50220, 0, // Japanice EUC
  30. 932, 932, 932, 0, 0, 50220, 0, // Japanice Shift-JIS
  31. 50225, 50225, 50225, 949, 0, 949, 0, // Korean ISO-2022-KR
  32. 50220, 50932, 0, 0, 50220, 50220, 0, // Japanice JIS
  33. 51949, 50949, 0, 949, 51949, 51949, 0, // Korean
  34. 949, 50949, 0, 0, 949, 949, 0, // Korean Windows
  35. 50221, 50932, 50932, 0, 0, 50220, 1, // Esc(I ISO-2022-JP
  36. 50222, 50932, 50932, 0, 0, 50220, 2, // Esc(J ISO-2022-JP
  37. 28598, 28598, 28598, 0, 0, 28598, 0, // Hebrew visual
  38. // 1255, 1255, 1255, 0, 0, 1255, 0, // Hebrew Windows
  39. 20127, 28591, 0, 0, 0, 28591, 0, // US-ASCII
  40. 862, 862, 862, 0, 0, 862, 0, // Hebrew OEM (DOS)
  41. 0, 0, 0, 0, 0, 0
  42. };
  43. HINSTANCE LoadLangDll(HINSTANCE hInstCaller, LPCSTR szDllName, BOOL fNT)
  44. {
  45. char szPath[MAX_PATH];
  46. HINSTANCE hinstShlwapi;
  47. PFNMLLOADLIBARY pfn;
  48. DLLGETVERSIONPROC pfnVersion;
  49. int iEnd;
  50. DLLVERSIONINFO info;
  51. HINSTANCE hInst = NULL;
  52. hinstShlwapi = LoadLibrary(c_szShlwapiDll);
  53. if (hinstShlwapi != NULL)
  54. {
  55. pfnVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstShlwapi, c_szDllGetVersion);
  56. if (pfnVersion != NULL)
  57. {
  58. info.cbSize = sizeof(DLLVERSIONINFO);
  59. if (SUCCEEDED(pfnVersion(&info)))
  60. {
  61. if (info.dwMajorVersion >= 5)
  62. {
  63. pfn = (PFNMLLOADLIBARY)GetProcAddress(hinstShlwapi, MAKEINTRESOURCE(377));
  64. if (pfn != NULL)
  65. hInst = pfn(szDllName, hInstCaller, (ML_NO_CROSSCODEPAGE));
  66. }
  67. }
  68. }
  69. FreeLibrary(hinstShlwapi);
  70. }
  71. if ((NULL == hInst) && (GetModuleFileName(hInstCaller, szPath, ARRAYSIZE(szPath))))
  72. {
  73. PathRemoveFileSpec(szPath);
  74. iEnd = lstrlen(szPath);
  75. szPath[iEnd++] = '\\';
  76. lstrcpyn(&szPath[iEnd], szDllName, ARRAYSIZE(szPath)-iEnd);
  77. hInst = LoadLibrary(szPath);
  78. }
  79. AssertSz(hInst, "Failed to LoadLibrary Lang Dll");
  80. return(hInst);
  81. }
  82. // Get system architecture and OS version
  83. BOOL GetPCAndOSTypes(SYSTEM_INFO * pSysInf, OSVERSIONINFO * pOsInf)
  84. {
  85. GetSystemInfo(pSysInf);
  86. pOsInf->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  87. return(GetVersionEx(pOsInf));
  88. }
  89. // PlugUI version of WinHelp
  90. BOOL OEWinHelp(HWND hWndCaller, LPCSTR lpszHelp, UINT uCommand, DWORD_PTR dwData)
  91. {
  92. if(!pfnWinHelp)
  93. {
  94. if(!fWinHelChecked)
  95. {
  96. HINSTANCE hinstShlwapi;
  97. PFNMLLOADLIBARY pfn;
  98. DLLGETVERSIONPROC pfnVersion;
  99. int iEnd;
  100. DLLVERSIONINFO info;
  101. HINSTANCE hInst = NULL;
  102. hinstShlwapi = DemandLoadShlWapi();
  103. // hinstShlwapi = LoadLibrary(c_szShlwapiDll);
  104. if (hinstShlwapi != NULL)
  105. {
  106. pfnVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstShlwapi, c_szDllGetVersion);
  107. if (pfnVersion != NULL)
  108. {
  109. info.cbSize = sizeof(DLLVERSIONINFO);
  110. if (SUCCEEDED(pfnVersion(&info)))
  111. {
  112. if (info.dwMajorVersion >= 5)
  113. {
  114. // 395 is ordinal # fot MLWinHelp
  115. pfnWinHelp = (PFNMLWINHELP)GetProcAddress(hinstShlwapi, MAKEINTRESOURCE(395));
  116. }
  117. }
  118. }
  119. // FreeLibrary(hinstShlwapi);
  120. }
  121. fWinHelChecked = TRUE;
  122. }
  123. if(pfnWinHelp)
  124. return(pfnWinHelp(hWndCaller, lpszHelp, uCommand, dwData));
  125. else
  126. return(WinHelp(hWndCaller, lpszHelp, uCommand, dwData));
  127. }
  128. else
  129. return(pfnWinHelp(hWndCaller, lpszHelp, uCommand, dwData));
  130. }
  131. // PlugUI version of HtmlHelp
  132. HWND OEHtmlHelp(HWND hWndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData)
  133. {
  134. if(!pfnHtmlHelp)
  135. {
  136. if(!fHtmlHelpChecked)
  137. {
  138. HINSTANCE hinstShlwapi;
  139. PFNMLLOADLIBARY pfn;
  140. DLLGETVERSIONPROC pfnVersion;
  141. int iEnd;
  142. DLLVERSIONINFO info;
  143. HINSTANCE hInst = NULL;
  144. hinstShlwapi = DemandLoadShlWapi();
  145. // hinstShlwapi = LoadLibrary(c_szShlwapiDll);
  146. if (hinstShlwapi != NULL)
  147. {
  148. pfnVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstShlwapi, c_szDllGetVersion);
  149. if (pfnVersion != NULL)
  150. {
  151. info.cbSize = sizeof(DLLVERSIONINFO);
  152. if (SUCCEEDED(pfnVersion(&info)))
  153. {
  154. if (info.dwMajorVersion >= 5)
  155. {
  156. // 396 is ordinal # fot MLHTMLHelp
  157. pfnHtmlHelp = (PFNMLHTMLHELP)GetProcAddress(hinstShlwapi, MAKEINTRESOURCE(396));
  158. if(!fNT5)
  159. {
  160. OSVERSIONINFO OSInfo;
  161. OSInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  162. GetVersionEx(&OSInfo);
  163. if((OSInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && (OSInfo.dwMajorVersion >= 5))
  164. fNT5 = TRUE;
  165. }
  166. }
  167. }
  168. }
  169. // FreeLibrary(hinstShlwapi);
  170. }
  171. fHtmlHelpChecked = TRUE;
  172. }
  173. if(pfnHtmlHelp)
  174. return(pfnHtmlHelp(hWndCaller, pszFile, uCommand, dwData, fNT5 ? ML_CROSSCODEPAGE_NT : ML_NO_CROSSCODEPAGE));
  175. else
  176. return(HtmlHelp(hWndCaller, pszFile, uCommand, dwData));
  177. }
  178. else
  179. return(pfnHtmlHelp(hWndCaller, pszFile, uCommand, dwData, fNT5 ? ML_CROSSCODEPAGE_NT : ML_NO_CROSSCODEPAGE));
  180. }