Results 1 to 7 of 7

Thread: Retrieve 'Local Settings' Directory [Resolved]

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Retrieve 'Local Settings' Directory [Resolved]

    I need to get the directory for Outlook where it stores the .pst
    files under windows 2k & XP. This path under windows 2000 is

    C:\Documents and Settings\UserName\Local Settings\Application Data\Microsoft\Outlook

    I can't get it through Outlook so I am trying to get it by getting a
    related folder. I thought about the temp directory, but that will be
    in a number of locations and could be changed. What would be
    the best I think is to get the path to the "Local Settings" directory.
    I don't want to depend on the path "C:\Documents and Settings\UserName
    of always being the same because I'm not sure if it IS always the
    same and cant be changed under 2000 & XP.

    Any ideas?

    Thanks in advance for any help.
    Last edited by RobDog888; Aug 16th, 2004 at 01:10 PM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506
    Heavily modified version of the allapi example, with fixes for option explicit:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type ****EMID
    4.   cb As Long
    5.   abID As Byte
    6. End Type
    7.  
    8. Private Type ITEMIDLIST
    9.   mkid As ****EMID
    10. End Type
    11.  
    12. Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
    13. Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
    14.  
    15. Private Sub Form_Load()
    16.   Debug.Print GetSpecialfolder(28)
    17. End Sub
    18.  
    19. Private Function GetSpecialfolder(CSIDL As Long) As String
    20.   Dim r As Long, sPath As String
    21.   Dim IDL As ITEMIDLIST
    22.  
    23.   r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
    24.  
    25.   If r = 0 Then
    26.     sPath = Space$(512)
    27.     r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)
    28.     GetSpecialfolder = Left$(sPath, InStr(sPath, Chr$(0)) - 1)
    29.     Exit Function
    30.   End If
    31.  
    32.   GetSpecialfolder = ""
    33. End Function
    Output to the immediate window should be c:\documents & Settings\[username]\local settings\application data

  3. #3

  4. #4

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Yes, I saw the example from allapi, but I didnt see a const for
    Local Settings. Is that what 28 is equilivalent to?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    VB Code:
    1. Const CSIDL_DESKTOP = &H0
    2. Const CSIDL_INTERNET = &H1
    3. Const CSIDL_PROGRAMS = &H2
    4. Const CSIDL_CONTROLS = &H3
    5. Const CSIDL_PRINTERS = &H4
    6. Const CSIDL_PERSONAL = &H5
    7. Const CSIDL_FAVORITES = &H6
    8. Const CSIDL_STARTUP = &H7
    9. Const CSIDL_RECENT = &H8
    10. Const CSIDL_SENDTO = &H9
    11. Const CSIDL_BITBUCKET = &HA
    12. Const CSIDL_STARTMENU = &HB
    13. Const CSIDL_DESKTOPDIRECTORY = &H10
    14. Const CSIDL_DRIVES = &H11
    15. Const CSIDL_NETWORK = &H12
    16. Const CSIDL_NETHOOD = &H13
    17. Const CSIDL_FONTS = &H14
    18. Const CSIDL_TEMPLATES = &H15
    19. Const CSIDL_COMMON_STARTMENU = &H16
    20. Const CSIDL_COMMON_PROGRAMS = &H17
    21. Const CSIDL_COMMON_STARTUP = &H18
    22. Const CSIDL_COMMON_DESKTOPDIRECTORY = &H19
    23. Const CSIDL_APPDATA = &H1A
    24. Const CSIDL_PRINTHOOD = &H1B
    25. Const CSIDL_ALTSTARTUP = &H1D
    26. Const CSIDL_COMMON_ALTSTARTUP = &H1E
    27. Const CSIDL_COMMON_FAVORITES = &H1F
    28. Const CSIDL_INTERNET_CACHE = &H20
    29. Const CSIDL_COOKIES = &H21
    30. Const CSIDL_HISTORY = &H22

  6. #6

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    So this CSIDL_APPDATA is the one under Local Settings and not
    under UserName?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Yes, it works fine.
    Thanks for the help guys.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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