New topic: COM access?
<http://forums.realsoftware.com/viewtopic.php?t=36327> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message tempel Post subject: COM access?Posted: Mon Nov 15, 2010 10:49 am Joined: Fri Sep 30, 2005 10:01 am Posts: 192 Location: Germany, Munich I like to talk to the iTunes API on Windows, which provides a COM API. I have no idea how COM works. Has anyone made COM calls with RB? Are there examples around? _________________ User of RB since version 1. Provider of many free and outdated plugins. See: http://www.tempel.org/rb/ and http://www.tempel.org/Tags/REALbasic Top tempel Post subject: Re: COM access?Posted: Mon Nov 15, 2010 11:13 am Joined: Fri Sep 30, 2005 10:01 am Posts: 192 Location: Germany, Munich Uh - turns out that RB's OLEObject is all I need! Despite the docs suggesting that it only works for the Office apps (Word, Excel, PP), it works with others, too! I just managed to ask iTunes the list of tracks. Yay! No more need for using Windows Scripting as a workaround. _________________ User of RB since version 1. Provider of many free and outdated plugins. See: http://www.tempel.org/rb/ and http://www.tempel.org/Tags/REALbasic Top tempel Post subject: iTunes library accessPosted: Mon Nov 15, 2010 11:29 am Joined: Fri Sep 30, 2005 10:01 am Posts: 192 Location: Germany, Munich OK, this is great. I just want to share what I figured out: A snippet that asks iTunes for the list of paths to all its songs. For more on accessing the iTunes lib thru Apple's COM SDK, get it here (requires login): http://developer.apple.com/sdk/itunescomsdk.html Code: #pragma BreakOnExceptions off dim itunes as new OLEObject("iTunes.Application") dim mainLib as OLEObject = itunes.Value("LibraryPlaylist") dim tracks as OLEObject = mainLib.Value("Tracks") dim numTracks as Integer = tracks.Value("Count") dim songPathList() as String for i as Integer = 1 to numTracks dim args(1) as Variant args(1) = i dim currTrack as OLEObject = tracks.Invoke("Item", args) if currTrack.Value("Kind") = 1 then // it's a file dim path as String = currTrack.Value("Location") songPathList.Append path end if next // at this point, look at the songPathList in the debugger to see that it fetched all the paths break Exception exc as RuntimeException dim msg as String = exc.Message Break _________________ User of RB since version 1. Provider of many free and outdated plugins. See: http://www.tempel.org/rb/ and http://www.tempel.org/Tags/REALbasic Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
