我怎么知道哪个版本的IE用于编译 [英] How can I know which version of IE is used for compile

查看:129
本文介绍了我怎么知道哪个版本的IE用于编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们正在开发使用MSHTML的应用程序.我们有一些开发人员,其PC已安装IE8或IE9.在开发过程中,我们需要一些IE版本多样性来进行测试.

现在,我们向应用程序添加了对HTML5的支持,并且只有在我们安装了IE9的情况下,某些新的HTML5功能才会编译,因为早期版本的MSHTML没有定义HTML5级别的枚举值,例如,仅定义了TAGID_HEADER枚举如果在装有IE9的PC上进行编译.

是否有一个预处理器符号来确定在编译时使用的IE版本(以及哪个版本的MSHTML)? _WIN32_IE预处理器符号不取决于计算机上安装的内容.它为程序员提供了一种控制应用程序兼容性级别的方法.那不是我们想要的.我们正在寻找一种方法,根据是否安装了IE9,有条件地对其进行一种或多种编译方式.

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.

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



最终版本将使用IE9,因此将正确使用这些符号.仅存在预处理器符号,以避免所有开发人员升级到IE9并允许他们完整构建应用程序.



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

推荐答案

您应该会发现它是SDK的版本,该版本指示这些标签的存在与否...

...或者您在编译时直接从com对象创建/导入tlb文件

如果是后者,则是,IE,松散地参与了您的编译

您需要确定它是哪一个,然后稳定您的构建环境-强制使用特定版本的SDK,并因此在开发人员机器上使用mshtml.h,和/或使用确定的TLB文件
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


我要解决的方法是创建一个小的实用程序,该实用程序创建了一个名为thisIeVersion.h
的文件. 我会检查当前安装的版本,然后相应地写入此头文件.

一旦有了一个执行此操作的应用程序,我便将其添加到项目选项中的预构建步骤中.然后,只要首先包含此标头,一切都将正常工作.


过去,我曾使用过类似的想法来自动增加内部版本号.每次构建应用程序时,它还可以用于创建唯一的指纹..

这是一些代码,这些代码将确定mshtml的安装版本.我将由您自己填写空白并编写thisIeVersion.h文件.


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..

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.


#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);
                    }
                }
            }
        }
    }
}


这篇关于我怎么知道哪个版本的IE用于编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆