CCTV TECH
Nassau, Bahamas
Search this site Search Help
Default
Newest
Oldest
CCTV Forum News
Use our miniPSS tool to get
enhanced hotkeys in PSS.
miniPSS is an EXE wrapper
for PSS on Windows XP/7.
Visit the Forum Post
 
 
 
Special Folders
      
Option Explicit

Private Declare Function SHGetFolderPath Lib "shfolder" Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, ByVal nFolder As Long, ByVal hToken As Long, ByVal dwFlags As Long, ByVal pszPath As String) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

'get windows system path
Public Function GetSystemPath() As String
    Dim sRet As String, lngRet As Long
    sRet = String$(255, 0)
    lngRet = GetSystemDirectory(sRet, 255)
    GetSystemPath = Left$(sRet, lngRet)
End Function

'get windows path
Public Function GetWindowsPath() As String
    Dim sRet As String, lngRet As Long
    sRet = String$(255, 0)
    lngRet = GetWindowsDirectory(sRet, 255)
    GetWindowsPath = Left$(sRet, lngRet)
End Function

'get programs path
Public Function GetProgramsPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H26
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetProgramsPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get all desktop path
Public Function GetAllDesktopPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H19
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetAllDesktopPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get all start menu path
Public Function GetAllStartMenuPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H16
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetAllStartMenuPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get user start menu path
Public Function GetUserStartMenuPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &HB
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetUserStartMenuPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get all start menu programs path
Public Function GetAllStartProgramsPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H17
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetAllStartProgramsPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get user start menu programs path
Public Function GetUserStartProgramsPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H2
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetUserStartProgramsPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get user appdata
Public Function GetUserApplicationDataPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H1A
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetUserApplicationDataPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get all users appdata
Public Function GetAllApplicationDataPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H23
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetAllApplicationDataPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get my documents path
Public Function GetMyDocumentsPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H5
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetMyDocumentsPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get quick launch path
Public Function GetQuickLaunch() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H1A
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetQuickLaunch = Left$(strPath, InStr(1, strPath, Chr(0)) - 1) & "\Microsoft\Internet Explorer\Quick Launch"
End Function

'get desktop path
Public Function GetUserDesktopPath() As String
    Dim strBuffer  As String
    Dim strPath    As String
    Dim lngReturn  As Long
    Dim lngCSIDL   As Long
    lngCSIDL = &H0
    strPath = String(260, 0)
    lngReturn = SHGetFolderPath(0, lngCSIDL, 0, &H0, strPath)
    GetUserDesktopPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function

'get temp directory
Public Function GetTempDir() As String
    Dim nSize As Long
    Dim Buff As String
    Buff = Space$(260)
    nSize = Len(Buff)
    Call GetTempPath(nSize, Buff)
    GetTempDir = TrimNull(Buff)
End Function

Private Function TrimNull(Item As String)
    Dim pos As Integer
    pos = InStr(Item, Chr$(0))
    If pos Then
       TrimNull = Left$(Item, pos - 1)
    Else
       TrimNull = Item
    End If
End Function

CCTV | DVR | Video Surveillance | CCTV Cameras | Remote Video | Tech Support | Software | Scripts | Articles | Burglar Alarms | Alarm Monitoring | Real Estate
Copyright © 2001/2012 BahamasSecurity.com
 
Website hosted in Nassau, The Bahamas