Extracting and displaying folder icons

Hi everyone,

I'm having a problem to extract the "Folder Icon" on the disk drive, the only icon can be displayed on the list view is the file icon. Here is a part of my code:

Private Sub ShowFiles()
  Dim dir() As String
  Dim en As System.Collections.IEnumerator
  Dim myIcon As System.Drawing.Icon
  Dim shinfo As New SHFILEINFO
  Dim hImgSmall As IntPtr
  Dim hImgLarge As IntPtr
  Dim fName As String
  Dim fSize As String
  Dim fType As String
  Dim fModified As String

  dir = System.IO.Directory.GetFiles(cboxDrives.Text)
  lvwFiles.SmallImageList = ImageList2
  lvwFiles.LargeImageList = ImageList2
  shinfo.szDisplayName = New String(Chr(0), 260)
  shinfo.szTypeName = New String(Chr(0), 80)
  en = dir.GetEnumerator
  While en.MoveNext
     fName = CStr(en.Current)
     Dim fInfo As New System.IO.FileInfo(fName)
     fSize = Str(Math.Ceiling(fInfo.Length / 1024))
     fType = fInfo.Extension
     fModified = fInfo.LastWriteTime
     Dim fileItem As New Windows.Forms.ListViewIte(GetNameFromPathAndName _
                                      (fName), nIndex)
     Dim sub1 As New Windows.Forms.ListViewItem.ListViewSubItem(fileItem, _
                                          fSize + " KB")
     Dim sub2 As New Windows.Forms.ListViewItem.ListViewSubItem(fileItem,            
     Dim sub3 As New Windows.Forms.ListViewItem.ListViewSubItem(fileItem, _
     hImgSmall = SHGetFileInfo(fName, 0, shinfo, Marshal.SizeOf(shinfo), _
                         SHGFI_ICON Or SHGFI_SMALLICON)
     myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon)
     ImageList2.Images.Add(myIcon) 'Add icon to imageList.
     nIndex = nIndex + 1
  End While
End Sub

Can anyone please help how to do this in VB.Net??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
The project here will show you how to do everything and anything you ever wanted to know about how to make a "windows explorer" type interface.  It is heavily commented and pretty easy to understand.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.