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?
CodePudding user response:
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);