[DllImport("user32.dll")] static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll")] static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); private string GetActiveWindowTitle() { const int nChars = 256; IntPtr handle = IntPtr.Zero; StringBuilder Buff = new StringBuilder(nChars); handle = GetForegroundWindow(); if (GetWindowText(handle, Buff, nChars) > 0) { // listBoxControl1.Items.Add(Buff.ToString()); // Buff.Capacity.ToString(); Buff.MaxCapacity.ToString(); return Buff.ToString(); } return null; listBoxControl1.Items.Add(GetForegroundWindow.ToString());
ToString()
GetForegroundWindow
IntPtr
GetForegroundWindow()
()
MediaPlayer
System.Windows.Forms
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)