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.

Here is a working BlitzMax version. I'm sure it can be "Maxified" a bit more to take out legacy commands.

'WinApi Commands
Extern "Win32"
Function SHGetSpecialFolderLocation(hwndOwner, nFolder, pIdl:Byte  Ptr)
Function SHGetPathFromIDList( pidList ,lpBuffer:Byte  Ptr)
End Extern


Print GetSpecialFolder(CSIDL_PROGRAMS)

Function GetSpecialFolder:String(folder_id) 
		
Local  idl% = CreateBank (8) 
Local  pathbank% = CreateBank (260) 
Local n%
Local sp$

	If SHGetSpecialFolderLocation(0,folder_id,BankBuf(idl)) = 0		
		SHGetPathFromIDList PeekInt( idl,0), BankBuf(pathbank)
		
		For n= 0 To 259
			sp$ = sp$ + Chr(PeekByte(pathbank,n))
		Next
	EndIf
	Return Trim(sp$) + ""
		
End Function