0

As we can get the title of active window in c sharp using method ActiveWindowTitle(). Now I need to get The icon of above same window. how can I do that?

2 Answers2

0

If you find a foreground window

GetForegroundWindow(

you can find out its process ID

GetWindowThreadProcessId(

and for that process, the file path

process.MainModule;

then just use the function

Icon ico = Icon.ExtractAssociatedIcon (executablPath);

See for example: this

Viliam
  • 636
  • 9
  • 17
0

Maybe you can use this. icon.

enter image description here

Jiale Xue - MSFT
  • 3,560
  • 1
  • 6
  • 21