private void GetActiveWindow() { const int cChars = 256; int ihandler = 0; StringBuilder sBuff = new StringBuilder(cChars); ihandler = GetForegroundWindow(); StreamWriter sw; if (File.Exists("C:\\Log.txt")) { sw = File.AppendText("C:\\Log.txt"); sw.WriteLine(sBuff.ToString() + "->" + ihandler.ToString()); sw.WriteLine("-----------"); sw.Close(); } else { sw = new StreamWriter("C:\\Log.txt"); sw.WriteLine(sBuff.ToString() + "->" + ihandler.ToString()); sw.WriteLine("-----------"); sw.Close(); } }
GetForegroundWindow
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)