INTERACT FORUM
Windows => Third Party Plug-ins, Programs, and Skins => Topic started by: widert on October 28, 2012, 05:56:37 am
-
Hi, just started looking into writing a little program that detects if Media Center is playing that will be used to control on/off of an amplifier.
I'm using Delphi and the Media Center com object.
Can anybody tell me why the following code does not work:
for i := 0 to MC.GetZones.GetNumberZones do
listbox1.Items.Append(mc.GetZones.GetZoneName(i));
Regards
Tom
-
Well, without knowing how you defined mc, I am assuming you successfully made the connection to mc and recieved a valid mc object. Also, if you could tell us what the error you are recieving is, we could probably give you better information.
But, since GetZoneName is a 0 based array, you should use MC.GetNumberZones -1 as you upper limit. If there are three zones, then they are number 0, 1, 2 and I am assuming that GetNumberZones will return a 3.
Hope this helps,
Alex
-
Thanks for your response
Updated code:
mc.Connect;
for i := 0 to MC.GetZones.GetNumberZones -1 do
listbox1.Items.Append(mc.GetZones.GetZoneName(i));
mc.Disconnect;
Connection works fine, and adding the name of the first zone works ok.
When trying to add the next name I however get:
First chance exception at $00C68FBB. Exception class $C0000005 with message 'access violation at 0x00c68fbb: write of address 0xb4000000'. Process Project1.exe (9168)
Tom