'//Module
Declare Function SHGetSpecialFolderLocation Lib "Shell32.dll" _
  (ByVal hwndOwner As Long, ByVal nFolder As Long, _
  pidl As ITEMIDLIST) As Long

Declare Function SHGetPathFromIDList Lib "Shell32.dll" _
  Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
  ByVal pszPath As String) As Long

Public Type SH_ITEMID
    cb As Long
    abID As Byte
End Type

Public Type ITEMIDLIST
    mkid As SH_ITEMID
End Type
' The Desktop - virtual folder
Public Const CSIDL_DESKTOP = &H0
' Program Files
Public Const CSIDL_PROGRAMS = 2
' Control Panel - virtual folder
Public Const CSIDL_CONTROLS = 3
' Printers - virtual folder
Public Const CSIDL_PRINTERS = 4
' My Documents
Public Const CSIDL_DOCUMENTS = 5
' Favorites
Public Const CSIDL_FAVORITES = 6
' Startup Folder
Public Const CSIDL_STARTUP = 7
' Recent Documents
Public Const CSIDL_RECENT = 8
' Send To Folder
Public Const CSIDL_SENDTO = 9
' Recycle Bin - virtual folder
Public Const CSIDL_BITBUCKET = 10
' Start Menu
Public Const CSIDL_STARTMENU = 11
' Desktop folder
Public Const CSIDL_DESKTOPFOLDER = 16
' My Computer - virtual folder
Public Const CSIDL_DRIVES = 17
' Network Neighbourhood - virtual folder
Public Const CSIDL_NETWORK = 18
' NetHood Folder
Public Const CSIDL_NETHOOD = 19
' Fonts folder
Public Const CSIDL_FONTS = 20
' ShellNew folder
Public Const CSIDL_SHELLNEW = 21

Public Const MAX_PATH As Integer = 260

Public Function fGetSpecialFolder(CSIDL As Long) As String
    Dim sPath As String
    Dim IDL As ITEMIDLIST
    '
    ' Retrieve info about system folders such as the
    ' "Desktop" folder. Info is stored in the IDL structure.
    '
    fGetSpecialFolder = ""
    If SHGetSpecialFolderLocation(Form1.hWnd, CSIDL, IDL) = 0 Then
        '
        ' Get the path from the ID list, and return the folder.
        '
        sPath = Space$(MAX_PATH)
        If SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) Then
            fGetSpecialFolder = Left$(sPath, InStr(sPath, vbNullChar) - 1) & "\"
        End If
    End If
End Function

'//--- Sample

Debug.Print "Desktop Folder " & fGetSpecialFolder(CSIDL_DESKTOPFOLDER)

 

http://vbcity.com/forums/topic.asp?tid=1393

Comment

Comment:

Tweet

<a href="http://wriykuatyfhicsz.com">nukqmmhhaqscnyu</a> http://ledmfrrxnyzaipu.com [url=http://zqsaeozrwwpuams.com]zwyxkvfxvazhwoc[/url]

#8 By xcvzykiewj (94.102.52.87) on 2010-06-14 15:30

<a href="http://yquqrzkdilgckwm.com">fbxrrgrswtnjozv</a> http://odvuuycocuimekm.com [url=http://znsfarejetzalwd.com]izeyxdunsojiaph[/url]

#7 By wwtfdfuwfq (94.102.52.87) on 2010-06-10 22:46

<a href="http://xcyqtuesvhwbyvx.com">hngtjnaavqmepzi</a> http://grjmgkegkxovxge.com [url=http://xozdvbzqetiflno.com]zngfnhhhirfgwcl[/url]

#6 By huetvjjzfk (94.102.52.87) on 2010-06-07 23:29

hi all !!

#5 By sears parts (124.157.191.197) on 2009-12-04 18:28

Que se ra

#4 By scratch and dent (124.157.236.175) on 2009-11-14 08:12

Good, I thought, we can use some Sunshine on a Sunday. ,

#3 By JWxwxzXCFQeJaP (83.26.144.251) on 2009-10-23 03:57

ขอบคุณค่ะ

#2 By โหลดเพลง (124.157.236.176) on 2009-10-06 22:21

ขอบคุณค่ะ

#1 By โหลดเพลง (124.157.236.250) on 2009-08-28 08:00