Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

We are developing an application which uses MSHTML. We have developers whose PCs have IE8 or IE9 installed. We need some of this IE version diversity for testing purposes as we develop.

We are now adding support for HTML5 to the application, and some of the new HTML5 features will only compile when we have IE9 installed as MSHTML for earlier version doesn't have HTML5 level enum values defined, eg, the enum TAGID_HEADER is only defined if you compile on a PC with IE9 installed.

Is there a preprocessor symbol to determine the version of IE (and hence, which version of MSHTML) is used at compile time? The _WIN32_IE preprocessor symbol does not depend on what's installed on the computer. It provides a way for a programmer to control compatibility level of an application. That's not what we are looking for. We are looking for a way to conditionally compile it one way or another depending on if IE9 is installed or not.

C++
Example:
#if defined( XXX_IE9_OR_LATER )
...->createElement( HTML::TAGID_FIGCAPTION, ... );
#else
...->createElement( (HTML::_ELEMENT_TAG_ID)201, ... );
#endif


A final release build will use IE9, so the symbols will be used correctly. The preprocessor symbol is only there to avoid all developers to upgrade to IE9 and to allow them to build the application in full.

Thanks
Posted
Updated 1-Mar-12 14:24pm
v3
Comments
Sergey Alexandrovich Kryukov 1-Mar-12 20:38pm    
What do you mean "IE used for compile"? IE is not used for compilation and anything...
--SA
Stefan_Lang 2-Mar-12 4:16am    
Seems like this isn't about IE, but about the MSHTML API that comes with it.
Sergey Alexandrovich Kryukov 2-Mar-12 14:24pm    
Probably. Thanks for this note.
--SA

you'll should find it's the version of the SDK that's dictating the presence or absence of those tags ...

... or, you're creating/importing a tlb file directly from the com object at the compile time

If it's the latter, then yes, IE, is loosely involved in your compile

You need to work out which one it is, then stabilise your build environment - mandate a specific version of the SDK, and hence mshtml.h on your dev machines, and/or use a definitive TLB file
 
Share this answer
 
Comments
Lekrot 2-Mar-12 0:27am    
We are indeed importing a tlb file directly from the COM object at compile time. Thanks for pointing us in the right direction. We now need to see how we can ensure that all developers use the same version of the TLB file.
barneyman 2-Mar-12 0:41am    
use OleView.exe to save the tlb from the version you want
Lekrot 2-Mar-12 1:07am    
We have the correct .tlb file on those PCs which have IE9 installed. We just need to work out the best way to ensure that all other developers have it in their build environment too.
barneyman 2-Mar-12 6:27am    
check it into your source control and #import it from a controlled location?
The way I'd go about it would be to create a small utility that created a file called thisIeVersion.h
I'd check the version that was currently installed then write this header file accordingly.

Once I had an app that did this, I'd add it to the pre-build steps in the project options. Then as long as this header was included first, everything will just work.


I've used a similar idea in the past to automatically increment the build number. It also has uses in creating a unique fingerprint for each time the app is built..

[EDIT:] Here's some code that will determine the installed version of mshtml. I'll leave it up to you to fill in the blanks and write the thisIeVersion.h file.


C++
#include <stdio.h>
#include <windows.h>


int main()
{
    char szBuffer[MAX_PATH+1];
    char *szFile = "mshtml.dll";
    char *backSlash = "\\";

    DWORD  verHandle = NULL;
    UINT   size      = 0;
    LPBYTE lpBuffer  = NULL;
    DWORD  verSize;


    GetSystemDirectory(szBuffer, MAX_PATH);
    strcat(szBuffer, backSlash);
    strcat(szBuffer, szFile);

    verSize   = GetFileVersionInfoSize( szBuffer, &verHandle);

    if (verSize != NULL)
    {
        LPSTR verData = new char[verSize];

        if (GetFileVersionInfo( szBuffer, verHandle, verSize, verData))
        {
            if (VerQueryValue(verData,"\\",(VOID FAR* FAR*)&lpBuffer,&size))
            {
                if (size)
                {
                    VS_FIXEDFILEINFO *verInfo = (VS_FIXEDFILEINFO *)lpBuffer;
                    if (verInfo->dwSignature == 0xfeef04bd)
                    {
                        int major = HIWORD(verInfo->dwFileVersionMS);
                        int minor = LOWORD(verInfo->dwFileVersionMS);
                        int build = verInfo->dwFileVersionLS;
                        printf("Installed MSHTML Version: %d.%d\n", major, minor);
                    }
                }
            }
        }
    }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900