如何在Image控件上显示外部EXE的图标?
vb吧
全部回复
仅看楼主
level 1
快樂钚哆 楼主
我用 Image1.Picture=LoadPicture("C:\Windows\Explorer.exe,1")不行。请问正确方法。
2008年05月15日 07点05分 1
level 0
很简单,你可以把Explorer.exe的图标通过截屏的方式取下来(PrintScreen),把它保存成JPG图片,然后再用Image1.Picture=LoadPicture(App.Path & "\Explorer.jpg")就OK了注意:要把Explorer.jpg保存在工程所在的目录下,编译成EXE后要把它保存在EXE所在的目录下.
2008年05月15日 07点05分 2
level 6
使用API函数吧.'========================================================='The following API (ExtractIcon) extracts a single icon from'a file. This file can be an executable (.exe) file, a'dynamic link library (.dll), or an icon file (.ico).'Alternately, this function can also determine how many icons'are stored in such a file. The icon generated by this'function must be destroyed using DestroyIcon after the'program has finished using it.'PARAMETERS:'hInst:' A handle to the instance of the application calling' the function.'lpszExeFileName:' The name of an .exe, .dll, or .ico to' extract an icon from.'nIconIndex:' If this is -1, the function returns the number' of icons stored in the specified file. If this' is a non-negative number, the function extracts' the icon using this value as the zero-based' index.'=========================================================Public Declare Function ExtractIcon Lib "shell32.dll" _ Alias "ExtractIconA" (ByVal hInst As Long, _ ByVal lpszExeFileName As String, _ ByVal nIconIndex As Long) As Long
2008年05月15日 11点05分 4
level 6
这个函数可以返回一个在exe或者dll中的图标的句柄,也可以返回该文件中图标的个数.当返回的图标不再使用时,你需要调用DestroyIcon来释放.参数有3个,应用程序的hInstance;exe或者dll文件路径;图标索引,如果索引值是-1,则返回图标的个数;对于其他非0值,返回对应索引的图标.0是第一个图标,1是第二个...调用范例hIcon = ExtractIcon(App.hInstance, fileNameWithPath, IconNumber)取得hIcon后,可以使用函数DrawIcon把图标绘制到PictureBox上(Image控件不支持绘图)
2008年05月15日 11点05分 5
level 6
哦,更正一下,上面的非0值应该是非负值,打错了...
2008年05月15日 11点05分 6
level 0
4楼 的符合我的意思。辛苦了。谢谢你。、还有谢谢所有热心的朋友。
2008年05月15日 14点05分 7
1