By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

How to use shell32.dll functions

P: n/a
I've referenced the shell32.dll but can't seen to use it.

Could someone give an example of using any function in it?

Something like:

Dim ShellQAs New Shell32.ShellClass

Dim shellFolder As Shell32.Folder =
ShellQ.NameSpace(Shell32.ShellSpecialFolderConstan ts.ssfDESKTOPDIRECTORY)

Thanks for any help
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
" Just Me" <ne********@a-znet.com> schrieb:
I've referenced the shell32.dll but can't seen to use it.

Could someone give an example of using any function in it?

Something like:

Dim ShellQAs New Shell32.ShellClass

Dim shellFolder As Shell32.Folder =
ShellQ.NameSpace(Shell32.ShellSpecialFolderConstan ts.ssfDESKTOPDIRECTORY)


Do you get an error message? Are you sure the necessary namespaces are
imported? Did you have a look at the object model provided by the
"shell32.dll" component in object browser?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #2

P: n/a
single stepping
After Dim ShellQ As New Shell32.ShellClass (no error there)
If I do a quickwatch it says that ShellQ is not declared
Dim ShellQAs New Shell32.ShellClass
Dim shellFolder As Shell32.Folder =
ShellQ.NameSpace(Shell32.ShellSpecialFolderConstan ts.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

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #3

P: n/a
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.ShellSpecialFolderConst ants.ssfDESKTOPDIRECTORY)

Dim items As shell32.FolderItems = shell32Folder.Items()

Dim dfolder As Shell32.Folder =
shell32q.NameSpace(Shell32.ShellSpecialFolderConst ants.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" <ne********@a-znet.com> wrote in message
news:uC**************@TK2MSFTNGP12.phx.gbl...
single stepping
After Dim ShellQ As New Shell32.ShellClass (no error there)
If I do a quickwatch it says that ShellQ is not declared
Dim ShellQAs New Shell32.ShellClass
Dim shellFolder As Shell32.Folder =
ShellQ.NameSpace(Shell32.ShellSpecialFolderConstan ts.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

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.