枚举机器上所有 IDispatch 实现对象
我想枚举机器上所有 IDispatch 支持对象。目前我需要知道类 id 或 prog id 是什么,但是为了检查我的机器,我想知道是否可以枚举实现 IDispatch 的所有对象。
这可能吗?
任何帮助将不胜感激:)
I'd like to enumerate all IDispatch supporting objects on a machine. At the moment I need to know what the class id or prog id is but, for inspecting my machine, I'd like to know if I can just enumerate all the objects that implement IDispatch.
Is this even possible?
Any help would be much appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个非常奇怪的要求。摩擦在于“全部”规定。通过 HKCR\Typelib 键和 LoadTypeLib() 进行简单枚举是不够的,COM 服务器不需要发布类型库。实际上,您必须 CoCreateInstance() 组件类和 IDispatch 的 QueryInterface。这不仅慢,而且有风险。
如果您解释为什么您实际上会考虑做这样的事情,您可能会得到更好的答案。在不了解参数的含义或副作用可能是什么的情况下调用 IDispatch::Invoke() 会导致灾难。远离“ReformatDrive”等方法名称。
That's a very odd request. The rub is in the "all" stipulation. Simple enumeration through the HKCR\Typelib key and LoadTypeLib() isn't enough, a COM server is not required to publish a type library. You would actually have to CoCreateInstance() the coclass and QueryInterface for IDispatch. Not only is this slow, it is also risky.
You might get a better answer if you explain why you would actually contemplate doing something like this. Calling IDispatch::Invoke() without having some kind of idea what the arguments mean or what the side-effects might be is a recipe for disaster. Stay away from method names like "ReformatDrive".