Computer Learning Zone CLZ Access Excel Word Windows

Extraordinary claims require extraordinary evidence.

-Carl Sagan
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Visual Basic Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
InitDir for Common Dialogue Control
Alex Hedley 
            
15 years ago
Hi Kevin,

I did a bit of searching and came across this thread
I tested the code from Flyguy and it worked for me.

I then found this thread and got it printing the path to a label for testing.


Private Declare Function SHGetSpecialFolderLocation Lib "Shell32.DLL" (ByVal hWndOwner As Long, ByVal SHFolder As Long, ByRef idl As Long) As Long

Private Declare Function SHGetPathFromIDList Lib "Shell32.DLL" (ByVal idl As Long, ByVal Path As String) As Long

Public Enum SystemFolder
CSIDL_MYMUSIC = &HD ' "My Music" folder
End Enum

Public Function SystemPath(ByVal PathID As SystemFolder) As String
    Dim lIDL As Long ' directory IDL value
    Dim sBuff As String
    sBuff = Space$(1024)
    Dim n As Long
        n = SHGetSpecialFolderLocation(0, PathID, lIDL)
    If n Then Exit Function
        n = SHGetPathFromIDList(lIDL, sBuff)
    If n > 0 Then
        n = InStr(sBuff, Chr$(0)) - 1
        sBuff = Left$(sBuff, n)
        If Right$(sBuff, 1) <> "\" Then sBuff = sBuff & "\"
        SystemPath = sBuff
    End If
End Function

Private Sub Command#_Click()
    'I added a label and changed it to the path for testing
    Label2 = SystemPath(&HD)
End Sub


You can add more SystemFolders to the Enum if you were wanting to check other folders.

Alex

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Visual Basic Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/18/2026 2:42:16 AM. PLT: 1s