views:

122

answers:

2

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'.

A: 
  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.

Shay Erlichmen
Urk. That will work, but it's a long way from elegant. Oh well (and thanks)
James Turner
A: 

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.

Georg Fritzsche