Extract Icons from exe applications or dlls-gdiplusX - partI

Published on by Yousfi Benameur

 
In this first part we studay only the gdiplus class Solution from xfcIcon class.in the second part we studay that with APIS exclusively.    
Exe and dlls can encapsulate many resources as icon files.these icons are compiled with projects and can be extracted easily with the gdiplusX function ExtractAssociatedIcon from the xfcIcon class(retrieves 32x32 icon format only).

these codes are similar and  do the following :
1-can extract icons to ico,png,bmp,jpg or gif file gathered in a folder.then can choice the destination format image of destination.
2-can extract directly to image pictureVal property and show these icons as blob image format on a form.We extract physically anything here.
3-can do same thing viewing all on a web page.

if the ico format(32x32) is choosen and depth=8 bits then cannot see them on the form (color depth=8  dont  shown on vfp image  control)  nor on the web page (only images)!

i dont recommend to extract icons with this function.extract only images (png,jpg,bmp,gif..).see the iconextract api it extracts icons with valid format and can be embed in image control or loaded by loadpicture() function.

-below 7 codes relative to subject.
-some questions stay yet unanswered.....to follow...


Click on code to select [then copy] -click outside to deselect


    *1*
*this code dont use any physical image extracted but uses the pictureVAl image property to display icons directly on form
*PictureVal Specifies a character string expression or object that represents an image.
*If eExpression is a string expression, it must be a valid expression that GDI+ can use to render an image.
*the form is scrollable

*try this code on this usefull test: c:\windows\system32\shell32.dll


Clea Resources
Clea All
Publi m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)

Do Locfile('system.app','app',"where is system.app of gdiplusX project ? ")

Publi yform
yform=Newobject("asup")
yform.Show
Read Events
Retu
*
Define Class asup As Form
    Top = 15
	Left = 88
	Height = 561
	Width = 843
	ShowWindow = 2
	ScrollBars = 2
	ShowTips = .T.
	Caption = "icons extract"
	Name = "Form1"

	Procedure yextract

	Local  i,lnindex
	Local loicon As xfcicon
	Local lobmp As xfcbitmap
	Wait Window "E x t r a c t i n g   i c o n s  ......" At  Srows()/2,Scols()/2-20 Nowait
	i = 0
	With _Screen.System.drawing
		Do While .T.
			loicon = .Icon.extractassociatedicon(Thisform.filename, i)
			If Isnull(loicon)
				Exit
			Endif
			lobmp = loicon.tobitmap()
			Try
				oo=Eval("thisform.img"+Trans(i))
				oo.PictureVal = lobmp.getpictureval (.imaging.imageformat.png)   &&m.ytype
				oo.ToolTipText=Trans(i)
			Catch
			Endtry
			i = i + 1
		Enddo
	Endwith
	lnindex=i
	Wait Clea
	Wait Clea
	Thisform.Caption=Trans(lnindex+1)+"  icons  extracted from "+Allt(Thisform.filename)

	With  Thisform
		For i=lnindex To .ControlCount
			Try
				.RemoveObject(.Controls(i).Name)
			Catch
			Endtry
		Endfo
	Endwith
	Endproc

	Procedure Init
	Thisform.AddProperty("filename","")
	Local  lnindex
	Local loicon As xfcicon
	Local lobmp As xfcbitmap
	With Thisform
		.filename = Getfile("exe;ico;dll","") && _vfp.servername
		If Empty(.filename)
			Return .F.
		Endi
	Endwith

	i = 0  && icon index
	With _Screen.System.drawing
		Do While .T.
			loicon = .Icon.extractassociatedicon(Thisform.filename, i)
			If Isnull(loicon)
				Exit
			Endif

			i = i + 1
		Enddo
	Endwith
	lnindex=i
	Local delta
	m.delta=7
	***************
	With Thisform
		j=0
		For i=1 To lnindex
			.AddObject("img"+Trans(i),"image")
			m.oo=Eval(".img"+Trans(i))
			With m.oo
				If j=0
					.Left=10
					.Top=10
				Else
					.Left=Eval(".parent.img"+Trans(i-1)+".left")+Eval(".parent.img"+Trans(i-1)+".width")+m.delta
					.Top =Eval(".parent.img"+Trans(i-1)+".top")
				Endi

				.Width=48
				.Height=48
				.Stretch=2
				.ToolTipText=.PictureVal
				.Name="img"+Trans(i)
				.Visible=.T.
				j=j+1
				If j>15  &&15 images per row
					.Left=10
					.Top=Eval('.parent.img'+Trans(i-1)+".top")+Eval(".parent.img"+Trans(i-1)+".height")+m.delta
					j=1
				Endi
				*bindevent(m.oo,"rightclick",thisform,"my")
			Endwith
		Endfor
	Endwith
	Thisform.yextract()
	Endproc

procedure destroy
clea events
Endproc


Enddefine
*
*-- EndDefine: asup
**************************


 

shell32.dll is used by windows os when you change app icon (dialog box like this image above)

shell32.dll is used by windows os when you change app icon (dialog box like this image above)

Click on code to select [then copy] -click outside to deselect

 
*2*
*extract icons from exe,dll and gather them into a folder...view with ie browser application as web page.
*ie contextmenu is still enabled.
*try this code on this usefull test: c:\windows\system32\shell32.dll

Clea Resources
Clea All
Do Locfile("system.app","app","where is system.app of gdiplusX project ?")
Set Safe Off

Publi m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)
******************
Try
    If ! Directory(m.yrep+"yicons")
		Md (m.yrep+"yicons")
	Else
		w=Adir(gabase1,m.yrep+"*.*")
		Wait Window "deleting "+Trans(w)+" icons files...." At Srow()/2,Scol()2-20 Nowait
		Dele File (m.yrep+"yicons\*.*") recycle
		Wait Clea
	Endi
Catch
	Messagebox("An error was occured when deleting images in "+m.yrep+"yicons\...do this operation manually!",16+4096,"error",2000)
Endtry

Local m.ytype
m.ytype=Inputbox("Extract icons to : ico,png,jpg,bmp,gif","","png")
If ! Inlist(Lower(m.ytype),"ico","png","jpg","bmp","gif")
	Return .F.
Endi
m.ytype="."+Lower(m.ytype)

Local lcfile, lnindex,lcfile1
Local loicon As xfcicon
Local lobmp As xfcbitmap
lcfile = Getfile("exe;ico;dll") && _vfp.servername
lnindex = 0
With _Screen.System.drawing
	Do While .T.
		loicon = .Icon.extractassociatedicon(lcfile, lnindex)
		If Isnull(loicon)
			Exit
		Endif
	m.lcfile1 = m.yrep+"yicons\"+ Juststem(m.lcfile) + Transform(lnindex) + m.ytype
		Wait Window(m.lcfile1) Nowait
		lobmp = loicon.tobitmap()
		Do Case
		Case m.ytype=".ico"
			lobmp.Save(m.lcfile1, .imaging.imageformat.Icon)
		Case m.ytype=".png"
			lobmp.Save(m.lcfile1, .imaging.imageformat.png)
		Case m.ytype=".jpg"
			lobmp.Save(m.lcfile,1 .imaging.imageformat.JPEG)
		Case m.ytype=".bmp"
			lobmp.Save(m.lcfile1, .imaging.imageformat.bmp)
		Case m.ytype=".gif"
			lobmp.Savem(m.lcfile1, .imaging.imageformat.gif)
		Endcase
		lnindex = lnindex + 1
	Enddo
Endwith
Wait Clea
Messagebox(Trans(lnindex+1)+" "+Substr(m.ytype,2)+" extracted!",0+32+4096,"",1000)
*****************
Local gnbre,delta
m.delta=8
gnbre=Adir(gabase,m.yrep+"yicons\*.*")

If gnbre=0
	Return .F.
Endi

j=0
Local m.xx
TEXT to m.xx noshow
	<body bgcolor=black topmargin=10  leftmargin=10>
	<input type="button" value="X" style="color:red;background-color:lime;cursor:hand;float:right;" onclick="window.close();">
<br><br>
<center><table>
ENDTEXT
m.yy=""
For i=1 To gnbre
	m.yy=m.yy+"<td><img src='file:///"+Allt(m.yrep+"yicons\"+gabase(i,1))+[' title="]+allt(gabase(i,1))+[" width='48' height='48' border="1"></td>]+Chr(13)
	j=j+1
	If j>15   &&15 images per row
		j=1
		m.yy="<tr>"+m.yy+"</tr>"+Chr(13)
	Endi
Endfor
m.yy=m.yy+"</table></center>"

m.xx=m.xx+"<center><h2 style='color:red;background-color:navy;width:800;'> "+Trans(lnindex+1)+" "+Substr(m.ytype,2)+" extracted as "+Substr(m.ytype,2)+" from "+m.lcfile+"</h2><center><br>"+Chr(13)+m.yy

Local m.myvar
TEXT to m.myvar textmerge noshow
<<m.xx>>
ENDTEXT

Set Safe Off
Local m.lcdest
m.lcdest=Addbs(Sys(2023))+"yicons.html"
Strtofile(m.myvar,m.lcdest)
*********************************************
Declare Integer BringWindowToTop In user32 Integer
Publi apie
apie=Newobject("internetexplorer.application")
With apie
	.Navigate(m.lcdest)
	.fullscreen=1
	BringWindowToTop(.HWnd)
	.Visible=.T.
Endwith




 Extract Icons from  exe applications or dlls-gdiplusX - partI
 Extract Icons from  exe applications or dlls-gdiplusX - partI

Click on code to select [then copy] -click outside to deselect


*3*
*extract icons from exe,dll and gather them into a folder...view  on *images controls on the form.

*try this code on this usefull test: c:\windows\system32\shell32.dll

Clea Resources
Clea All

Do Locfile("system.app","app")

Set Safe Off
Publi m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)


Publi oform
oform=Newobject("asup")
oform.Show
Read Events
Retu
*
Define Class asup As Form
    Top = 15
	Left = 88
	Height = 543
	Width = 891
	ShowWindow = 2
	ScrollBars = 2
	ShowTips = .T.
	Caption = "icons extractor"
	Name = "Form1"

	Procedure Init
	Try
		If ! Directory(m.yrep+"yicons")
			Md (m.yrep+"yicons")
		Else
			Wait Window "cleaning folder icons...." Nowait
			Dele File (m.yrep+"yicons\*.*")    &&recycle
			Wait Clea
		Endi
	Catch
		Messagebox("An error was occured when deleting images in "+m.yrep+"yicons\...do this operation manually!",16+4096,"error",2000)
	Endtry

	Local m.ytype
	m.ytype=Inputbox("Extract icons to : ico,png,jpg,bmp,gif","","png")
	If ! Inlist(Lower(m.ytype),"ico","png","jpg","bmp","gif")
		Return .F.
	Endi
	m.ytype="."+Lower(m.ytype)

	Local lcfile, lnindex,lcfile1
	Local loicon As xfcicon
	Local lobmp As xfcbitmap
	m.lcfile = Getfile("exe;ico;dll") && _vfp.servername
	If Empty(m.lcfile)
		Return .F.
	Endi

	m.lnindex = 0
	With _Screen.System.drawing
		Do While .T.
			loicon = .Icon.extractassociatedicon(m.lcfile, lnindex)
			If Isnull(loicon)
				Exit
			Endif
			lcfile1 = m.yrep+"yicons\"+ Juststem(m.lcfile) + Transform(lnindex) + m.ytype
			Wait Window(lcfile1) Nowait
			lobmp = loicon.tobitmap()
			Do Case
			Case m.ytype=".ico"
				lobmp.Save(m.lcfile1, .imaging.imageformat.Icon)
			Case m.ytype=".png"
				lobmp.Save(m.lcfile1, .imaging.imageformat.png)
			Case m.ytype=".jpg"
				lobmp.Save(m.lcfile1, .imaging.imageformat.JPEG)
			Case m.ytype=".bmp"
				lobmp.Save(m.lcfile1, .imaging.imageformat.bmp)
			Case m.ytype=".gif"
				lobmp.Save(m.lcfile1, .imaging.imageformat.gif)
			Endcase
			lnindex = lnindex + 1
		Enddo
	Endwith
	Wait Clea
	Messagebox(Trans(lnindex+1)+" "+Substr(m.ytype,2)+" extracted!",0+32+4096,"",1000)
	*****************
	Local gnbre,delta
	m.delta=8
	gnbre=Adir(gabase,m.yrep+"yicons\*.*")

	If gnbre=0
		Return .F.
	Endi

	With Thisform
		j=0
		For i=1 To gnbre
			.AddObject("img"+Trans(i),"image")
			With Eval(".img"+Trans(i))
				If j=0
					.Left=10
					.Top=10
				Else
					.Left=Eval(".parent.img"+Trans(i-1)+".left")+Eval(".parent.img"+Trans(i-1)+".width")+m.delta
					.Top =Eval(".parent.img"+Trans(i-1)+".top")
				Endi

				.Width=48
				.Height=48
				.Stretch=2
				.Picture=m.yrep+"yicons\"+gabase(i,1)
				.ToolTipText=Justfname(.Picture)
				.Visible=.T.
				j=j+1
				If j>15   &&15 images per row
					.Left=10
					.Top=Eval('.parent.img'+Trans(i-1)+".top")+Eval(".parent.img"+Trans(i-1)+".height")+m.delta
					j=1
				Endi
			Endwith
		Endfor
		.Caption=Trans(lnindex+1)+" "+Substr(m.ytype,2)+" extracted as "+Substr(m.ytype,2)+" from "+m.lcfile
	Endwith
	Endproc

	Procedure Destroy
	Clea Events
	Endproc

Enddefine
*
*-- EndDefine: asup
**************************************************



 Extract Icons from  exe applications or dlls-gdiplusX - partI
 Extract Icons from  exe applications or dlls-gdiplusX - partI

Click on code to select [then copy] -click outside to deselect


*4*
 *extract icons from exe,dll and gather them into a folder (png format)...view with ie browser application as pellicule of PNGs
*ie contextmenu enabled.

*try this code on this usefull test: c:\windows\system32\shell32.dll

Do Locfile("system.app","app")
Set Safe Off

Publi m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)
******************
Try
    If ! Directory(m.yrep+"yicons")
		Md (m.yrep+"yicons")
	Else
		w=Adir(gabase1,m.yrep+"*.*")
		Wait Window "deleting "+Trans(w)+" icons files...." At Srow()/2,Scol()2-20 Nowait
		Dele File (m.yrep+"yicons\*.*") recycle
		Wait Clea
	Endi
Catch
	Messagebox("An error was occured when deleting images in "+m.yrep+"yicons\...do this operation manually!",16+4096,"error",2000)
Endtry

Local m.ytype
m.ytype=Inputbox("Extract icons to : ico,png,jpg,bmp,gif","","png")
If ! Inlist(Lower(m.ytype),"ico","png","jpg","bmp","gif")
	Return .F.
Endi
m.ytype="."+Lower(m.ytype)

Local lcfile, lnindex
Local loicon As xfcicon
Local lobmp As xfcbitmap
m.lcfile = Getfile("exe;ico;dll") && _vfp.servername
lnindex = 0
With _Screen.System.drawing
	Do While .T.
		loicon = .Icon.extractassociatedicon(m.lcfile, lnindex)
		If Isnull(loicon)
			Exit
		Endif
		lcfile1 = m.yrep+"yicons\"+ Juststem(m.lcfile) + Transform(lnindex) + m.ytype
		Wait Window(lcfile1) Nowait
		lobmp = loicon.tobitmap()
		Do Case
		Case m.ytype=".ico"
			lobmp.Save(m.lcfile1, .imaging.imageformat.Icon)
		Case m.ytype=".png"
			lobmp.Save(m.lcfile1, .imaging.imageformat.png)
		Case m.ytype=".jpg"
			lobmp.Save(m.lcfile1, .imaging.imageformat.JPEG)
		Case m.ytype=".bmp"
			lobmp.Save(m.lcfile1, .imaging.imageformat.bmp)
		Case m.ytype=".gif"
			lobmp.Save(m.lcfile1, .imaging.imageformat.gif)
		Endcase
		lnindex = lnindex + 1
	Enddo
Endwith
Wait Clea
Messagebox(Trans(lnindex+1)+" "+Substr(m.ytype,2)+" extracted!",0+32+4096,"",1000)
*****************
Local gnbre,delta
m.delta=8
gnbre=Adir(gabase,m.yrep+"yicons\*.*")

If gnbre=0
	Return .F.
Endi

*j=0
Local m.xx
TEXT to m.xx noshow
	<body bgcolor=black topmargin=10  leftmargin=10>
	<input type="button" value="X" style="color:red;background-color:lime;cursor:hand;float:right;" onclick="window.close();">
<br><br>
<center><table><tr>
ENDTEXT
m.yy=""
For i=1 To gnbre
	m.yy=m.yy+"<td><img src='file:///"+Allt(m.yrep+"yicons\"+gabase(i,1))+[' title="]+Allt(gabase(i,1))+[" width='48' height='48' border="1"></td>]+Chr(13)
Endfor
m.yy=m.yy+"</tr></table></center>"

m.xx=m.xx+"<center><h2 style='color:red;background-color:navy;width:800;'> "+Trans(lnindex+1)+" "+Substr(m.ytype,2)+" extracted as "+Substr(m.ytype,2)+" from "+m.lcfile+"</h2><center><br>"+Chr(13)+m.yy

Local m.myvar
TEXT to m.myvar textmerge noshow
<<m.xx>>
ENDTEXT

Set Safe Off
Local m.lcdest
m.lcdest=Addbs(Sys(2023))+"yicons.html"
Strtofile(m.myvar,m.lcdest)
*********************************************
Declare Integer SetWindowText In user32 Integer,String
Declare Integer BringWindowToTop In user32 Integer
Publi apie
apie=Newobject("internetexplorer.application")
With apie
	.Navigate(m.lcdest)
	.Height=300
	.Width=Sysmetric(1)-20
	.Left=0
	.Top=0
	.menubar=0
	.Toolbar=0
	.StatusBar=0
	.Resizable=1
	SetWindowText(.HWnd,"Icon extractor as PNGs pellicule ")
	BringWindowToTop(.HWnd)
	.Visible=.T.
Endwith




 Extract Icons from  exe applications or dlls-gdiplusX - partI

Click on code to select [then copy] -click outside to deselect


*5*
*save as Anyimage2ico.prg
 *convert any image convert to ico (can compile an exe as utility).

*Note:he gdiplusX project must be updated and recompiled to new system.app if not the case (system.drawing.prg :replace  xfcIcon.save function)
*(to verify first before running this code below otherwise icon delivred with bad quality).
*refrences:
*http://vfpx.codeplex.com/workitem/12534
*Foxite forum discussion :http://www.foxite.com/archives/jpg-format-to-ico-format-0000207496.htm

*this code produces an ico 48x48 from an image and with color depth=32

do locfile("system.app")
local m.yrep,lnWidth,lnHeight
m.yrep=addbs(justpath(sys(16,1)))

with _screen.system.drawing as xfcdrawing && convert the original bitmap to ensure better quality and compatibility
m.lnWidth=48
m.lnHeight=48
local loPitc as xfcBitmap
loPict= .bitmap.new(.bitmap.fromfile(getpict()), m.lnWidth,m.lnHeight)

* create icon object
local loicon as xfcicon
loicon = .icon.fromhandle(loPict.gethicon())
*** high quality icons-  setting the tlquality flag to .t.
* save sending filename
loicon.save(m.yrep+"icon_save_filename_highqual.ico", .t.)
endwith

run/n explorer &yrep

*my remarks
*the function LOADPICTURE([cFileName]) :Creates an object reference for a *bitmap, icon, or Windows meta file.
*when applied to loaded icon created with this method, returns error ??
 



Click on code to select [then copy] -click outside to deselect

 
 *6*
 *save this code as AnyIcon2Image.prg
 *The reverse of the code above AnyIcon2Image can be simply cut from the *first code. any icon can be saved as image (with dimensions set by user) *to PNG,JPG,BM,GIF....
*convert any icon to an image (png,jpg,bmp,gif....) or even icon (pb color depth=8)

Do Locfile("system.app","app")
Set Safe Off

Publi m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)


Local loicon
m.loicon=Getfile('ico')
If Empty(m.loicon) Or ! Inlist (Lower(Justext(m.loicon)),"ico")
    Return .F.
Endi


Local m.ytype
m.ytype=Inputbox("Convert icon to : png,jpg,bmp,gif","","png")
If ! Inlist(Lower(m.ytype),"png","jpg","bmp","gif","ico")
	Return .F.
Endi
m.ytype="."+Lower(m.ytype)


Local lobmp ,lobmp1 As xfcbitmap
Local lcfile
With _Screen.System.drawing
	lnWidth=48
	lnHeight=48
	lobmp =.Bitmap.fromfile(m.loicon)
	lobmp1=.Bitmap.new(lobmp,lnWidth,lnHeight,.Imaging.PixelFormat.Format32bppARGB)

	m.lcfile = m.yrep+ Juststem(m.loicon) + m.ytype
    

	Do Case
	Case m.ytype=".ico"
    *save to high quality (param= .t.)
	m.lcfile = m.yrep+ Juststem(m.loicon) +"b"+ m.ytype
    lobmp1.Save(m.lcfile, .imaging.imageformat.Icon,.t.)  &&pb color depth=8 always ??
	Case m.ytype=".png"
		lobmp1.Save(m.lcfile, .imaging.imageformat.png)
	Case m.ytype=".jpg"
		lobmp1.Save(m.lcfile, .imaging.imageformat.JPEG)
	Case m.ytype=".bmp"
		lobmp1.Save(m.lcfile, .imaging.imageformat.bmp)
	Case m.ytype=".gif"
		lobmp1.Save(m.lcfile, .imaging.imageformat.gif)
	Endcase

Endwith

Run/N explorer /select,&lcfile
*Remarks: one problem in converting icon to another  icon.the color depth=8 and can not be seen in image control of vfp ?? also the icon created dont skin as ico in explorer ?


Click on code to select [then copy] -click outside to deselect


*7*
 *built windows systems special IDI icons as png images on form
#Define IDI_APPLICATION    32512
#Define IDI_ASTERISK       32516
#Define IDI_ERROR          32513
#Define IDI_EXCLAMATION    32515
#Define IDI_QUESTION       32514
#Define IDI_WINLOGO        32517
#Define IDI_WARNING        IDI_EXCLAMATION
#Define IDI_HAND           IDI_ERROR  &&??
#Define IDI_INFORMATION    IDI_ASTERISK
#Define IDI_SHIELD         32518    

*these constants are already defined in system.drawing.h (from winuser.h)-can refer to it with #include header statement.
*can also use pictureVal image control property if dont want physicall built images (bitmap1.getpictureval (.imaging.imageformat.png)   

Do Locfile("system.app","app")
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)
With _Screen.System.drawing
    Local bitmap1 As xfcBitmap
	Local m.lcdest,w,h
	w=48
	h=48
	For I=1 To 10
		m.lcdest=m.yrep+"IDI_"
		Do Case
    	Case I=1
			m.lhIcon = xfcLoadIcon(0, IDI_APPLICATION)
			m.lcdest=m.lcdest+"APPLICATION"+".png"
		Case I=2
			m.lhIcon = xfcLoadIcon(0, IDI_ASTERISK )
			m.lcdest=m.lcdest+"ASTERISK"+".png"
		Case I=3
			m.lhIcon = xfcLoadIcon(0, IDI_ERROR)
			m.lcdest=m.lcdest+"ERROR"+".png"
		Case I=4
			m.lhIcon = xfcLoadIcon(0, IDI_EXCLAMATION)
			m.lcdest=m.lcdest+"EXCLAMATION"+".png"
		Case I=5
			m.lhIcon = xfcLoadIcon(0, IDI_QUESTION)
			m.lcdest=m.lcdest+"QUESTION"+".png"

		Case I=6
			m.lhIcon = xfcLoadIcon(0,IDI_WINLOGO)
			m.lcdest=m.lcdest+"WINLOGO"+".png"
		Case I=7
			m.lhIcon = xfcLoadIcon(0,IDI_WARNING)
			m.lcdest=m.lcdest+"WARNING"+".png"
		Case I=8
			m.lhIcon = xfcLoadIcon(0, IDI_HAND)
			m.lcdest=m.lcdest+"HAND"+".png"
		Case I=9
			m.lhIcon = xfcLoadIcon(0, IDI_INFORMATION)
			m.lcdest=m.lcdest+"INFORMATION"+".png"
         Case I=10
    		m.lhIcon = xfcLoadIcon(0, IDI_SHIELD)
			m.lcdest=m.lcdest+"SHIELD"+".png"	   
			
		Endcase

		bitmap1=. Bitmap.FromHicon(m.lhIcon)
		bitmap1.Save(m.lcdest,.imaging.imageformat.png,.T.)
	Endfor
Endwith
* run/n explorer /select,&lcdest
*************************************
oform=Newobject("asup")
oform.Show
Read Events
*
Define Class asup As Form
	Top = 24
	Left = 137
	Height = 83
	Width = 570
	Caption = "System IDI icons"
	MaxButton = .F.
	MinButton = .F.
	ShowWindow=2
	ShowTips=.T.
	BackColor=0
	Name = "Form1"

	Add Object image2 As Image With ;
		Height = 48, ;
		Left = 31, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_APPLICATION.PNG",;
		tooltiptext="IDI_APPLICATION.PNG"
	Name = "Image2"

	Add Object image1 As Image With ;
		Height = 48, ;
		Left = 84, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_ASTERISK.png",;
		tooltiptext="IDI_ASTERISK.png"
	Name = "Image1"

	Add Object image3 As Image With ;
		Height = 48, ;
		Left = 138, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_ERROR.PNG",;
		tooltiptext="IDI_ERROR.PNG"
	Name = "Image3"

	Add Object image4 As Image With ;
		Height = 48, ;
		Left = 191, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_EXCLAMATION.PNG",;
		tooltiptext="IDI_EXCLAMATION.PNG"
	Name = "Image4"

	Add Object image5 As Image With ;
		Height = 48, ;
		Left = 245, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_QUESTION.png",;
		tooltiptext="IDI_QUESTION.png"
	Name = "Image5"


	Add Object image6 As Image With ;
		Height = 48, ;
		Left = 296, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_warning.png",;
		tooltiptext="IDI_warning.png"
	Name = "Image6"


	Add Object image7 As Image With ;
		Height = 48, ;
		Left = 347, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_exclamation.png",;
		tooltiptext="IDI_exclamation.png"
	Name = "Image7"


	Add Object image8 As Image With ;
		Height = 48, ;
		Left = 398, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_hand.png",;
		tooltiptext="IDI_hand.png"
	Name = "Image8"

	Add Object image9 As Image With ;
		Height = 48, ;
		Left = 449, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_winlogo.png",;
		picture="IDI_information.png",;
		tooltiptext="IDI_information.png",;
		Name = "Image9"
      
      Add Object image10 As Image With ;
    	Height = 48, ;
		Left =500, ;
		Top = 13, ;
		Width = 48, ;
		picture="IDI_shield.png",;
		tooltiptext="IDI_SHIELD.png",;
		Name = "Image10"

	Procedure Destroy
	Clea Events
	Endproc

Enddefine
*
*-- EndDefine: asup
*************************




 

 Extract Icons from  exe applications or dlls-gdiplusX - partI
 
*Important:*the code above is tested on visual foxpro 9 sp2-under windows 10 pro

To be informed of the latest articles, subscribe:
Comment on this post