The simplified algorithm for searching for main windows of applications running in the system:
Call the EnumWindows function, as the first parameter pass a function (or method) which will be
called for each top-level window found in the system
For each found top-level window check if it is visible and has an icon
The simplified algorithm of getting window's icon:
Use the SendMessageTimeout function with the SMTO_NORMAL (0) flag to send to a window the
WM_GETICON (0x007F) message (use the ICON_BIG (1) value for a big icon or ICON_SMALL (0) for small)
If the above way failed (the NULL value was received), get an icon of a window's class
(call the GetClassLong function with the GCL_HICON (-14) value for a big icon or GCL_HICONSM (-34)
for small)
Approximate points:
A window with two listviews: 0.5
Getting top-level applications windows: 2.5
Getting windows' icons: 2.5
Presenting icons in listviews: 1.0
Adding icons to tray (including the context menu): 1.5
Restoring window from the tray area: 1.0
Synchronization of the content of both lists with the situation in the system
(may be delayed): 1.0