Get current active application name in Windows 10 using C# -


i tried current active application name (or process name) in application microsoft edge result applicationframehost. there way application name such in task manager?

my actual code:

    [dllimport("user32.dll")]     static extern intptr getforegroundwindow();     [dllimport("user32.dll")]     static extern int getwindowtext(intptr hwnd, stringbuilder text, int count);     [dllimport("user32.dll")]     public static extern intptr getwindowthreadprocessid(intptr hwnd, out uint processid);              private string getactiveprocess()     {          const int nchars = 256;         uint processid;         stringbuilder buff = new stringbuilder(nchars);         intptr handle = getforegroundwindow();          if (getwindowtext(handle, buff, nchars) > 0)         {             getwindowthreadprocessid(handle, out processid);             return process.getprocessbyid((int)processid).processname;         }         return null;     } 

i believe looking this:

process.getcurrentprocess().processname 

getcurrentprocess

processname

that should give name of curent process


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -