Enumerating all IDispatch implementing objects on a machine
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 IDi开发者_如何学Cspatch.
Is this even possible?
Any help would be much appreciated :)
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".
精彩评论