开发者

Detecting if a COM object is registered or instantiated (iTunes)

I'm working with the iTunes COM API on Windows. I'd like to manage the enormous 开发者_如何学编程delay that occurs when instantiating the iTunes object (which has to launch iTunes itself). I was hoping there was a way to determine the following:

  • if a given CLSID is registered on the system (programatically)
  • if an instance of a given CLSID is already created

Using these, I could then offer helpful feedback such as 'iTunes is not installed' or 'Please wait while iTunes is started - this make take a few moments'.


  1. Create the iTunes COM object, if it fails then iTunes is not installed and the function should return pretty fast.
  2. Create other thread before creating the iTunes object let the thread wait on some event, once that iTunes object is created signal that event.
  3. In the thread, if in let say 3 seconds the event is not singled then display the "Please wait" and then wait for the event again this time forever.

This is more or less the flow you should do.


The straight-forward way of determining wether a given CLSID is registered without CoCreating it is to check in the registry for HKCR\ReadableName\CLSID. That is also where windows gets its information from.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜