C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
7,621 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I used following code to get windows title but for application name p1 returns devenv instead of Visual Studio
If anyone knows how to resolve this issue, please let know
var wnd = GetForegroundWindow();
uint procId;
GetWindowThreadProcessId(wnd, out procId);
var p = Process.GetProcessById((int)procId).MainWindowTitle.ToString();
var p1 = Process.GetProcessById((int)procId).ProcessName.ToString();
string shortDateString = DateTime.Now.ToShortDateString();
List<string> app = new List<string>();
app.Add(p);
For example :
var p = Process.GetProcessById((int)procId).MainModule.FileName;
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(p);
string sDescription = fvi.FileDescription;