VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Extracts a single icon from a file. This file can be an executable (.exe) file, a dynamic link libr

by Martin McCormick (2 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 17th August 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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).

API Declarations





Rate Extracts a single icon from a file. This file can be an executable (.exe) file, a dynamic link libr



' C:\MyApp\Prog.exe on window Form1.  The icon must be destroyed after the
' program finishes using it.
Dim hIcon As Long  ' handle to the function gotten from the executable file
Dim retval As Long  ' return value

' Extract the first icon stored in the aforementioned executable file.
hIcon = ExtractIcon(App.hInstance, "C:\MyApp\Prog.exe", 0)
' Only attempt to display the icon if we successfully extracted it.
If hIcon = 0 Then
  Debug.Print "Failed to extract the icon -- aborting."
  End  ' terminate the program
Else
  ' Display the icon at coordinates (100, 75) on window Form1.
  retval = DrawIcon(Form1.hDC, 100, 75, hIcon)
  ' Although the icon's image is still visible, the icon itself is not in use.
  ' Therefore we destroy it to free up resources.
  retval = DestroyIcon(hIcon)
End If


Download this snippet    Add to My Saved Code

Extracts a single icon from a file. This file can be an executable (.exe) file, a dynamic link libr Comments

No comments have been posted about Extracts a single icon from a file. This file can be an executable (.exe) file, a dynamic link libr. Why not be the first to post a comment about Extracts a single icon from a file. This file can be an executable (.exe) file, a dynamic link libr.

Post your comment

Subject:
Message:
0/1000 characters