Announcement

Collapse
No announcement yet.

icon and bitmap retrieved from system dll

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • icon and bitmap retrieved from system dll

    how can one know what number a icon is in a system (win) dll
    [code]
    hDll = LoadLibrary ( "SHELL32.dll" );
    // Add an icon to each image list.
    hiconItem = LoadIcon (hDll , MAKEINTRESOURCE ( 3));
    [code)
    do you use iconsextract per file then count the order?.

    also i can make bitmap ribbon (bar) using some merge image online just slow
    is there a way to save an image list to a bitmap.
    thanks everyone


  • #2
    One way would be to use ResourceHacker to identify them

    http://www.angusj.com/resourcehacker

    Comment


    • #3
      Some useful code samples here too,
      Rgds, Dave

      Comment


      • #4
        Originally posted by Dave Biggs View Post
        Some useful code samples here too,
        Borje's Iconview at Post #4 in that link is a great little tool for this (a minor modification to let you pick the file would be trivial)

        https://forum.powerbasic.com/forum/u...754#post784754

        Edit: OK, I did the mod
        '
        Code:
        'Original code by Borje Hagsten
        'https://forum.powerbasic.com/forum/user-to-user-discussions/powerbasic-for-windows/784751-dll-icon-numbers?p=784754#post784754
        'modified by Stuart Mclachlan (changed window size and added file selector)
        #COMPILE EXE   ' IconView.bas
        #DIM ALL
        #INCLUDE "WIN32API.INC"
        %ID_LIST = 200
        
        '====================================================================
        FUNCTION PBMAIN () AS LONG
          LOCAL hDlg, hIcon AS DWORD
          LOCAL c, cIcons, dataValue, iItem AS LONG
          LOCAL strFile AS STRINGZ * %MAX_PATH
          DISPLAY OPENFILE 0, , , "View Icons", $NUL, CHR$("Executables", 0, "*.EXE;*.DLL", 0), _
          "", "", 0 TO strFile
        
          IF strFile = "" THEN EXIT FUNCTION
          DIALOG NEW 0, PATHNAME$(NAMEX,strFile  & " icons"),,, 600, 400, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
        
          CONTROL ADD LISTVIEW, hDlg, %ID_LIST, "SysListView321", 5, 5, 590, 390, _
                  %WS_CHILD OR %WS_VISIBLE OR %WS_VSCROLL OR %WS_TABSTOP, %WS_EX_CLIENTEDGE
        
          IMAGELIST NEW ICON 32, 32, %ILC_COLOR32, 0 TO dataValue
          LISTVIEW SET IMAGELIST hDlg, %ID_LIST, dataValue, %LVSIL_NORMAL
        
          '------------------------------------------------------------------
          cIcons = ExtractIcon(0, strFile, -1) '-1 = icon count
          FOR c = 0 TO cIcons - 1
              hIcon = ExtractIcon(0, strFile, c)
              IF hIcon THEN
                  INCR iItem
                  IMAGELIST ADD ICON dataValue, hIcon
                  IMAGELIST GET COUNT dataValue TO cIcons
                  LISTVIEW INSERT ITEM hDlg, %ID_LIST, iItem, cIcons, "Icon" + STR$(c)
              END IF
          NEXT
          '------------------------------------------------------------------
        
          DIALOG SHOW MODAL hDlg
        END FUNCTION
        '

        Comment


        • #5
          Howdy, James!

          is there a way to save an image list to a bitmap.
          If the imagelist has 100 images that are 24x24 , then something like this ...

          Code:
          w = 100 * 24
          h = 24
          Graphic Bitmap New w,h to hBMP   'Graphic memory bitmap sized to hold a 100x1 row of images, the entire hLst ImageList
          
          For i = 1 to 100
             x = (i-1)*24
             Graphic ImageList (x,0), hLst, i, 0, %ILD_Normal   'copies the ImageList images to the memory bitmap
          Next i
          Graphic Save can then be used if you want to save the composite to a file.

          Comment


          • #6
            what in ran into n
            making a bitmap ribbon aka bar if bitmap a 16 x 16 the lenght is (number of images x 16)
            and used
            Code:
            IMAGELIST NEW ICON 1, 24, %ILC_COLOR24, 0 TO I ' ILC_COLOR32
            IMAGELIST NEW ICON 16, 16, 24, 1 TO hImageList ' Note Icon Size
            thanks

            Comment


            • #7
              Code:
              #COMPILE EXE
              #DIM ALL
              #INCLUDE ONCE "WIN32API.INC"
              
              FUNCTION PBMAIN () AS LONG
              LOCAL hDlg,hLib,hIcon AS DWORD
              
              DIALOG NEW 0, "Icon Demo",100,100,300,300, %WS_POPUP OR _
              %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
              %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
              %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
              OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
              
              CONTROL ADD IMAGEX, hDlg, 1001, "H", 10, 8, 256, 256, %SS_BITMAP
              ' hicon = loadimage(0,"H:\Image\button_buy-it-now.bmp", %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
              hLib = LoadLibrary("shell32.dll") 'SHELL32.dll")
              hicon = loadbitmap(hlib, byval 204)
              'hicon = LoadImage(hlib, byval 204, %IMAGE_BITMAP, 0, 0, 0)'%LR_LOADFROMFILE)
              ' HIcon = ExtractIcon(0, "SHELL32.DLL", -1) '-1 = icon count can try ImageRes.dll too
              'HIcon = ExtractIcon(0, "SHELL32.DLL", 115)
              ' hIcon = LoadImage(hLib,byval 87 , %IMAGE_ICON, 0,0,%LR_DEFAULTCOLOR)' 256, 256,0)
              'hIcon = LoadImage(hLib,byval 4 , %IMAGE_BITMAP, 0,0,%LR_DEFAULTCOLOR)
              SendDlgItemMessage hDlg, 1001, %STM_SETIMAGE, %IMAGE_bitmap, hIcon
              freelibrary hLib
              DIALOG SHOW MODAL hDlg
              
              END FUNCTION
              i used this to extract icon by using Extraction
              works modified for bitmap can not get it to work
              thanks

              Comment


              • #8
                ExtractIcon sorry

                Comment


                • #9
                  modified for bitmap can not get it to work
                  Couple of reasons..
                  When using IMAGEX control - load a bitmap to "prime" the control before changing it with STM_SETIMAGE.

                  To do that, add a resource bitmap to the source code..
                  '
                  Code:
                  #RESOURCE Bitmap, H, "Hammer.bmp"     ' eg - use any 'primer' bitmap
                  Also - there is no bitmap '204' in Shell32.dll, try 'byval 210' instead.
                  Rgds, Dave

                  Comment


                  • #10
                    Hi Dave i an trying to keep from using #resource

                    thanks

                    Comment


                    • #11
                      Thanks Very Much
                      the load a bitmap to "prime" was the key

                      Comment


                      • #12
                        Originally posted by James C Morgan View Post
                        Ii used this to extract icon by using Extraction
                        works modified for bitmap can not get it to work
                        thanks
                        So many things wrong with that code, it's hard to know where to start
                        The big one is that you are conflating icons and bitmaps.Shell32.dll contains icons, so your code won't work if you tell it to load a bitmap.
                        Without error checking, you can flounder around for ever. You really need to check whether you are getting valid handles back.

                        '
                        Code:
                        #COMPILE EXE
                        #DIM ALL
                        #INCLUDE ONCE "WIN32API.INC"
                        
                        FUNCTION PBMAIN () AS LONG
                        LOCAL hDlg,hLib,hIcon AS DWORD
                        
                        DIALOG NEW 0, "Icon Demo",100,100,300,300, %WS_POPUP OR _
                            %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
                            %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
                            %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
                            OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                        
                            CONTROL ADD IMAGEX, hDlg, 1001, "H", 10, 8, 256, 256, %SS_BITMAP
                            hLib = LoadLibrary("shell32.dll") 'SHELL32.dll")
                            IF ISFALSE(hLib) THEN ? "Library not loaded":EXIT FUNCTION
                            hIcon = LoadImage(hLib,BYVAL MAKEINTRESOURCE(42),%IMAGE_ICON, 0,0,%LR_DEFAULTCOLOR)' 256, 256,0)
                            IF ISFALSE(hICon) THEN ? "Icon not found":EXIT FUNCTION
                            SendDlgItemMessage hDlg, 1001, %STM_SETIMAGE, %IMAGE_ICON, hIcon
                            freelibrary hLib
                            DIALOG SHOW MODAL hDlg
                        
                        END FUNCTION
                        '

                        Comment


                        • #13
                          Dave
                          Code:
                           hIcon = LoadImage(hLib, BYVAL 701 , %IMAGE_bitmap, 256,256,%LR_DEFAULTCOLOR)
                          this works also 256, 256 sets the image size

                          again thanks

                          Comment


                          • #14
                            Originally posted by Stuart McLachlan View Post
                            One way would be to use ResourceHacker to identify them

                            http://www.angusj.com/resourcehacker
                            Problems with ResourceHacker, Win 10 and Shell32.dll

                            Just used Nirsoft's IconsExtract instead. It worked well and has a lot more capabilities that the PB code posted earlier.
                            https://www.nirsoft.net/utils/iconsext.html

                            Comment


                            • #15
                              Stuart McLachlan
                              Code:
                              #COMPILE EXE
                              #DIM ALL
                              #INCLUDE ONCE "WIN32API.INC"
                              #RESOURCE Bitmap, H, "retrivebmp1.bas"   'PRIME
                              
                              FUNCTION PBMAIN () AS LONG
                              LOCAL hDlg,hLib,hIcon AS DWORD
                              
                              DIALOG NEW 0, "Icon Demo",100,100,300,300, %WS_POPUP OR _
                              %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
                              %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
                              %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
                              OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                              
                              CONTROL ADD IMAGEX, hDlg, 1001, "H", 10, 8, 256, 256, %SS_BITMAP
                              hLib = LoadLibrary("shell32.dll") 'SHELL32.dll")
                              IF ISFALSE(hLib) THEN ? "Library not loaded":EXIT FUNCTION
                              hIcon = LoadImage(hLib,BYVAL 701,%IMAGE_bitmap, 0,0,%LR_DEFAULTCOLOR)' 256, 256,0)
                              IF ISFALSE(hICon) THEN ? "Icon not found":EXIT FUNCTION
                              SendDlgItemMessage hDlg, 1001, %STM_SETIMAGE, %IMAGE_bitmap, hIcon
                              freelibrary hLib
                              DIALOG SHOW MODAL hDlg
                              
                              END FUNCTION
                              you must prime the control first
                              Thanks

                              Comment


                              • #16
                                Originally posted by James C Morgan View Post
                                Stuart McLachlan
                                ...
                                you must prime the control first
                                Thanks
                                No need with my code (at least not with and PBWIn10.04., but I seem to recall something with LoadImage and earlier PBWIn 10?)


                                Comment


                                • #17
                                  if one uses control add label
                                  instead of control add image or imagex
                                  no prime
                                  Have not tried it in a imagelist for

                                  Thanks every one
                                  Gary Beene have not tried yours, wanted to save
                                  the Imagelist which should make a bitmap ribbon or bar
                                  Again thanks

                                  Comment


                                  • #18
                                    Code:
                                    FUNCTION FDF(FLN() AS STRING, FileExists AS LONG, LENG AS LONG) AS LONG
                                    ' FLN() FILE NAMES PASSED IN AN ARRY
                                    ' FileExists IS -1 TRUE 0 FALSE
                                    ' LENG IS LENGHT OF ARRAY
                                    ' TO FIND THE WINDOWS DIRECTORY API IS GetWindowsDirectory(zWinDir, %MAX_PATH
                                    ' IF YOU USE THE FOLLOWING YOU LOAD THE DLL INTO MEMORY AND PROGRAM
                                    ' hICON = LoadLibrary("SHELL32.DLL")
                                    'if hicon = 0 then ?"file shell32.dll not found"
                                    
                                    LOCAL FLS AS asciiz * %max_path 'STRING
                                    LOCAL TT AS LONG
                                    'LOCAL zSysDir AS ASCIIZ * %MAX_PATH
                                    GetSystemDirectory(fls, %MAX_PATH)
                                    fls = fls +"\"
                                    'FLS = ENVIRON$("SYSTEMROOT")+"\SYSTEM32\"
                                    
                                    FOR TT = 0 TO LENG
                                    
                                    
                                    FileExists = isfile(FLS+ FLN(TT))
                                    IF FileExists = -1 then ? FLN(TT) + " File Exist"
                                    NEXT
                                    FUNCTION = FileExists
                                    END FUNCTION
                                    JUST FOR INFO HOPE IT HELPS SOMEONE
                                    THANKS

                                    Comment


                                    • #19
                                      “Any CPU 32-bit preferred”. If you run such an executable on a 64-bit Windows operating system, then it will start as a 32-bit process and be affected by WOW64 file system redirection.

                                      When a 32-bit process on 64-bit Windows tries to access "C:\Windows\System32", WOW64 redirects it to "C:\Windows\SysWOW64". There are several ways to access the real "C:\Windows\System32" directory:

                                      THE ISFILE WOULD NOT FIND SHELL32.DLL
                                      I HAD TO PUT THE ADDRESS IN

                                      Comment

                                      Working...
                                      X