vb.net - How Do i Extracting the Highest Resolution icon from program -
i'm makeing program mimics desktop, i've got working i'm getting lowest resolution out icons.
i need of icons files in set path, these icons need best can (256x256).
want icon files .exe .lnk .url .txt .png . jpg
shortend verstion have currently.(i remove part don't have affect on icons)
public class form1 dim counter integer = 0 dim iconarray(200) picturebox dim titlearray(200) label dim linker(200) string public sub loading(sender object, e eventargs) handles mybase.load apps_on_screen.items.addrange(io.directory.getfiles("c:\users\public\desktop")) 'gets files on desktop , adds them listbox threading.thread.sleep(0) 'waits till file have been got desktop dim icon_position_x = 0, icon_position_y = 5 'sets start x , y icons dim title_position_x = 0, title_position_y = 55 'sets start x , y text under icons integer = 0 apps_on_screen.items.count - 1 'loops every item in listbox dim icon new picturebox 'creates new picturebox icon.backgroundimagelayout = imagelayout.zoom 'changes zoom images fits icon.backcolor = color.transparent 'makes picturebox transparent icon.name = "icon" & 'gives picturebox name referance later icon.size = new size(78, 51) 'sets picturebox size icon.location = new point(icon_position_x, icon_position_y) 'sets pictureboxs x , y me.controls.add(icon) 'adds picturebox controls iconarray(i) = icon 'adds picturebox array easyer use later iconarray(i).bringtofront() addhandler icon.doubleclick, addressof me.start_link 'adds double click handler picturebox on sub icon_position_y += 101 'changes y postion on next picturebox if (icon_position_y + 50) >= screen.primaryscreen.workingarea.height 'when picture box reaches bottom of sceen y resets , x gets increased icon_position_y = 5 icon_position_x += 78 end if 'same above, label dim title new label title.name = "title" & title.size = new size(78, 51) title.location = new point(title_position_x, title_position_y) title.forecolor = color.white title.backcolor = color.transparent title.textalign = contentalignment.topcenter title.font = new font("microsoft sans serif", 9) me.controls.add(title) titlearray(i) = title title.bringtofront() addhandler title.doubleclick, addressof me.start_link title_position_y += 101 if title_position_y >= screen.primaryscreen.workingarea.height title_position_y = 55 title_position_x += 78 end if next set_icons() end sub public sub set_icons() 'most pc's have "this pc" on desktop iconarray(0).backgroundimage = fake_background.my.resources.this_pc titlearray(0).text = "this pc" linker(0) = "c:\windows\explorer.exe" counter = 1 each item in apps_on_screen.items 'loops every item in listbox try 'just here incase crashes linker(counter) = item 'adds item array use start programs iconarray(counter).backgroundimage = icon.extractassociatedicon(item).tobitmap 'gets 32x32 icon item sets icons background dim extension = io.path.getextension(item) 'gets extension item, used later item = io.path.getfilename(item) 'gets items name e.g item = "c:\users\public\desktop\hi.txt" item = "hi.txt" if item = "desktop.ini" '"desktop.ini" didn't want work thats why have code @ top of sub counter -= 1 else item = item.replace(extension, "") 'removes extension item e.g item = "hi.txt" item = "hi" titlearray(counter).text = item 'sets display text item 'this part how higher res icons item = item.replace(" ", "-") 'replaces " " "-" 'i've got bunch of images of icons in resources iconarray(counter).backgroundimage = directcast(my.resources.resourcemanager.getobject(item), bitmap) 'seaches item in resources if found add set icons background end if catch ex exception end try counter += 1 next end sub public sub start_link(sender object, e eventargs) 'i don't know how explane dim start = 0 if sender.name.contains("icon") start = val(replace(sender.name, "icon", "")) if sender.name.contains("title") start = val(replace(sender.name, "title", "")) try process.start(linker(start)) catch ex exception if linker(start).contains(" (x86)") 'some programs didn't want work added fix linker(start) = replace(linker(start), " (x86)", "") process.start(linker(start)) end if end try end sub end class
this code grabs 32x32 size images of icon compair desktop, in program
is there way me best resolution icon.
can post code? i've spent hour looking around following links, it's in c# , not me.
thanks ~gamer_sa22
Comments
Post a Comment