• Welcome to Theos PowerBasic Museum 2017.

Capture Icon (and save it as Bitmap into the clipboard)

Started by Patrice Terrier, October 25, 2008, 04:59:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

This one extract an icon from any FullPath.exe or dll.
Then the icon is saved on the fly into the clipboard as bitmap.


SUB CaptureIcon(lpszFile AS ASCIIZ)
    LOCAL hIconLarge, hIconSmall AS DWORD
    IF ExtractIconEx(lpszFile, -1, 0, 0, 0) THEN
       'CALL ExtractIconEx(lpszFile, 0, hIconLarge, hIconSmall, 1)
       CALL ExtractIconEx(lpszFile, 0, hIconLarge, hIconSmall, 1)
       LOCAL ii AS ICONINFO
       IF hIconLarge THEN
          CALL GetIconInfo(hIconLarge, ii)
       ELSE
          CALL GetIconInfo(hIconSmall, ii)
       END IF
       IF OpenClipboard(BYVAL 0) THEN
          CALL EmptyClipboard()
          CALL SetClipboardData(%CF_BITMAP, ii.hbmColor)
          CALL CloseClipboard()
       END IF
       IF hIconLarge THEN DestroyIcon(hIconLarge)
       IF hIconSmall THEN DestroyIcon(hIconSmall)
    END IF
END SUB
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com