Re: getting number of items from curr playlist of windows media player

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Maybe beacuse the code in MainForm_Load cannot find specified window?
There can be different reasons why this is happening:
- there is not such window ( check windows with Spy++ tool )
- bug in the Win32 class

Also you do not check if
wnd = Win32.FindWindow("WMPlayerApp","Windows Media Player");
returned valid wnd handle.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Paul Fi" <nazar_fin@xxxxxxxxxxx> wrote in message
news:Og6g3qPGGHA.3856@xxxxxxxxxxxxxxxxxxxxxxx
>I have this code which tries to obtain the number of items in the
> current playlist of windows media player:
>
> private void MainForm_Load(object sender, System.EventArgs e)
> {
> // get Window handle
> wnd = Win32.FindWindow("WMPlayerApp","Windows Media Player");
> wnd = Win32.FindWindowEx(wnd, 0, "WMPAppHost", null);
> wnd = Win32.FindWindowEx(wnd, 0, "WMP Skin Host", null);
> wnd = Win32.FindWindowEx(wnd, 0, "CWmpControlCntr", null);
> wnd = Win32.FindWindowEx(wnd, 0, "WMPPlaylist", null);
> wnd = Win32.FindWindowEx(wnd, 0, "ATL:SysListView32", null);
>
> iHandle = Win32.FindWindow("WMPlayerApp", "Windows Media Player");
> }
>
> private void button1_Click(object sender, System.EventArgs e)
> {
> han =Win32.SendMessage(wnd, Win32.LB_GETCOUNT, 0,0);
> if(han != Win32.LB_ERR)
> {
> textBox1.Text = Convert.ToString(han);
> }
> }
>
> so when i click the button1 i should get the number of items displayed
> in my textbox1.
> but all i get is 0 even though my current playlist has 5 items and one
> of them is currently playing.
> has any body any idea why this is happening?
>
>
> *** Sent via Developersdex http://www.developersdex.com ***


.


Quantcast