Is it possible to use registration-free COM with HTA applications?

半世苍凉 提交于 2020-01-02 05:27:10

问题


Since HTA applications are hosted within MSHTA.exe how does one provide a manifest? Plus I assume providing a MSHTA.exe.manifest could potentially break other HTA apps?


回答1:


On Vista+, MSHTA.exe has an embedded manifest, which takes priority over external manifests, so your suggestion is not an option.

On XP/2003, yes, your suggestion would work, although it would be bad form, as is dropping files in System32 to modify the behavior of a system binary (especially make sure that any registration you put in the manifest are objects you are the only one to care about).

The proper solution, available on Win2003 and above, is to use the Microsoft.Windows.ActCtx object to instantiate your object given an explicit manifest reference.

For example:

var actCtx = WScript.CreateObject("Microsoft.Windows.ActCtx");
actCtx.Manifest = "myregfree.manifest";
var obj =  actCtx.CreateObject("MyObj");   

Perhaps, if this must work on XP as well, a path you may take is a combination of both solutions.




回答2:


Edit: My answer is wrong, but I'll leave it here to avoid any similar wrong answers :)


If you question is can you access a COM object without registering it on the machine, then I think the answer is a tentative yes. However the work you would need to do would be substantial and would mean implementing a lot of the low level code that most development tools provide for you as a matter of course (Delphi, .NET, JAVA). You would need to interface with the dll directly (like you would a normal dll ), query its interfaces and call your methods.

If you have C, C++ knowledge, the way COM is accessed from these languages would give you some pointers.

Sorry I cant be of any more help.



来源:https://stackoverflow.com/questions/483306/is-it-possible-to-use-registration-free-com-with-hta-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!