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