VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Return various directories including desktop, programs, personal, favorites, start menu, fonts, etc

by Anonymous (267 Submissions)
Category: Windows System Services
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Mon 28th December 1998
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Return various directories including desktop, programs, personal, favorites, start menu, fonts, etc.

API Declarations


sfidDESKTOP = &H0
sfidPROGRAMS = &H2
sfidPERSONAL = &H5
sfidFAVORITES = &H6
sfidSTARTUP = &H7
sfidRECENT = &H8
sfidSENDTO = &H9
sfidSTARTMENU = &HB
sfidDESKTOPDIRECTORY = &H10
sfidNETHOOD = &H13
sfidFONTS = &H14
sfidTEMPLATES = &H15
sfidCOMMON_STARTMENU = &H16
sfidCOMMON_PROGRAMS = &H17
sfidCOMMON_STARTUP = &H18
sfidCOMMON_DESKTOPDIRECTORY = &H19
sfidAPPDATA = &H1A
sfidPRINTHOOD = &H1B
sfidProgramFiles = &H10000
sfidCommonFiles = &H10001
End Enum

Public Declare Function SHGetSpecialFolderLocation Lib "shell32" (ByVal hwndOwner As Long, ByVal nFolder As SpecialFolderIDs, ByRef pIdl As Long) As Long
Public Declare Function SHGetPathFromIDListA Lib "shell32" (ByVal pIdl As Long, ByVal pszPath As String) As Long

Public Const NOERROR = 0

Rate Return various directories including desktop, programs, personal, favorites, start menu, fonts, etc



    Dim IDL     As Long
    Dim strPath As String
    Dim lngPos As Long
    
    ' Fill the item id list with the pointer of each folder item, rtns 0 on success
    If SHGetSpecialFolderLocation(0, sfidPROGRAMS, IDL) = NOERROR Then
        sPath = String$(255, 0)
        SHGetPathFromIDListA IDL, sPath

        lngPos = InStr(sPath, Chr&(0))
        If lngPos > 0 Then
            strPath = Left$(sPath, lngPos - 1)
        End If
        
    End If

Download this snippet    Add to My Saved Code

Return various directories including desktop, programs, personal, favorites, start menu, fonts, etc Comments

No comments have been posted about Return various directories including desktop, programs, personal, favorites, start menu, fonts, etc. Why not be the first to post a comment about Return various directories including desktop, programs, personal, favorites, start menu, fonts, etc.

Post your comment

Subject:
Message:
0/1000 characters