|
-
Jul 30th, 2000, 09:47 AM
#1
Thread Starter
Hyperactive Member
Hi,
I'm creating a little utility that extracts an icon from a *.exe or *.dll. I'm sure many of you have done it using the ExtractIcon API. Anyway, the programs just about finished except for one feature, saving the icon. The icon is stored inside a variable called lngIcon so how would I save it in the format of *.ico? Thanks
-
Jul 30th, 2000, 10:34 AM
#2
Try this.
Make a Form with a PictureBox, ImageList and CommandButton
Code:
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Private Declare Function DestroyIcon Lib "user32.dll" (ByVal hIcon As Long) As Long
Private Sub Command1_Click()
'Extract the Icon and Draw it
Retval = ExtractIcon(App.hInstance, "C:\Windows\Calc.exe", 0)
DrawIcon Picture1.hdc, 0, 0, Retval
Picture1.Picture = Picture1.Image
'Convert the Bitmap to an Icon
ImageList1.ListImages.Add 1, "Calc", Picture1.Picture
Set Picture1.Picture = ImageList1.ListImages(1).ExtractIcon
'Save the file
SavePicture Picture1.Picture, "C:\Windows\Desktop\ttt.ico"
'Free up resources
DestroyIcon (Retval)
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
End Sub
-
Jul 30th, 2000, 10:39 AM
#3
Thread Starter
Hyperactive Member
Thanks Megatron,
I'll give that a try.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|