什么是的ProgID或CLSID为IE9的JavaScript引擎(code-命名为"轮") [英] What is the ProgId or CLSID for IE9's Javascript engine (code-named "Chakra")

查看:452
本文介绍了什么是的ProgID或CLSID为IE9的JavaScript引擎(code-命名为"轮")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用.NET,我可以写承载符合微软的IActiveScript约定的脚本引擎的应用程序。这包括JScript和VBScript来自微软,也PerlScript,RubyScript和我不知道还有什么来自第三方的

Using .NET, I can write an app that hosts a scripting engine that complies with Microsoft's IActiveScript conventions. This includes JScript and VBScript from Microsoft, and also PerlScript, RubyScript and I don't know what else from third-parties.

要做到这一点在code的方法是这样的:

The way to do it in code is something like this:

    Type engine = Type.GetTypeFromProgID(progId, true);
    _engine = Activator.CreateInstance(engine) as IActiveScript;

其中 PROGID 可以利用的价值的Javascript,JScript中,ECMAScript中,VBScript和其他人。运行的Cscript.exe时,与 //è选项在命令行上指定的PROGID你可以做同样的事情。例如,这个命令:

where the progId can take the value Javascript, JScript, ECMAScript, VBScript, and others. You can do something similar when running cscript.exe, specifying the progId on the command line with the //E option. For example, this command:

cscript.exe  <file>  //e:JScript

..将运行指定的文件,无论其扩展,通过JScript引擎。

..will run the specified file, regardless of its extension, through the JScript engine.

在我的机器,如果我看在 HKLM \软件\类\ ,三的ProgID {Javascript中,JScript中,ECMAScript中}都指向同一CLSID,这是我估计是5.8的JScript脚本引擎: {f414c260-6ac0-11cf-b6d1-00aa00bbbb58}

On my machine, if I look in HKLM\SW\Classes\ , the three progIds {Javascript, JScript, ECMAScript} all point to the same CLSID, which I guess is the JScript 5.8 script engine: {f414c260-6ac0-11cf-b6d1-00aa00bbbb58}

有一个ProgID或CLSID我可以指定要运行IE9的JavaScript引擎,又名查克拉?

Is there a ProgId or CLSID I can specify to run IE9's Javascript engine, aka "Chakra"?

请问IE9的发动机仍然可以通过IActiveScript装?
微软的文档显示,它,但没有指定的ProgId或CLSID。

Does IE9's engine still get loaded by IActiveScript?
Microsoft's documentation suggests that it does, but does not specify a ProgId or CLSID.

推荐答案

的CLSID与IE9安装在轮Javascript引擎是
{16d51579-a30b-4c8b-a276-0ff4dc41e755}

The CLSID for the Chakra Javascript engine installed with IE9 is
{16d51579-a30b-4c8b-a276-0ff4dc41e755}.

该InProcServer32中是%WINDIR%\ SYSTEM32 \ jscript9.dll

The InProcServer32 is %windir%\System32\jscript9.dll .

没有的ProgId,我能找到。这是一个有点奇怪;通常成对ProgId和CLSID项相互引用。对于给定的COM对象,在注册表中的ProgID项有一个名为CLSID子项,并且CLSID注册表项中有一个名为的ProgId子项,并且它们相互引用。但是的ProgID子项IE9 CLSID为JScript的,这当然指的是V5.8的Jscript CLSID。不知道这是一个错误,微软,或混淆的目的一点,因为他们不使用IE9之外的查克拉引擎有人要。看起来有目的的对我。

There is no ProgId that I could find. That's a bit odd; normally paired ProgId and CLSID entries refer to each other. For a given COM object, the ProgId key in the registry has a subkey called CLSID, and the CLSID registry key has a subkey called ProgId, and they refer to each other. But the ProgId subkey for the IE9 CLSID is "JScript", which of course refers to the v5.8 Jscript CLSID. Not sure if this was a mistake by Microsoft, or a purposeful bit of obfuscation, because they don't want anyone using the Chakra engine outside of IE9. Looks purposeful to me.

我只是通过搜索注册表的jscript9.dll学到的CLSID的。

I learned of the CLSID by just searching the registry for jscript9.dll .

如果您有承载的脚本引擎.NET code,就可以直接使用CLSID实例为IE9的JavaScript引擎(查克拉)的IActiveScript对象。在code需要是这样的:

If you have .NET code that hosts scripting engines, you can instantiate the IActiveScript object for the IE9 javascript engine ("Chakra") by using the CLSID directly. The code needs to be something like this:

private const string clsIdPattern =
    @"^(?<curly>\{)?[a-zA-Z0-9]{8}(?:-[a-zA-Z0-9]{4}){3}-[a-zA-Z0-9]{12}(?(curly)\})$";

public ScriptEngine(string language)
{
    if (language == null)
        throw new ArgumentNullException("language");

    Type engineType = null;

    if (Regex.IsMatch(language, clsIdPattern))
    {
        // it's a CLSID
        var guid = new System.Guid(language);
        engineType = Type.GetTypeFromCLSID(guid, true);
    }
    else
    {
        // assume vanilla progId
        engineType = Type.GetTypeFromProgID(language, true);
    }

    var engine = Activator.CreateInstance(engineType) as IActiveScript;

在上面, clsIdPattern 是一个普通的EX pression匹配熟悉的GUID格式,不论有无周围的花括号。

In the above, clsIdPattern is a regular expression that matches the familiar GUID format, either with or without surrounding curlies.

由于code以上,你可以通过JScript的,使用Javascript,或ECMAScript的,并获得了V5.8 JScript引擎。或者你也可以通过{16d51579-a30b-4c8b-a276-0ff4dc41e755},并获得了IE9 Javascript引擎。很明显,你需要安装IE9为了这个工作。

Given the code above, you could pass "jscript", "Javascript", or "ECMAScript" and get the v5.8 JScript engine. Or you could pass "{16d51579-a30b-4c8b-a276-0ff4dc41e755}" and get the IE9 Javascript engine. Obviously you need to have IE9 installed in order for this to work.

我只是尝试这样做,它适用于简单的情况。我会与打多一些,真正很快。

I just tried this and it works for simple cases. I'll be playing with that some more, real soon.

如果您想从WSH运行脉轮,就像从Cscript.exe将,那么你就需要一个ProgID,我想。
如果我创建查克拉作为一个ProgID在注册表中,指的是正确的CLSID,我可以通过IE9的引擎像这样运行的JS文件:

If you want to run Chakra from WSH, like from cscript.exe, then you will need a ProgId, I think.
If I create "Chakra" as a Progid in the registry, referring to the correct CLSID, I can run JS files through IE9's engine like this:

cscript.exe  module.js  //E:Chakra 

例如,插入新的查克拉的ProgId后,给出的脚本是这样的:

For example, after inserting the new "Chakra" ProgId, given a script like this:

WScript.Echo( ScriptEngineMajorVersion() + "." +
              ScriptEngineMinorVersion() + "." +
              ScriptEngineBuildVersion());

...的输出是这样的:

...the output is like this:

C:\dev\js>Version.js
5.8.16982

C:\dev\js>cscript.exe Version.js  //E:Chakra
9.0.16434

而这里的Javascript中的AES加密测试结果,使用JScript 5.8比较轮:

And here's the result of a test of AES encryption in Javascript, comparing Chakra with JScript 5.8:

C:\dev\js\SlowAES>cscript.exe test.aes.js
AES encryption in Javascript.
password  : Albatros1
salt      : saltines (73616c74696e6573)
iterations: 1000
key       : 172,52,20,51,98,71,49,195,14,31,141,51,129,8,94,66
iv        : 212,27,28,156,83,245,0,35,176,157,45,141,209,143,158,248
plaintext : Hello, /r/javascript.
ciphertext: fdebac9f1ed1a13bac58f3cc6558e8b0367a94245dbbfe53cacc4979799fc182
decrypted : Hello, /r/javascript.
elapsed   : 5011ms

C:\dev\js\SlowAES>cscript.exe test.aes.js //E:Chakra
AES encryption in Javascript.
password  : Albatros1
salt      : saltines (73616c74696e6573)
iterations: 1000
key       : 172,52,20,51,98,71,49,195,14,31,141,51,129,8,94,66
iv        : 212,27,28,156,83,245,0,35,176,157,45,141,209,143,158,248
plaintext : Hello, /r/javascript.
ciphertext: fdebac9f1ed1a13bac58f3cc6558e8b0367a94245dbbfe53cacc4979799fc182
decrypted : Hello, /r/javascript.
elapsed   : 2593ms


要设置的ProgID在我的注册表,我用这样的:


To set the ProgId in my registry, I used this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{16d51579-a30b-4c8b-a276-0ff4dc41e755}\ProgID]
@="Chakra"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID\{16d51579-a30b-4c8b-a276-0ff4dc41e755}\ProgID]
@="Chakra"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Chakra]
@="JScript Language"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Chakra\CLSID]
@="{16d51579-a30b-4c8b-a276-0ff4dc41e755}"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Chakra\OLEScript]

和以取消显示脉轮,或恢复注册表,我这样做:

and to unexpose Chakra, or revert the registry, I did this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{16d51579-a30b-4c8b-a276-0ff4dc41e755}\ProgID]
@="JScript"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID\{16d51579-a30b-4c8b-a276-0ff4dc41e755}\ProgID]
@="JScript"

[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Chakra]

该注册表脚本曾与64位Windows系统;如果你没有64位,那么你需要删除WOW6432Node线。

This registry script worked with x64 Windows; if you don't have x64, then you'll need to remove the WOW6432Node lines.

这篇关于什么是的ProgID或CLSID为IE9的JavaScript引擎(code-命名为&QUOT;轮&QUOT;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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