views:

105

answers:

2

How do I access an enum that is defined within a COM interface? Specifically, I've created a new instance of an iTunes.Application:

var   iTunesApp = WScript.CreateObject("iTunes.Application");

... and I want to be able to use certain enums defined within the COM

iTunesTrackCOM.idl File Reference
[...]
Enumerations
[...]

enum   ITVideoKind { 
   ITVideoKindNone = 0, 
   ITVideoKindMovie, 
   ITVideoKindMusicVideo, 
   ITVideoKindTVShow 
 }

I've tried iTunesApp.ITVideoKindTVShow, but that doesn't seem to work.

Alternatively, how could I root around the iTunesApp object interactively via a shell or something like that?

+1  A: 

You can't use the enum by name. You have to just use the constants: 0, 1, 2...

It's really awesome when you're dealing with bit-fields. You have to use the decimal value of the bit-flag, e.g. the flags parameter to IHTMLTxtRange::findText().

jeffamaphone
Or declare your own constants in the scripts, and use them.
Pavel Minaev
Yeah, that'd work too.
jeffamaphone
Thanks for the answers; this is what I ended up doing.
Peyton
A: 

You can use a tool like tlb2const to generate constants from the typelib.

See my answer here: http://stackoverflow.com/questions/1276442/is-it-possible-to-expose-a-c-enum-to-com-interop-callers-and-if-so-how/1276503#1276503

Kim Gräsman