Is there a way to trap the play/pause key so that windows does *not*
open the windows media player when the key is pressed, but instead
plays/pauses music in my app (also start my app if not already open).

I managed it to get the key notification in my app with installing a
keyboard hook but windows media player is opened afterwards anyway.

I tried returning one, zero or whatever from the HookCallback function
but windows media player still opens.

What can I do about it?

private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN &&
lParam.ToInt32() == 1307112)
{
int vkCode = Marshal.ReadInt32(lParam);

//return CallNextHookEx(IntPtr.Zero, 0, wParam,
IntPtr.Zero);
//return new IntPtr.Zero;
return new IntPtr(1);
}
else
{
return CallNextHookEx(_hookID, nCode, wParam, lParam);
}
}