[commit] r1565 - trunk/GME/Gme

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Fri Sep 30 09:51:15 CDT 2011


Author: ksmyth
Date: Fri Sep 30 09:51:15 2011
New Revision: 1565

Log:
Dont initialize every interpreter dll, just load the dll to get the icon

Modified:
   trunk/GME/Gme/GMEApp.cpp

Modified: trunk/GME/Gme/GMEApp.cpp
==============================================================================
--- trunk/GME/Gme/GMEApp.cpp	Fri Sep 30 09:51:06 2011	(r1564)
+++ trunk/GME/Gme/GMEApp.cpp	Fri Sep 30 09:51:15 2011	(r1565)
@@ -893,31 +893,21 @@
 			HICON hIcon = NULL; //, hictofree = NULL;
 			int commaPos;
 			HMODULE hModule = NULL;
-			CComPtr<IMgaComponent> loadedConmponent; // GetModuleHandle works with loaded DLL only
 			if((commaPos = iconInfo.Find(',')) >= 0)  //Format:   <modulename>,<resourceID>
 			{
 				if(commaPos)  // module name present;
 				{
-					hModule = GetModuleHandle(iconInfo.Left(commaPos));
-					if(!hModule)
-					{
-						loadedConmponent.CoCreateInstance(componentName); // GetModuleHandle works for loaded DLLs only
-						hModule = GetModuleHandle(iconInfo.Left(commaPos));
-					}
+					// XP doesn't support LOAD_LIBRARY_AS_IMAGE_RESOURCE
+					hModule = LoadLibraryEx(iconInfo.Left(commaPos), NULL, LOAD_LIBRARY_AS_DATAFILE);
 				}
 				else // No module name provided,
 				{
-					CString modulePath;
-					registrar->get_LocalDllPath(componentName, PutOut(modulePath));
-					if(modulePath) 
+					_bstr_t modulePath;
+					registrar->get_LocalDllPath(componentName, modulePath.GetAddress());
+					if(modulePath.length() != 0)
 					{
-						hModule = ::GetModuleHandle(modulePath);
-						if(!hModule)
-						{
-							loadedConmponent.CoCreateInstance(componentName); // GetModuleHandle works for loaded DLLs only
-							hModule = ::GetModuleHandle(modulePath);
-							// FIXME: this is more efficient: hModule = LoadLibraryEx(modulePath, NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
-						}
+						// XP doesn't support LOAD_LIBRARY_AS_IMAGE_RESOURCE
+						hModule = LoadLibraryEx(modulePath, NULL, LOAD_LIBRARY_AS_DATAFILE);
 					}
 				}
 			}
@@ -950,6 +940,7 @@
 			CMFCToolBarButton toolBarButton(commandID, nIndex, componentName + '\n' + toolTip, TRUE);
 
 			componentBar.InsertButton(toolBarButton);
+			FreeLibrary(hModule);
 		}
 		if (plugins.GetSize() + interpreters.GetSize() != 0) {
 			componentBar.AdjustLayout();	// CMFCToolBar::AdjustLayout


More information about the gme-commit mailing list