I don't think I'll need any help.
I copied the code and then stripped almost everything.
Ended with :
Option Strict Off
Option Explicit On
Imports Shell32
Public Class FolderExplorerControl
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Inherits System.Windows.Forms.UserControl
#Region "Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
If Disposing Then
If Not components Is Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(Disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents tvFolders As System.Windows.Forms.TreeView
Private Sub InitializeComponent()
Me.tvFolders = New System.Windows.Forms.TreeView
Me.SuspendLayout()
'
'tvFolders
'
Me.tvFolders.ImageIndex = -1
Me.tvFolders.Location = New System.Drawing.Point(144, 128)
Me.tvFolders.Name = "tvFolders"
Me.tvFolders.SelectedImageIndex = -1
Me.tvFolders.Size = New System.Drawing.Size(568, 256)
Me.tvFolders.TabIndex = 0
'
'FolderExplorerControl
'
Me.Controls.Add(Me.tvFolders)
Me.Font = New System.Drawing.Font("Arial", 8.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Name = "FolderExplorerControl"
Me.Size = New System.Drawing.Size(856, 552)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub FolderExplorerControl_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Added a reference to Shell32 by browsing to shell32.dll
Dim shell32q As Shell32.ShellClass = New Shell32.ShellClass
Dim shell32Folder As Shell32.Folder =
shell32q.NameSpace(Shell32.ShellSpecialFolderConstants.ssfDESKTOPDIRECTORY)
Dim items As shell32.FolderItems = shell32Folder.Items()
Dim dfolder As Shell32.Folder =
shell32q.NameSpace(Shell32.ShellSpecialFolderConstants.ssfDESKTOPDIRECTORY)
For Each fi As shell32.FolderItem In dfolder.ParentFolder.Items()
Dim Subnode2 As TreeNode = tvFolders.Nodes.Add(dfolder.Title)
Next
End Sub
End Class
which seems to work as expected.
I should be able to find out why the complete code doesn't work.
Thanks
Just Me said:
single stepping
After Dim ShellQ As New Shell32.ShellClass (no error there)
If I do a quickwatch it says that ShellQ is not declared
ShellQ.NameSpace(Shell32.ShellSpecialFolderConstants.ssfDESKTOPDIRECTORY)
Do you get an error message?
No I can single step through the code
Are you sure the necessary namespaces are imported?
I Imports Shell32 is that enough?
If, in the IDE I type Shell32. intellisense shows the options - including
ShellClass
Did you have a look at the object model provided by the
"shell32.dll" component in object browser?
yes, but what should I look for? ShellClass is there but it's grayed