简体   繁体   中英

How to get HMODULE from COM object that it reside?

I want to determine the version of DLL that implemented Microsoft Web Browser Control . The way I need to go is query DLLVERSIONINFO from implemented DLL through DllGetVersion function; because I think it is the most stable way. But, I don't known how to get HMODULE of implemented DLL from Microsoft Web Browser Control object.

How can I get the HMODULE of implemented DLL? Or there is other way to determine its version with stability?

Thanks for advance.

You can read Internet Explorer COM Object's server from the registry (ususally, it will be hosted by shdocvw.dll or ieframe.dll in more recent versions), and load it manually, something like this:

TCHAR key[MAX_PATH];
// read CLSID_InternetExplorer COM Server path
SHRegGetPath(HKEY_CLASSES_ROOT, _T("CLSID\\{8856F961-340A-11D0-A96B-00C04FD705A2}\\InProcServer32"), NULL, key, 0);
HINSTANCE hInstance = LoadLibrary(PathFindFileName(key));
if (hInstance)
{
    DLLGETVERSIONPROC fn = (DLLGETVERSIONPROC)GetProcAddress(hInstance, "DllGetVersion");
    if (fn)
    {
        DLLVERSIONINFO2 version;
        ZeroMemory(&version, sizeof(DLLVERSIONINFO2));
        version.info1.cbSize = sizeof(DLLVERSIONINFO2);
        (*fn)((DLLVERSIONINFO*)&version);

        printf("Major:%u\n", version.ullVersion >> 48);
        printf("Minor:%u\n", (version.ullVersion >> 32) & 0xFFFF);
        printf("Build:%u\n", (version.ullVersion >> 16) & 0xFFFF);
        printf("QFE:%u\n", version.ullVersion & 0xFFFF);
    }
    FreeLibrary(hInstance);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM