Posted By

jeffld on 04/16/07


Tagged

api SpecialFolder MyDocuments


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

thastyle


My_Documents


 / Published in: Visual Basic
 

I didn't write this, but I also don't remember where I got it.

  1. Private Declare Function SHGetSpecialFolderPathW Lib "shell32.dll" ( _
  2. ByVal hwndOwner As Long, _
  3. ByVal lpszPath As Long, _
  4. ByVal nFolder As Long, _
  5. ByVal fCreate As Long) As Boolean
  6.  
  7. Private Const MD As Long = &H5
  8.  
  9. Public Function My_Documents() As String
  10.  
  11. Dim Folders(512) As Byte
  12.  
  13. My_Documents = vbNullString
  14.  
  15. If SHGetSpecialFolderPathW(0&, _
  16. ByVal VarPtr(Folders(0)), _
  17. MD, 0&) Then
  18. My_Documents = Left$(Folders, InStr(Folders, Chr$(0)) - 1)
  19. End If
  20.  
  21. Erase Folders
  22.  
  23. End Function

Report this snippet  

You need to login to post a comment.