Spetial folders

BlitzMax Forums/BlitzMax Programming/Spetial folders

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This is for Blitz3D/Blitz+, see if it works in BlitzMax

.lib "shell32.dll" 
SHGetSpecialFolderLocation%(hwndOwner%,nFolder%,pIdl*):"SHGetSpecialFolderLocation"
SHGetPathFromIDList(pidList, lpBuffer$):"SHGetPathFromIDListA"



Const CSIDL_DESKTOP                 = $0000  ; <desktop>
Const CSIDL_INTERNET                = $0001  ; Internet Explorer (icon on desktop)
Const CSIDL_PROGRAMS                = $0002  ; Start Menu\Programs
Const CSIDL_CONTROLS                = $0003  ; My Computer\Control Panel
Const CSIDL_PRINTERS                = $0004  ; My Computer\Printers
Const CSIDL_PERSONAL                = $0005  ; My Documents
Const CSIDL_FAVORITES               = $0006  ; <user name>\Favorites
Const CSIDL_STARTUP                 = $0007  ; Start Menu\Programs\Startup
Const CSIDL_RECENT                  = $0008  ; <user name>\Recent
Const CSIDL_SENDTO                  = $0009  ; <user name>\SendTo
Const CSIDL_BITBUCKET               = $000a  ; <desktop>\Recycle Bin
Const CSIDL_STARTMENU               = $000b  ; <user name>\Start Menu
Const CSIDL_MYDOCUMENTS             = $000c  ; logical "My Documents" desktop icon
Const CSIDL_MYMUSIC                 = $000d  ; "My Music" folder
Const CSIDL_MYVIDEO                 = $000e  ; "My Videos" folder
Const CSIDL_DESKTOPDIRECTORY        = $0010  ; <user name>\Desktop
Const CSIDL_DRIVES                  = $0011  ; My Computer
Const CSIDL_NETWORK                 = $0012  ; Network Neighborhood
Const CSIDL_NETHOOD                 = $0013  ; <user name>\nethood
Const CSIDL_FONTS                   = $0014  ; windows\fonts
Const CSIDL_TEMPLATES               = $0015
Const CSIDL_COMMON_STARTMENU        = $0016  ; All Users\Start Menu
Const CSIDL_COMMON_PROGRAMS         = $0017  ; All Users\Programs
Const CSIDL_COMMON_STARTUP          = $0018  ; All Users\Startup
Const CSIDL_COMMON_DESKTOPDIRECTORY = $0019  ; All Users\Desktop
Const CSIDL_APPDATA                 = $001a  ; <user name>\Application Data
Const CSIDL_PRINTHOOD               = $001b  ; <user name>\PrintHood
Const CSIDL_LOCAL_APPDATA           = $001c  ; <user name>\Local Settings\Application Data (non roaming)
Const CSIDL_ALTSTARTUP              = $001d  ; non localized startup
Const CSIDL_COMMON_ALTSTARTUP       = $001e  ; non localized common startup
Const CSIDL_COMMON_FAVORITES        = $001f
Const CSIDL_INTERNET_CACHE          = $0020
Const CSIDL_COOKIES                 = $0021
Const CSIDL_HISTORY                 = $0022
Const CSIDL_COMMON_APPDATA          = $0023  ; All Users\Application Data
Const CSIDL_WINDOWS                 = $0024  ; GetWindowsDirectory()
Const CSIDL_SYSTEM                  = $0025  ; GetSystemDirectory()
Const CSIDL_PROGRAM_FILES           = $0026  ; C:\Program Files
Const CSIDL_MYPICTURES              = $0027  ; C:\Program Files\My Pictures
Const CSIDL_PROFILE                 = $0028  ; USERPROFILE
Const CSIDL_SYSTEMX86               = $0029  ; x86 system directory on RISC
Const CSIDL_PROGRAM_FILESX86        = $002a  ; x86 C:\Program Files on RISC
Const CSIDL_PROGRAM_FILES_COMMON    = $002b  ; C:\Program Files\Common
Const CSIDL_PROGRAM_FILES_COMMONX86 = $002c  ; x86 Program Files\Common on RISC
Const CSIDL_COMMON_TEMPLATES        = $002d  ; All Users\Templates
Const CSIDL_COMMON_DOCUMENTS        = $002e  ; All Users\Documents
Const CSIDL_COMMON_ADMINTOOLS       = $002f  ; All Users\Start Menu\Programs\Administrative Tools
Const CSIDL_ADMINTOOLS              = $0030  ; <user name>\Start Menu\Programs\Administrative Tools
Const CSIDL_CONNECTIONS             = $0031  ; Network and Dial-up Connections
Const CSIDL_COMMON_MUSIC            = $0035  ; All Users\My Music
Const CSIDL_COMMON_PICTURES         = $0036  ; All Users\My Pictures
Const CSIDL_COMMON_VIDEO            = $0037  ; All Users\My Video
Const CSIDL_RESOURCES               = $0038  ; Resource Direcotry
Function GetSpecialFolder$(folder_id)
		
Local  idl% = CreateBank (8) 

Local spath$ = String(0 ,260 )
Local nPos


	If SHGetSpecialFolderLocation(0,folder_id,idl) = 0
		
		SHGetPathFromIDList PeekInt( IDL,0), spath$
	
		nPos = Instr( spath, Chr$(0))
	    If nPos > 0 Then           
	    	spath = Left(spath, nPos - 1)
	    End If
		spath = spath + ""
	
	EndIf
	
	FreeBank idl
		
	Return spath
		
End Function