PageRenderTime 65ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/modSpecialFolders.bas

#
Basic | 169 lines | 69 code | 9 blank | 91 comment | 0 complexity | 722450031b598f8a9e93f1b34e937b1f MD5 | raw file
Possible License(s): AGPL-1.0
  1. Attribute VB_Name = "modSpecialFolders"
  2. ' _____________________________________________________________________________
  3. '|________________________________ SPECIAL FOLDER RETREAVAL ___________________|
  4. '| Name: modSpecialFolders.bas |
  5. '| Type: VB6 Module |
  6. '| Project: Cybera Server & Workstation (http://cybera.sf.net) |
  7. '| Description: Contains Windows special folder retreaval api calls & funcs.|
  8. '| Copyright: (C) 2004-2006 Samuel Monsarrat (smonsarr@users.sf.net) |
  9. '| |
  10. '| This file is part of Cybera. |
  11. '| |
  12. '| Cybera is free software; you can redistribute it and/or modify it under the |
  13. '| terms of the GNU General Public License as published by the Free Software |
  14. '| Foundation; either version 2 of the License, or (at your option) any later |
  15. '| version. |
  16. '| |
  17. '| Cybera is distributed in the hope that it will be useful, but WITHOUT ANY |
  18. '| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
  19. '| FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
  20. '| details. |
  21. '| |
  22. '| You should have received a copy of the GNU General Public License along |
  23. '| with Cybera; if not, write to the Free Software Foundation, Inc., |
  24. '| 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
  25. '| |
  26. '|_____________________________________________________________________________|
  27. ' $Id$
  28. Option Explicit
  29. ' Version 5.0. The file system directory that is used to store administrative tools for an individual user.
  30. ' The Microsoft Management Console (MMC) will save customized consoles to this directory, and it will roam with the user.
  31. Public Const CSIDL_ADMINTOOLS = &H30
  32. ' The file system directory that corresponds to the user's nonlocalized Startup program group.
  33. Public Const CSIDL_ALTSTARTUP = &H1D
  34. ' Version 4.71. The file system directory that serves as a common repository for application-specific data.
  35. ' A typical path is C:\Documents and Settings\username\Application Data. This CSIDL is supported by the redistributable
  36. ' Shfolder.dll for systems that do not have the MicrosoftŽ Internet Explorer 4.0 integrated Shell installed.
  37. Public Const CSIDL_APPDATA = &H1A
  38. ' The virtual folder containing the objects in the user's Recycle Bin.
  39. Public Const CSIDL_BITBUCKET = &HA
  40. ' Version 6.0. The file system directory acting as a staging area for files waiting to be written to CD. A typical path
  41. ' is C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\CD Burning.
  42. Public Const CSIDL_CDBURN_AREA = &H3B
  43. ' Version 5.0. The file system directory containing administrative tools for all users of the computer.
  44. Public Const CSIDL_COMMON_ADMINTOOLS = &H2F
  45. ' The file system directory that corresponds to the nonlocalized Startup program group for all users. Valid only for Microsoft Windows NTŽ systems.
  46. Public Const CSIDL_COMMON_ALTSTARTUP = &H1E
  47. ' Version 5.0. The file system directory containing application data for all users. A typical path is C:\Documents and Settings\All Users\Application Data.
  48. Public Const CSIDL_COMMON_APPDATA = &H23
  49. ' The file system directory that contains files and folders that appear on the desktop for all users. A typical path is C:\Documents and Settings\All Users\Desktop.
  50. ' Valid only for Windows NT systems.
  51. Public Const CSIDL_COMMON_DESKTOPDIRECTORY = &H19
  52. ' The file system directory that contains documents that are common to all users. A typical paths is C:\Documents and Settings\All Users\Documents.
  53. ' Valid for Windows NT systems and Microsoft WindowsŽ 95 and Windows 98 systems with Shfolder.dll installed.
  54. Public Const CSIDL_COMMON_DOCUMENTS = &H2E
  55. ' The file system directory that serves as a common repository for favorite items common to all users. Valid only for Windows NT systems.
  56. Public Const CSIDL_COMMON_FAVORITES = &H1F
  57. ' Version 6.0. The file system directory that serves as a repository for music files common to all users. A typical path is C:\Documents and Settings\All Users\Documents\My Music.
  58. Public Const CSIDL_COMMON_MUSIC = &H35
  59. ' Version 6.0. The file system directory that serves as a repository for image files common to all users. A typical path is C:\Documents and Settings\All Users\Documents\My Pictures.
  60. Public Const CSIDL_COMMON_PICTURES = &H36
  61. ' The file system directory that contains the directories for the common program groups that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs.
  62. ' Valid only for Windows NT systems.
  63. Public Const CSIDL_COMMON_PROGRAMS = &H17
  64. ' The file system directory that contains the programs and folders that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu. Valid only for Windows NT systems.
  65. Public Const CSIDL_COMMON_STARTMENU = &H16
  66. ' The file system directory that contains the programs that appear in the Startup folder for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs\Startup. Valid only for Windows NT systems.
  67. Public Const CSIDL_COMMON_STARTUP = &H18
  68. ' The file system directory that contains the templates that are available to all users. A typical path is C:\Documents and Settings\All Users\Templates. Valid only for Windows NT systems.
  69. Public Const CSIDL_COMMON_TEMPLATES = &H2D
  70. ' Version 6.0. The file system directory that serves as a repository for video files common to all users. A typical path is C:\Documents and Settings\All Users\Documents\My Videos.
  71. Public Const CSIDL_COMMON_VIDEO = &H37
  72. ' The virtual folder containing icons for the Control Panel applications.
  73. Public Const CSIDL_CONTROLS = &H3
  74. ' The file system directory that serves as a common repository for Internet cookies. A typical path is C:\Documents and Settings\username\Cookies.
  75. Public Const CSIDL_COOKIES = &H21
  76. ' The virtual folder representing the Windows desktop, the root of the namespace.
  77. Public Const CSIDL_DESKTOP = &H0
  78. ' The file system directory used to physically store file objects on the desktop (not to be confused with the desktop folder itself). A typical path is C:\Documents and Settings\username\Desktop.
  79. Public Const CSIDL_DESKTOPDIRECTORY = &H10
  80. ' The virtual folder representing My Computer, containing everything on the local computer: storage devices, printers, and Control Panel. The folder may also contain mapped network drives.
  81. Public Const CSIDL_DRIVES = &H11
  82. ' The file system directory that serves as a common repository for the user's favorite items. A typical path is C:\Documents and Settings\username\Favorites.
  83. Public Const CSIDL_FAVORITES = &H6
  84. ' A virtual folder containing fonts. A typical path is C:\Windows\Fonts.
  85. Public Const CSIDL_FONTS = &H14
  86. ' The file system directory that serves as a common repository for Internet history items.
  87. Public Const CSIDL_HISTORY = &H22
  88. ' A virtual folder representing the Internet.
  89. Public Const CSIDL_INTERNET = &H1
  90. ' Version 4.72. The file system directory that serves as a common repository for temporary Internet files. A typical path is C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
  91. Public Const CSIDL_INTERNET_CACHE = &H20
  92. ' Version 5.0. The file system directory that serves as a data repository for local (nonroaming) applications. A typical path is C:\Documents and Settings\username\Local Settings\Application Data.
  93. Public Const CSIDL_LOCAL_APPDATA = &H1C
  94. ' Version 6.0. The virtual folder representing the My Documents desktop item. This should not be confused with CSIDL_PERSONAL, which represents the file system folder that physically stores the documents.
  95. Public Const CSIDL_MYDOCUMENTS = &HC
  96. ' The file system directory that serves as a common repository for music files. A typical path is C:\Documents and Settings\User\My Documents\My Music.
  97. Public Const CSIDL_MYMUSIC = &HD
  98. ' Version 5.0. The file system directory that serves as a common repository for image files. A typical path is C:\Documents and Settings\username\My Documents\My Pictures.
  99. Public Const CSIDL_MYPICTURES = &H27
  100. ' Version 6.0. The file system directory that serves as a common repository for video files. A typical path is C:\Documents and Settings\username\My Documents\My Videos.
  101. Public Const CSIDL_MYVIDEO = &HE
  102. ' A file system directory containing the link objects that may exist in the My Network Places virtual folder. It is not the same as CSIDL_NETWORK, which represents the network namespace root. A typical path is C:\Documents and Settings\username\NetHood.
  103. Public Const CSIDL_NETHOOD = &H13
  104. ' A virtual folder representing Network Neighborhood, the root of the network namespace hierarchy.
  105. Public Const CSIDL_NETWORK = &H12
  106. ' The file system directory used to physically store a user's common repository of documents. A typical path is C:\Documents and Settings\username\My Documents. This should be distinguished from the virtual My Documents folder in the namespace, identified by CSIDL_MYDOCUMENTS.
  107. ' To access that virtual folder, use SHGetFolderLocation, which returns the ITEMIDLIST for the virtual location, or refer to the technique described in Managing the File System.
  108. Public Const CSIDL_PERSONAL = &H5
  109. ' The virtual folder containing installed printers.
  110. Public Const CSIDL_PRINTERS = &H4
  111. ' The file system directory that contains the link objects that can exist in the Printers virtual folder. A typical path is C:\Documents and Settings\username\PrintHood.
  112. Public Const CSIDL_PRINTHOOD = &H1B
  113. ' Version 5.0. The user's profile folder. A typical path is C:\Documents and Settings\username. Applications should not create files or folders at this level; they should put their data under the locations referred to by CSIDL_APPDATA or CSIDL_LOCAL_APPDATA.
  114. Public Const CSIDL_PROFILE = &H28
  115. ' Version 6.0. The file system directory containing user profile folders. A typical path is C:\Documents and Settings.
  116. Public Const CSIDL_PROFILES = &H3E
  117. ' Version 5.0. The Program Files folder. A typical path is C:\Program Files.
  118. Public Const CSIDL_PROGRAM_FILES = &H26
  119. ' Version 5.0. A folder for components that are shared across applications. A typical path is C:\Program Files\Common. Valid only for Windows NT, Windows 2000, and Windows XP systems. Not valid for Windows Millennium Edition (Windows Me).
  120. Public Const CSIDL_PROGRAM_FILES_COMMON = &H2B
  121. ' The file system directory that contains the user's program groups (which are themselves file system directories). A typical path is C:\Documents and Settings\username\Start Menu\Programs.
  122. Public Const CSIDL_PROGRAMS = &H2
  123. ' The file system directory that contains shortcuts to the user's most recently used documents. A typical path is C:\Documents and Settings\username\My Recent Documents. To create a shortcut in this folder, use SHAddToRecentDocs. In addition to creating the shortcut, this function updates the Shell's list of recent documents and adds the shortcut to the My Recent Documents submenu of the Start menu.
  124. Public Const CSIDL_RECENT = &H8
  125. ' The file system directory that contains Send To menu items. A typical path is C:\Documents and Settings\username\SendTo.
  126. Public Const CSIDL_SENDTO = &H9
  127. ' The file system directory containing Start menu items. A typical path is C:\Documents and Settings\username\Start Menu.
  128. Public Const CSIDL_STARTMENU = &HB
  129. ' The file system directory that corresponds to the user's Startup program group. The system starts these programs whenever any user logs onto Windows NT or starts Windows 95. A typical path is C:\Documents and Settings\username\Start Menu\Programs\Startup.
  130. Public Const CSIDL_STARTUP = &H7
  131. ' Version 5.0. The Windows System folder. A typical path is C:\Windows\System32.
  132. Public Const CSIDL_SYSTEM = &H25
  133. ' The file system directory that serves as a common repository for document templates. A typical path is C:\Documents and Settings\username\Templates.
  134. Public Const CSIDL_TEMPLATES = &H15
  135. ' Version 5.0. The Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables. A typical path is C:\Windows.
  136. Public Const CSIDL_WINDOWS = &H24
  137. ' Defines an item identifier.
  138. Public Type typSHITEMID
  139. cb As Long
  140. abID As Byte
  141. End Type
  142. ' Contains a list of item identifiers.
  143. Public Type typITEMIDLIST
  144. mkid As typSHITEMID
  145. End Type
  146. ' The ShellExecute function opens or prints a specified file. The file can be an executable file or a document file.
  147. 'Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  148. ' Converts an item identifier list to a file system path.
  149. Public Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
  150. ' Retrieves a pointer to the ITEMIDLIST structure of a special folder.
  151. Public Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As typITEMIDLIST) As Long
  152. '*******************************************************************************
  153. Public Function funGetFolderPath(CSIDL As Long) As String
  154. Dim uIDL As typITEMIDLIST
  155. Dim strtemp As String * 512
  156. On Error Resume Next
  157. Call SHGetSpecialFolderLocation(0, CSIDL, uIDL)
  158. Call SHGetPathFromIDList(uIDL.mkid.cb, strtemp)
  159. funGetFolderPath = left$(strtemp, InStr(strtemp, Chr$(0)) - 1)
  160. End Function