CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    239

    [RESOLVED] Special Folders Question (My Network Places, Recycle Bin)

    Where can I get the paths for "My Network Places" and "Recycle Bin"? Environment.SpecialFolder contains the following entries but not "My Network Places" and "Recycle Bin":

    ApplicationData
    CommonApplicationData
    CommonProgramFiles
    Cookies
    Desktop
    DesktopDirectory
    Favorites
    History
    InternetCache
    LocalApplicationData
    MyComputer
    MyDocuments
    MyMusic
    MyPictures
    Personal
    ProgramFiles
    Programs
    Recent
    SendTo
    StartMenu
    Startup
    System
    Templates

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Special Folders Question (My Network Places, Recycle Bin)

    Try AllAPI.NET. Here's Recycle Bin

    Code:
    Const SHERB_NOCONFIRMATION = &H1
    Const SHERB_NOPROGRESSUI = &H2
    Const SHERB_NOSOUND = &H4
    Private Type ULARGE_INTEGER
      LowPart As Long
      HighPart As Long
    End Type
    Private Type SHQUERYRBINFO
      cbSize As Long
      i64Size As ULARGE_INTEGER
      i64NumItems As ULARGE_INTEGER
    End Type
    Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
    Private Declare Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As Long
    Private Declare Function SHQueryRecycleBin Lib "shell32.dll" Alias "SHQueryRecycleBinA" (ByVal pszRootPath As String, pSHQueryRBInfo As SHQUERYRBINFO) As Long
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim RBinInfo As SHQUERYRBINFO, Msg As VbMsgBoxResult
        RBinInfo.cbSize = Len(RBinInfo)
        SHQueryRecycleBin vbNullString, RBinInfo
        If (RBinInfo.i64Size.LowPart And &H80000000) = &H80000000 Or RBinInfo.i64Size.HighPart > 0 Then
            Msg = MsgBox("Your Recycle Bin consumes over 2 gigabytes right now!" + vbCrLf + "Do you want to empty it?", vbYesNo + vbQuestion)
        Else
            Msg = MsgBox("Your Recycle Bin consumes" + Str$(RBinInfo.i64Size.LowPart) + " bytes right now." + vbCrLf + "Do you want to empty it?", vbYesNo + vbQuestion)
        End If
        If Msg = vbYes Then
            SHEmptyRecycleBin Me.hwnd, vbNullString, 0
            SHUpdateRecycleBinIcon
        End If
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Nov 2004
    Posts
    239

    Smile [Resolved]: Special Folders Question (My Network Places, Recycle Bin)

    Thanks for all the input. I did end up going with Customizing the BrowseForFolder dialog and used the following API functions...

    Code:
        Public Declare Function SHBrowseForFolder Lib "shell32" (ByRef lpbi As BROWSEINFO) As Integer
        Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Integer, ByVal lpBuffer As String) As Integer
        Public Declare Function SHGetSpecialFolderLocation Lib "shell32" (ByVal hWndOwner As Integer, ByVal nFolder As Integer, ByRef ListId As Integer) As Integer
    Wasn't able to get the Recycle Bin this way, but it's good enough for now...

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [RESOLVED] Special Folders Question (My Network Places, Recycle Bin)

    Did you miss my post?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured