View Single Post
Old 9th February 2011, 12:36   #3
akpsvnit
Junior Member
 
Join Date: Feb 2011
Posts: 1
First of all,
for Winamp title, you need to enable "Show winamp in taskbar" in preferences -> General preferences.
Now you need to get correct handle for winamp to get title.
For that import few dll functions.
-------------------------------------------------------
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow([MarshalAs(UnmanagedType.LPTStr)] string lpClassName, [MarshalAs(UnmanagedType.LPTStr)] string lpWindowName);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int GetWindowText(IntPtr hwnd, string lpString, int cch);
-------------------------------------------------------

& create a function
-------------------------------------------------------
public static string GetTitle()
{
IntPtr hwnd = FindWindow("Winamp v1.x",null);
if (hwnd.Equals(IntPtr.Zero))
return "N/A";
string lpText = new string((char) 0, 100);
int intLength = GetWindowText(hwnd, lpText, lpText.Length);
if ((intLength <= 0) || (intLength > lpText.Length))
return "N/A";
string strTitle = lpText.Substring(0, intLength);
return (strTitle);
}
-------------------------------------------------------

This will return the whole title visible in taskbar.
Then you can crop the winamp name at the end in order to get current track.
akpsvnit is offline   Reply With Quote