Cannot downcast IITWindow to IITBrowserWindow in iTunes COM interface.

Actually, what I'd really like is the ability to highlight a playlist, or an artist, or an album, or a bunch of tracks and use right-click to send the information to another application. But as that isn't an option, I've started looking at the iTunes COM interface.
The code I'm trying to run, gets an IITWindowCollection using LiTunes:Windows() and then iterates though these. When it finds either a BrowserWindow, or a PlaylistWindow, I want to do more processing. But I'm unable to downcast the IITWindow object to an IITBrowserWindow.
Here's a snippet of what I'm trying to do:
IITWindowCollection* iIWindowCollection;
long lCount;
hRes = iITunes->get_Windows(&iIWindowCollection);
hRes = iIWindowCollection->get_Count(&lCount);
IITWindow *iITWindow;
ITWindowKind iTWindowKind;
BSTR bstrName;
IITBrowserWindow *iITBrowserWindow;
IITTrackCollection *iITTrackCollection;
for (long i = 1; i <= lCount; i++) {
hRes = iIWindowCollection->get_Item(i, &iITWindow);
hRes = iITWindow->get_Name(&bstrName);
hRes = iITWindow->get_Kind(&iTWindowKind);
switch (iTWindowKind) {
case ITWindowKindBrowser:
// At this point I need to refer to the object as iITBrowserWindow, not iITWindow.
iITBrowserWindow = dynamic_cast<IITBrowserWindow *>(iITWindow);
if (iITBrowserWindow) {
hRes = iITBrowserWindow->get_SelectedTracks(&iITTrackCollection);
break;
case ITWindowKindPlaylist:
break;
When I run it, I get an exception on the dynamic_cast.
What am I doing wrong here, as I can't see why this shouldn't work.
Or is my lack of C++ knowledge that obvious. <GRIN>.
Cheers.

Ha. I was partly right with my comment about lack of C++ knowledge. It turned out to be a lack of knowledge on how Windows COM works.
In case anyone else runs into this, and finds this thread, (Yeah, right. LOL) here's the answer.
You can't just "cast" from one object to another. You have to use the IUnknown::QueryInterface function to get the pointer to the new Object.
Easy when you know how, not !!!!!
Now onto other questions about how to access parts of the UI through this interface.
Cheers.

Similar Messages

  • ITunes COM interface

    I made an application that interfaced with the iTunes COM interface a while back now. And after updating to 7.4.1.2, it stopped working.
    Unhappy...
    Any ideas?

    The iTunes SDK has not been updated, so I can only recommend you logon to your developer account and raise the issue through channels at their site, probably a bug report would be appropriate.

  • ITunes COM interface missing

    I have recently updated to iTunes 8 (8.0.0.35 on Windows XP Pro). I was using a little self-written C# application to control iTunes using my mouse's special buttons (the mouse driver supports this out of the box, however not in the way I want it to).
    After the update, the application stopped working throwing an “interface not supported” 0x80004002 E_NOINTERFACE error. When I tried recompiling the tool from source, there was an error loading the iTunes COM interface. When checking the list of available COM interfaces in Visual Studio I noticed the “iTunes {VersionNumber} Type Library” interface was not listed.
    Did Apple remove the iTunes Type Library COM interface or was there just some error while installing iTunes 8 so it did not get registered?
    Btw: You don't need Visual Studio to check whether the COM interface is available; a lot of other applications allow using COM interfaces aswell, i.e. Visual Basic for Office (go to Tools » References and search the list for iTunes; my system lists iTunesAdmin, iTunesOutlookAddIn, iTunesPhotoSupport)

    I have heard of several people having this issue.
    Refer to this thread:
    http://discussions.apple.com/thread.jspa?messageID=8048746&#8048746
    Maybe you can figure out which registry settings to add/delete...
    But you can apparently also fix it by:
    1) uninstalling iTunes 8
    2) Installing iTunes 7.7
    3) Uninstalling iTunes 7.7
    4) installing iTunes 8 again
    (reference http://groups.google.com/group/itunes-com-developers/browse_thread/thread/61918c cf74a32e8)
    Fun, right?

  • ITunes COM Interface Documentation

    hi all
    I want to know ,how to add the photos to ipod in iTunes COM Interface Documentation .
    please help me ,
    thanks.
    my email: [email protected]

    I don't think the COM interface supports what you want to do. You can get the documentation here:
    http://developer.apple.com/sdk/itunescomsdk.html

  • Unavailable iTunes COM interface (FAO Robert Jacobson)

    Something hasn't set up properly or has broken which causes no iTunes VBS or Javascript files to execute, they simply respond that they cannot create the 'iTunes.Application' object.
    Does anyone know enough about COM interfaces and Vista to explain why this is happening or how to fix it? (obviously reinstalling iTunes, different versions, registering vbscript etc have no effect).
    (this is a continuation of http://discussions.apple.com/thread.jspa?messageID=8268641)

    Sounds like the COM interface did not register. This seems to have happened to several people when upgrading from iTunes 7 to iTunes 8. I don't think it is specific to Vista, or x64.
    I would first try a "repair" install. In other words, if you have iTunes 8 installed, try installing it again and selecting the "Repair" option.
    If that doesn't work, try this:
    1) Uninstall iTunes 8
    2) Install iTunes 7.7
    3) Uninstall iTunes 7.7
    4) install iTunes 8 again
    Message was edited by: Robert Jacobson1

  • Do PlayFile and AddFile still exist in the iTunes COM interface?

    I'm playing around with the iTunes COM SDK on Windows. I'd like to come up with a script that causes iTunes to play a video file, and either the PlayFile (associated with the liTunes interface) or AddFile (IITUserPlaylist) methods ought to do the trick -- at least in theory.
    Unfortunately, neither of them work. They're both still apparently valid method calls, since my Java -> COM bridge barfs when I feed it invalid method names. But neither of them actually does anything. By way of contrast, OpenURL and AddURL both work perfectly -- and they'd be viable workarounds, save that they both assume the input file is streaming audio and store it in the library as such.
    Have these methods been deprecated? If so, what have they been replaced with? Or is it more likely that I'm running afoul of one gotcha or another?
    Right now, the only workaround I can think of is to write code that edits "iTunes Music Library.xml" directly, and I'd rather avoid that for what should be bloody obvious reasons.
    Thanks in advance for any insight anyone has to offer on this.

    In general:
    - The best way to check if files are in a library is to drag the whole media folder to the library.  If something was missed it will be added.  If it is in the library is won't be added a second time.
    - If you have a second copy of a file and iTunes does not currently list that specific file in its database then even if it is identical to one already in the database it will add it a second time.  So if you have file xyz on the internal drive and the external drive and add them to iTunes you will end up with two entries for the same thing in iTunes because you really do have to copies of the files.  While this can happen with two copies on a single drive, it will almost definitely be the case when you have a copy of a file on two drives because iTunes really sees them as two different things.
    -Unless you know how iTunes works, avoid moving files yourself.  Let the consolidate feature do all the file moving.  Manually moving files can really mess up iTunes unless you know what you are doing and have iTunes set to not try to do it itself.
    - There's no clean and easy way to delete duplicates.  The best thing is to change practice so you don't create them.   Here are  references:
    How to find and remove duplicate items in your iTunes library - http://support.apple.com/kb/HT2905
    http://dougscripts.com/itunes/itinfo/dupin.php (commercial)
    Posts by turingtest2 about different types of duplicates and techniques- https://discussions.apple.com/thread/3555601 and https://discussions.apple.com/message/16042406 (Note: The DeDuper script is for Windows)
    http://www.hardcoded.net/dupeguru_me/

  • ITunes COM Interface - Podcasts

    Hello ...
    If anyone is familiar with the iTunesLib.dll COM interface ...
    I can't figure out for the life of me how to emulate deleting a podcast feed (by right clicking the feed in the Podcasts playlist and clicking "Delete") in code.
    I can iterate through each URLTrack and delete those, but the name of the feed always remains.
    Even shelling out and deleting the folder (under "\\Itunes Music\Podcasts\" does not get the job done ...
    Anyone know how to do this with the iTunesLib interface? Or even if you might tell me where this information is physically stored when you subscribe to a podcast so that deleting it via the COM interface will actually delete the feed (and not just the tracks...).
    Thanks.

    I don't think this is possible.
    If you don't already have it, the documentation for the COM interface is here:
    http://developer.apple.com/sdk/itunescomsdk.html
    You might try asking in the Developer or the Software Development 101 forums (even though the forums seem to be for Mac development...)
    http://home.comcast.net/~teridon73/itunesscripts/    

  • ITunes COM interface and iPod Chapters

    Hello everybody
    Does anyone know how to make Chapters through the COM interfaces for iTunes? Looking at the documentation there's no such functionality as far as I can see, but double checking anyway.
    If not, is there any other way to make chapters for MP4 files that are supported by iPod? I am on Windows so ChapterTool is not available to me.
    Thanks!

    I don't think the COM interface supports what you want to do. You can get the documentation here:
    http://developer.apple.com/sdk/itunescomsdk.html

  • ITunes COM interface for Windows

    Anyone know what is the newest version?
    I would suspect that an updated documentation was available for iTunes 10.
    The one for download is rather old.
    Regards
    Thomas

    Hi, welcome to Apple Discussions.
    The version I have is 8.1.0.52. I'm not aware of a newer version, although I've just failed to find the download in the ADC site, and it doesn't seem to be there, so perhaps an update is imminent.
    tt2

  • ITunes COM SDK broken on Windows XP??

    I have an application called TuneUp Companion (http://www.tuneupmedia.com) that was working fine with iTunes 7.7 and after upgrading is broken.
    It works fine on Windows Vista ...but iTunes 8 on Windows XP seems to give a message back that the iTunes COM interface is not available.
    Are there known issues with the iTunes COM SDK for Windows (7/15/08 release) on Windows XP??
    Thanks, Raza

    much of this is speculation because I can't remember how many previous versions of iTunes were on these machines...but this is what we're seeing:
    extra entries in two registry keys... when it didn't work these two registry entries contained "AppID" values:
    HKEYCLASSESROOT\CLSID\{B9E1D2CB-CCFF-4AA6-9579-D7A4754030EF}\Implemented
    Categories
    HKEYLOCALMACHINE\SOFTWARE\Classes\CLSID\{B9E1D2CB-CCFF-4AA6-9579-D7A4754030EF}
    with the APpID set to the same iTunes CLSID string:
    {B9E1D2CB-CCFF-4AA6-9579-D7A4754030EF}
    and when it did work the AppIDs entries were gone. this is only on XP.
    on vista there never was any AppID entry.
    but, again, i wonder if that was added by previous versions of iTunes which we didn't install on the vista machines...
    Also, worthy of noting is this post from Apple:
    http://support.apple.com/kb/HT1925
    ciao, raza

  • ITunes COM timesout in PHP

    I'm trying to connect to the iTunes COM interface from PHP. The code simply looks like:
    $iTunes = new COM("iTunes.Application");
    When I try to run this, the browser sits there and thinks for a while, then times out with:
    Fatal error: Maximum execution time of 30 seconds exceeded in K:\Webserver\content\private\iTunes.php on line 25
    Any help with this?

    Sorry, no anwser - but I have exactly the same problem, and really thought, that more people will have it, too...
    To be maybe a bit more precise: It SEEMS like Oulooks closes, but there is still the icon on the right buttom, showing, that Outook ist still open in the background. Also my mails in the trash folder of outlook are not deleted, which is a clear sign, that outlook is still running.
    This is - once again, after the "DEL key bug" extremly annoying! I don't use the Outlook sync function, so why is Apple touching my installation of Outlook, without asking me, and without giving me a chance, to reverse it? This is absolutely unacceptable!!

  • I cannot update or install updates on itunes. It says that the location for that file does not exist. I cant even uninstall itunes as the same error message comes up.

    I cannot update or install updates on itunes. It says that the location for that file does not exist. I cant even uninstall itunes as the same error message comes up.

    Hi vindog60,
    Thank you for using Apple Support Communities.
    To troubleshoot this issue where you get an installation error with iTunes on your Windows PC, please follow the steps in the article linked to below.
    Issues installing iTunes for Windows - Apple Support
    Cheers,
    Alex H.

  • Whenever i try to sync iphone5(version8.0.2) with itunes 12 on macbookpro.it appears cannot sync the purchased items on itune store. authorize your computer.i authorized it many times. but same response comes again to authorize.

    whenever i try to sync iphone5(version8.0.2) with itunes 12 on macbookpro.it appears cannot sync the purchased items on itune store. authorize your computer.i authorized it many times. but same response comes again to authorize.

    If you are sure that you are authorizing the correct account/ID then:
    iTunes repeatedly prompts to authorize computer to play iTunes Store purchases

  • ITunes comes up saying the iTunes library files cannot be saved. an unknown error occured

    iTunes comes up saying the iTunes library files cannot be saved. an unknown error occured
    what should i do

    Note: Close iTunes completely before doing any of this.
    After getting this error, I found a bunch of Temp files in the same folder as my iTunes library. The thing that stuck me as odd about this was that there were 4-5 of them labeled "Temp File.xml", "Temp File2.xml", etc. and when I tried to select any of them, the selected file(s) would mysteriously disappear. I ended up Selecting everything except the Temp File.xml files, and moving it elsewhere (I actually just put in a new folder in the parent folder).
    I then deleted/"Move to Trash"ed the folder that used to contain my Library, and renamed the new folder to have the same name as the old folder.
    Then I clicked on the iTunes icon (hold down option/alt from before you click, until the "choose library" dialog appears), and chose my old iTunes Library. This re-linked my old library and restored it to how it was before error (-48) started rearing its ugly head.
    (Windows users, when you re-open iTunes to link your library back in... you double click the icon, then immediately press-and-hold "shift" until the dialog appears)

  • When I try to purchase something it tells me my purchase cannot be completed .please apple support. Com/ itunes

    When I try to purchase something it tells me my purchase cannot be completed .please apple support. Com/ itunes

    Okay, the obvious answer, have you tried contacting iTunes Store support? http://www.apple.com/support/itunes/contact/

Maybe you are looking for