How to use shell32.dll functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Just Me

    How to use shell32.dll functions

    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.ShellCl ass

    Dim shellFolder As Shell32.Folder =
    ShellQ.NameSpac e(Shell32.Shell SpecialFolderCo nstants.ssfDESK TOPDIRECTORY)



    Thanks for any help


  • Herfried K. Wagner [MVP]

    #2
    Re: How to use shell32.dll functions

    " Just Me" <newsgroups@a-znet.com> schrieb:[color=blue]
    > 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.ShellCl ass
    >
    > Dim shellFolder As Shell32.Folder =
    > ShellQ.NameSpac e(Shell32.Shell SpecialFolderCo nstants.ssfDESK TOPDIRECTORY)[/color]

    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.dl l" component in object browser?

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

    Comment

    • Just Me

      #3
      Re: How to use shell32.dll functions

      single stepping
      After Dim ShellQ As New Shell32.ShellCl ass (no error there)
      If I do a quickwatch it says that ShellQ is not declared
      [color=blue][color=green]
      > > Dim ShellQAs New Shell32.ShellCl ass
      > > Dim shellFolder As Shell32.Folder =
      > >[/color][/color]
      ShellQ.NameSpac e(Shell32.Shell SpecialFolderCo nstants.ssfDESK TOPDIRECTORY)[color=blue]
      >
      > Do you get an error message?[/color]

      No I can single step through the code
      [color=blue]
      >Are you sure the necessary namespaces are imported?[/color]
      I Imports Shell32 is that enough?

      If, in the IDE I type Shell32. intellisense shows the options - including
      ShellClass
      [color=blue]
      > Did you have a look at the object model provided by the
      > "shell32.dl l" component in object browser?[/color]

      yes, but what should I look for? ShellClass is there but it's grayed
      [color=blue]
      >
      > --
      > Herfried K. Wagner [MVP]
      > <URL:http://dotnet.mvps.org/>
      >[/color]


      Comment

      • Just Me

        #4
        Re: How to use shell32.dll functions

        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 FolderExplorerC ontrol
        ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '''''

        Inherits System.Windows. Forms.UserContr ol

        #Region "Windows Form Designer generated code "

        Public Sub New()

        MyBase.New()

        'This call is required by the Windows Form Designer.

        InitializeCompo nent()

        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.Disp ose()

        End If

        End If

        MyBase.Dispose( Disposing)

        End Sub

        'Required by the Windows Form Designer

        Private components As System.Componen tModel.IContain er

        '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 InitializeCompo nent()

        Me.tvFolders = New System.Windows. Forms.TreeView

        Me.SuspendLayou t()

        '

        'tvFolders

        '

        Me.tvFolders.Im ageIndex = -1

        Me.tvFolders.Lo cation = New System.Drawing. Point(144, 128)

        Me.tvFolders.Na me = "tvFolders"

        Me.tvFolders.Se lectedImageInde x = -1

        Me.tvFolders.Si ze = New System.Drawing. Size(568, 256)

        Me.tvFolders.Ta bIndex = 0

        '

        'FolderExplorer Control

        '

        Me.Controls.Add (Me.tvFolders)

        Me.Font = New System.Drawing. Font("Arial", 8.0!,
        System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
        CType(0, Byte))

        Me.Name = "FolderExplorer Control"

        Me.Size = New System.Drawing. Size(856, 552)

        Me.ResumeLayout (False)

        End Sub

        #End Region

        Private Sub FolderExplorerC ontrol_Load(ByV al sender As Object, ByVal e As
        System.EventArg s) Handles MyBase.Load

        'Added a reference to Shell32 by browsing to shell32.dll

        Dim shell32q As Shell32.ShellCl ass = New Shell32.ShellCl ass

        Dim shell32Folder As Shell32.Folder =
        shell32q.NameSp ace(Shell32.She llSpecialFolder Constants.ssfDE SKTOPDIRECTORY)

        Dim items As shell32.FolderI tems = shell32Folder.I tems()



        Dim dfolder As Shell32.Folder =
        shell32q.NameSp ace(Shell32.She llSpecialFolder Constants.ssfDE SKTOPDIRECTORY)

        For Each fi As shell32.FolderI tem In dfolder.ParentF older.Items()

        Dim Subnode2 As TreeNode = tvFolders.Nodes .Add(dfolder.Ti tle)

        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" <newsgroups@a-znet.com> wrote in message
        news:uCttvhIYEH A.1000@TK2MSFTN GP12.phx.gbl...[color=blue]
        > single stepping
        > After Dim ShellQ As New Shell32.ShellCl ass (no error there)
        > If I do a quickwatch it says that ShellQ is not declared
        >[color=green][color=darkred]
        > > > Dim ShellQAs New Shell32.ShellCl ass
        > > > Dim shellFolder As Shell32.Folder =
        > > >[/color][/color]
        > ShellQ.NameSpac e(Shell32.Shell SpecialFolderCo nstants.ssfDESK TOPDIRECTORY)[color=green]
        > >
        > > Do you get an error message?[/color]
        >
        > No I can single step through the code
        >[color=green]
        > >Are you sure the necessary namespaces are imported?[/color]
        > I Imports Shell32 is that enough?
        >
        > If, in the IDE I type Shell32. intellisense shows the options -[/color]
        including[color=blue]
        > ShellClass
        >[color=green]
        > > Did you have a look at the object model provided by the
        > > "shell32.dl l" component in object browser?[/color]
        >
        > yes, but what should I look for? ShellClass is there but it's grayed
        >[color=green]
        > >
        > > --
        > > Herfried K. Wagner [MVP]
        > > <URL:http://dotnet.mvps.org/>
        > >[/color]
        >
        >[/color]


        Comment

        Working...