pythoncom.CoCreateInstance无法创建IZoneIdentifier;尽管在MSDN中有记录,但是注册表中也缺少该接口 [英] pythoncom.CoCreateInstance can't create IZoneIdentifier; the interface is missing from registry too despite being documented in MSDN

查看:503
本文介绍了pythoncom.CoCreateInstance无法创建IZoneIdentifier;尽管在MSDN中有记录,但是注册表中也缺少该接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施操作区域标识符以指定在哪里下载文件 - 旧的新东西 - MSDN博客在Python中。

I'm trying to implement Manipulating the zone identifier to specify where a file was download from – The Old New Thing - MSDN blogs in Python.

CoCreateInstance

pythoncom.CoCreateInstance(
        pywintypes.IID('{0968e258-16c7-4dba-aa86-462dd61e31a3}'),    #CLSID_PersistentZoneIdentifier
        None,pythoncom.CLSCTX_ALL,
        pywintypes.IID('{cd45f185-1b21-48e2-967b-ead743a8914e}'))    #IID_IZoneIdentifier

我收到错误:

TypeError: There is no interface object registered that supports this IID

(没有堆栈跟踪,因为这是一个扩展函数)

如果我替换 IZoneIdenti fier IID与 pythoncom.IID_IUnknown pythoncom.IID_IPersistFile ,它有效,但是 QueryInterface 使用正确的IID失败并出现相同的错误。

If I replace the IZoneIdentifier IID with pythoncom.IID_IUnknown or pythoncom.IID_IPersistFile, it works, but a QueryInterface with the right IID fails with the same error.

确实,在 HKCR \接口,我看不到像 IZoneIdentifier ,但确实看到 IPersistFile

Indeed, in HKCR\Interface, I see nothing like IZoneIdentifier but do see an IPersistFile.

反汇编 urlmon.dll 后,我发现它确实实现了接口,但不会在 DllRegisterServer 中注册它。进一步搜索,我看到 IPersistFile 正由 ole32.dll 注册 - 但不是 IZoneIdentifier

Having disassembled urlmon.dll, I see that it indeed implements the interface, but doesn't register it in its DllRegisterServer. Searching further, I see that IPersistFile is being registered by ole32.dll - but not IZoneIdentifier.

MSDN 证明此界面自IE6起可用。但它在IE7或IE8中都不存在。由于这是XP(并且涉及所有更新),我没有别的尝试。

MSDN documents this interface to be available since IE6. But it's not there in either IE7 or IE8. Since this is XP (and with all the updates allegedly), I've nothing else to try.

同样,该界面存在于Windows SDK 7.0中的 urlmon.h MSDN文章中提到的文件。

Likewise, the interface is present in Windows SDK 7.0 in the urlmon.h file mentioned in the MSDN article.

问题是:


  • 这个界面是否会默默地丢弃,而不支持其他没有MSDN反映的内容?或者,这是一个已知的问题吗?是否可以在IE的更高版本中使用?

  • ole32.dll urlmon.dll 属于(所以我可以尝试(联合国)安装更新)?

  • Was this interface silently dropped in favour of something else without MSDN reflecting that or something? Alternatively, is this a known issue? Is it available in later versions of IE?
  • What components do ole32.dll and urlmon.dll pertain to (so I can try (un)installing updates for them)?

推荐答案

IZoneIdentifier 没有任何问题。最初的C ++程序运行得很好。正如 @IgorTandetnik指出的那样out ,并非对象实现的每个接口都将在注册表中注册,只有那些支持编组的接口。

There's nothing wrong with IZoneIdentifier. The original C++ program runs just fine. As @IgorTandetnik pointed out, not every interface an object implements is going to be registered in the registry, only those that support marshalling.

错误来自 pythoncom 本身(提示是 TypeError ,而不是 pythoncom.com_error ,错误信息总是用英语而不是系统的UI语言。)

The error comes from pythoncom itself (a hint is that it's a TypeError, not pythoncom.com_error, and the error message is always in English rather than the system's UI language).

原因是 pythoncom 确实需要接口支持 IDispatch - 或者它无法推断出如何使用接口的函数和它们接受/返回的值。

The cause is that pythoncom indeed requires IDispatch support by the interface - or it wouldn't be able to deduce how to work with the interface's functions and values they accept/return.

唯一的例外是一些基于 IUnknown 的接口,其编译支持( IPersistFile 是其中之一;完整列表在中pythoncom.InterfaceNames ,显然)。

The only exception is a number of IUnknown-based interfaces, support for which is compiled in (IPersistFile is one of them; the full list is in pythoncom.InterfaceNames, apparently).

支持其他 IUnknown 的接口可以添加pythoncom扩展模块。关于它们的一些(非常稀少)文档可以在 pywin32 文档中找到com / win32com / HTML / PythonCOM.htmlrel =nofollow noreferrer> Python和COM - 实施细节文章。

Support for other IUnknown-based interfaces can be added with a "pythoncom extension" module. Some (very scarce) documentation on them can be found in pywin32 docs in the Python and COM - Implementation Details article.

这篇关于pythoncom.CoCreateInstance无法创建IZoneIdentifier;尽管在MSDN中有记录,但是注册表中也缺少该接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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