+// utility functions to manage the loading/unloading
+// of hhctrl.ocx
+#ifndef UNICODE
+typedef HWND ( WINAPI * HTMLHELP )( HWND, LPCSTR, UINT, DWORD );
+#define HTMLHELP_NAME "HtmlHelpA"
+#else
+typedef HWND ( WINAPI * HTMLHELP )( HWND, LPCWSTR, UINT, DWORD );
+#define HTMLHELP_NAME "HtmlHelpW"
+#endif
+// dll handle/reference count
+static HTMLHELP gs_htmlHelp = 0;
+static wxDllType gs_dllHandle = 0;
+static int gs_dllCount = 0;
+
+static bool LoadHtmlHelpLibrary()
+{
+ if( !gs_dllCount )
+ {
+ gs_dllHandle = wxDllLoader::LoadLibrary( "hhctrl.ocx" );
+ if( !gs_dllHandle )
+ {
+ wxLogError(_("MS HTML Help functions are unavailable because the MS HTML Help library is not installed on this machine. Please install it."));
+ return FALSE;
+ }
+ else
+ {
+ gs_dllCount = 1;
+ gs_htmlHelp = (HTMLHELP)wxDllLoader::GetSymbol( gs_dllHandle, HTMLHELP_NAME );
+
+ if( !gs_htmlHelp )
+ {
+ wxLogError(_("Failed to initialize MS HTML Help."));
+
+ wxDllLoader::UnloadLibrary(gs_dllHandle);
+ gs_dllHandle = 0;
+ gs_dllCount = 0;
+
+ return FALSE ;
+ }
+ }
+ }
+ else
+ {
+ ++gs_dllCount;
+ }
+
+ return TRUE;
+}
+
+static void UnloadHtmlHelpLibrary()
+{
+ if( gs_dllCount != 0 && !--gs_dllCount )
+ {
+ wxDllLoader::UnloadLibrary( gs_dllHandle );
+ gs_dllHandle = 0;
+ gs_htmlHelp = 0;
+ }
+}
+