GetSpecialFolderLocation - no lib required

BlitzPlus Forums/BlitzPlus Programming/GetSpecialFolderLocation - no lib required

This code does not require any dll's. Now you can write installers for your programs.

Someone should convert the compression routines in the archives to compress a bank - this makes a lot more sense than creating a compressed file on your hard drive.

Maybe ASPack or UPX could be used to compress the installer.

;.lib "shell32.dll"
;SHGetSpecialFolderLocation%(hwnd%,folder%,pidl*)
;SHGetPathFromIDList%(pidl%,pszPath*)

Notify GetSpecialFolderLocation(CSIDL_PROGRAMS)


Const MAX_PATH=260

Const CSIDL_PROGRAMS=2					;Program Groups Folder
Const CSIDL_PERSONAL=5					;Personal Documents Folder
Const CSIDL_FAVORITES=6					;Favorites Folder
Const CSIDL_STARTUP=7					;Startup Group Folder
Const CSIDL_RECENT=8					;Recently Used Documents Folder
Const CSIDL_SENDTO=9   					;Send To Folder
Const CSIDL_STARTMENU=11  				;Start Menu Folder
Const CSIDL_DESKTOPDIRECTORY=16  		;Desktop Folder
Const CSIDL_NETHOOD=19					;Network Neighborhood Folder
Const CSIDL_TEMPLATES=21				;Document Templates Folder
Const CSIDL_COMMON_STARTMENU=22			;Common Start Menu Folder
Const CSIDL_COMMON_PROGRAMS=23			;Common Program Groups Folder
Const CSIDL_COMMON_STARTUP=24			;Common Startup Group Folder
Const CSIDL_COMMON_DESKTOPDIRECTORY=25	;Common Desktop Folder
Const CSIDL_APPDATA=26					;Application Data Folder
Const CSIDL_PRINTHOOD=27				;Printers Folder
Const CSIDL_COMMON_FAVORITES=1			;Common Favorites Folder
Const CSIDL_INTERNET_CACHE=32			;Temp. Internet Files Folder
Const CSIDL_COOKIES=33					;Cookies Folder
Const CSIDL_HISTORY=34					;History Folder

Function GetSpecialFolderLocation$(folder)
temp=CreateBank(4)
SHGetSpecialFolderLocation(0,2,temp)
pidl=PeekInt(temp,0)
FreeBank temp
If Not pidl Return
temp=CreateBank(MAX_PATH)
SHGetPathFromIDList(pidl,temp)
s$=PeekString(temp,0)
FreeBank temp
Return s
End Function


Should
SHGetSpecialFolderLocation(0,2,temp)
actually be
SHGetSpecialFolderLocation(0,folder,temp)
in the function GetSpecialFolderLocation$(folder) ?

@TAS: Yeah, I think that is right. Did you get an error about that function? Mine says the function can't be found.

Anyone used this successfully on Vista? I created the decls file and put it in user libs. Copied the PeekString function from the code archive but get the error "Bank offset out of range" at the following line...

Function PeekString$(bank,offset)
	l = PeekInt(bank,offset)
	s$ = ""
	For i = 1 To l
>>>>>>>>s$ = s$ + Chr$(PeekByte(bank,offset+i+3))<<<<<<<<<
	Next
	Return s$
End Function


If it's any comfort, I get the same error in XP. took off the + 3 and it still gets it.