DisplaySpecialFolders - jaPBe plugin & standalone

Share your advanced PureBasic knowledge/code with the community.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

DisplaySpecialFolders - jaPBe plugin & standalone

Post by gnozal »

Based on Sverson's DisplaySystemMetrics plugin, here is another jaPBe plugin (to be included in the next release).

It displays Windows special folders.

Code: Select all

; ******************************************************************* 
; DisplaySpecialFolders 
; jaPBe plugin & standalone 
; 2009-06-26 gnozal, based on sverson's 'DisplaySystemMetrics' plugin
; ******************************************************************* 

EnableExplicit 

#SM_ENTRYCOUNT             = 57 
#SM_SendCode               = 1 
#SM_SendConstant           = 2 
#SM_SendValue              = 3 
#mywm_Plugin_Cancel        = #WM_USER+18 
#mywm_plugin_EnablejaPBe   = #WM_USER+20 
#WMCD_InsertText           = 2 
#wmcd_Fatal_Error          = 6 
#wmcd_Compilation_Finished = 10 

#CSIDL_DESKTOP=$00                
#CSIDL_INTERNET=$01               
#CSIDL_PROGRAMS=$02               
#CSIDL_CONTROLS=$03               
#CSIDL_PRINTERS=$04               
#CSIDL_PERSONAL=$05               
#CSIDL_FAVORITES=$06              
#CSIDL_STARTUP=$07                
#CSIDL_RECENT=$08                 
#CSIDL_SENDTO=$09                 
#CSIDL_BITBUCKET=$0A              
#CSIDL_STARTMENU=$0B              
#CSIDL_MYDOCUMENTS=$0C            
#CSIDL_MYMUSIC=$0D                
#CSIDL_MYVIDEO=$0E                
#CSIDL_DESKTOPDIRECTORY=$10       
#CSIDL_DRIVES=$11                 
#CSIDL_NETWORK=$12                
#CSIDL_NETHOOD=$13                
#CSIDL_FONTS=$14                  
#CSIDL_TEMPLATES=$15              
#CSIDL_COMMON_STARTMENU=$16       
#CSIDL_COMMON_PROGRAMS=$17        
#CSIDL_COMMON_STARTUP=$18         
#CSIDL_COMMON_DESKTOPDIRECTORY=$19
#CSIDL_APPDATA=$1A                
#CSIDL_PRINTHOOD=$1B              
#CSIDL_LOCAL_APPDATA=$1C          
#CSIDL_ALTSTARTUP=$1D             
#CSIDL_COMMON_ALTSTARTUP=$1E      
#CSIDL_COMMON_FAVORITES=$1F       
#CSIDL_INTERNET_CACHE=$20         
#CSIDL_COOKIES=$21                
#CSIDL_HISTORY=$22                
#CSIDL_COMMON_APPDATA=$23         
#CSIDL_WINDOWS=$24                
#CSIDL_SYSTEM=$25                 
#CSIDL_PROGRAM_FILES=$26          
#CSIDL_MYPICTURES=$27             
#CSIDL_PROFILE=$28                
#CSIDL_SYSTEMX86=$29              
#CSIDL_PROGRAM_FILESX86=$2A       
#CSIDL_PROGRAM_FILES_COMMON=$2B   
#CSIDL_PROGRAM_FILES_COMMONX86=$2C
#CSIDL_COMMON_TEMPLATES=$2D       
#CSIDL_COMMON_DOCUMENTS=$2E       
#CSIDL_COMMON_ADMINTOOLS=$2F      
#CSIDL_ADMINTOOLS=$30             
#CSIDL_CONNECTIONS=$31            
#CSIDL_COMMON_MUSIC=$35           
#CSIDL_COMMON_PICTURES=$36        
#CSIDL_COMMON_VIDEO=$37           
#CSIDL_RESOURCES=$38              
#CSIDL_RESOURCES_LOCALIZED=$39    
#CSIDL_COMMON_OEM_LINKS=$3A       
#CSIDL_CDBURN_AREA=$3B            
#CSIDL_COMPUTERSNEARME=$3D        
#CSIDL_PROFILES=$3E               

Global Dim _SM_No.l(#SM_ENTRYCOUNT) 
Global Dim _SM_Name.s(#SM_ENTRYCOUNT,1) 
Global _SM_TableNo.l, _SM_TableID.l, _SM_InfoNo.l, _SM_InfoID.l 
Global _SM_ButtonInsertCodeNo.l, _SM_ButtonInsertCodeID.l, _SM_ButtonInsertConstantNo.l, _SM_ButtonInsertConstantID.l, _SM_ButtonInsertValueNo.l, _SM_ButtonInsertValueID.l 
Global _SM_ButtonQuitNo.l, _SM_ButtonQuitID.l, _SM_CheckBoxjaPBeNo.l, _SM_CheckBoxjaPBeID.l 
Global _SM_MainWIndowNo.l, _SM_MainWIndowID.l, _SM_EditorHwnd.l=0 
Global _SM_FontID.l = GetGadgetFont(#PB_Default) 
Global _SM_ClipBoard$ = GetClipboardText() 
Global jaPBe_Handle.l, jaPBe_Version$, jaPBe_CompilerMsg.s, jaPBe_CompilerType.l, jaPBe_Selection.l, jaPBe_CurrentWord.l, jaPBe_CompleteText.l, jaPBe_CurrentLine.l, SM_Parameter$, jaPBe_Found.b=#False 
Global SpecialFolderCode.s

SpecialFolderCode = "Procedure.s GetSpecialFolder(folderno)" + #CRLF$
SpecialFolderCode + "  Protected listptr, result$" + #CRLF$
SpecialFolderCode + "  listptr = 0" + #CRLF$
SpecialFolderCode + "  result$ = Space(270)" + #CRLF$
SpecialFolderCode + "  SHGetSpecialFolderLocation_(0, folderno, @listptr)" + #CRLF$
SpecialFolderCode + "  SHGetPathFromIDList_(listptr, @result$)" + #CRLF$
SpecialFolderCode + "  ProcedureReturn Trim(result$)" + #CRLF$
SpecialFolderCode + "EndProcedure" + #CRLF$

Procedure Callback(WindowId, message, wParam, lParam) 
  Protected result = #PB_ProcessPureBasicEvents 
  Protected *cd.COPYDATASTRUCT 
  If message=#WM_COPYDATA 
    *cd.COPYDATASTRUCT=lParam 
    result=#False 
    If wParam=jaPBe_Handle 
      Select *cd\dwData 
        Case $FFFFFFFF 
        Default 
          If *cd\dwData>=#wmcd_Fatal_Error And *cd\dwData<=#wmcd_Compilation_Finished 
            jaPBe_CompilerMsg=PeekS(*cd\lpData,*cd\cbData) 
            If jaPBe_CompilerMsg=Chr(255) 
              jaPBe_CompilerMsg="" 
            EndIf 
            jaPBe_CompilerType=*cd\dwData 
            result=#True 
          EndIf 
      EndSelect 
    Else 
      MessageRequester("jaPBe-Plugin","I got a message NOT from jaPBe!") 
    EndIf 
  EndIf 
  ProcedureReturn result 
EndProcedure 

Procedure SendDataS(ziel,Type,Message$) 
  Protected cd.COPYDATASTRUCT 
  cd\dwData=Type 
  cd\cbData=Len(Message$)+1 
  cd\lpData=@Message$ 
  ProcedureReturn SendMessage_(ziel,#WM_COPYDATA,WindowID(1),cd) 
EndProcedure 

Procedure.l _SM_ColumnAutoSize(GadgetID.l) 
  Protected AktColumn.l, ColumnCount.l, TableWidth.l=0 
  ColumnCount = SendMessage_(SendMessage_(GadgetID,#LVM_GETHEADER,0,0),#HDM_GETITEMCOUNT,#Null,#Null)-1 
  For AktColumn=0 To ColumnCount - 1
    SendMessage_(GadgetID,#LVM_SETCOLUMNWIDTH,AktColumn,#LVSCW_AUTOSIZE) 
    TableWidth + SendMessage_(GadgetID, #LVM_GETCOLUMNWIDTH, AktColumn, 0) 
  Next 
  ProcedureReturn TableWidth 
EndProcedure 

Procedure _SM_Init() 
  Protected SM_Pos.l =0 
  
  _SM_No(SM_Pos)= #CSIDL_DESKTOP                  : _SM_Name(SM_Pos,0)= "CSIDL_DESKTOP"                   : _SM_Name(SM_Pos,1)= "Windows desktop virtual folder that is the root of the name space.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_INTERNET                 : _SM_Name(SM_Pos,0)= "CSIDL_INTERNET"                  : _SM_Name(SM_Pos,1)= "Virtual folder that represents the Internet.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PROGRAMS                 : _SM_Name(SM_Pos,0)= "CSIDL_PROGRAMS"                  : _SM_Name(SM_Pos,1)= "File system directory that contains the user's program groups (which are also file system directories). A typical path is C:\Documents and Settings\username\Start Menu\Programs.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_CONTROLS                 : _SM_Name(SM_Pos,0)= "CSIDL_CONTROLS"                  : _SM_Name(SM_Pos,1)= "Control Panel - virtual folder containing icons for the Control Panel applications.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PRINTERS                 : _SM_Name(SM_Pos,0)= "CSIDL_PRINTERS"                  : _SM_Name(SM_Pos,1)= "Printers folder - virtual folder containing installed Printers.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PERSONAL                 : _SM_Name(SM_Pos,0)= "CSIDL_PERSONAL"                  : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for documents."+Chr(13)+"A typical path is C:\Documents and Settings\username\My documents. This is different from the My documents virtual folder in the name space.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_FAVORITES                : _SM_Name(SM_Pos,0)= "CSIDL_FAVORITES"                 : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for the user's favourite items."+Chr(13)+"A typical path is C:\Documents and Settings\username\Favorites. (Version 6.0. This is equivalent to CSIDL_MYDOCUMENTS)": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_STARTUP                  : _SM_Name(SM_Pos,0)= "CSIDL_STARTUP"                   : _SM_Name(SM_Pos,1)= "File system directory that corresponds to the user's Startup program group. The system starts these programs whenever any user logs onto Microsoft® Windows NT® or starts Microsoft® Windows® 98."+Chr(13)+"A typical path is C:\Documents and Settings\username\Start Menu\Programs\Startup": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_RECENT                   : _SM_Name(SM_Pos,0)= "CSIDL_RECENT"                    : _SM_Name(SM_Pos,1)= "File system directory that contains the user's most recently used documents."+Chr(13)+"A typical path is C:\Documents and Settings\username\Recent."+Chr(13)+"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 documents submenu of the Start menu.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_SENDTO                   : _SM_Name(SM_Pos,0)= "CSIDL_SENDTO"                    : _SM_Name(SM_Pos,1)= "File system directory that contains Send To menu items."+Chr(13)+"A typical path is C:\Documents and Settings\username\SendTo.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_BITBUCKET                : _SM_Name(SM_Pos,0)= "CSIDL_BITBUCKET"                 : _SM_Name(SM_Pos,1)= "Virtual folder that contains the objects in the user's Recycle Bin.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_STARTMENU                : _SM_Name(SM_Pos,0)= "CSIDL_STARTMENU"                 : _SM_Name(SM_Pos,1)= "File system directory that contains Start menu items."+Chr(13)+"A typical path is C:\Documents and Settings\username\Start menu.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_MYDOCUMENTS              : _SM_Name(SM_Pos,0)= "CSIDL_MYDOCUMENTS"               : _SM_Name(SM_Pos,1)= "Virtual folder that contains the objects in the user's My Documents folder.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_MYMUSIC                  : _SM_Name(SM_Pos,0)= "CSIDL_MYMUSIC"                   : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for music files."+Chr(13)+"A typical path is C:\My music.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_MYVIDEO                  : _SM_Name(SM_Pos,0)= "CSIDL_MYVIDEO"                   : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for video files.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_DESKTOPDIRECTORY         : _SM_Name(SM_Pos,0)= "CSIDL_DESKTOPDIRECTORY"          : _SM_Name(SM_Pos,1)= "File system directory used to physically store file objects on the desktop (not to be confused with the desktop folder itself)."+Chr(13)+"A typical path is C:\Documents and Settings\username\desktop": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_DRIVES                   : _SM_Name(SM_Pos,0)= "CSIDL_DRIVES"                    : _SM_Name(SM_Pos,1)= "My Computer - virtual folder containing everything on the local Computer : storage devices, Printers, and Control Panel."+Chr(13)+"The folder may also contain mapped network drives.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_NETWORK                  : _SM_Name(SM_Pos,0)= "CSIDL_NETWORK"                   : _SM_Name(SM_Pos,1)= "Network Neighborhood virtual folder that represents the root of the network namespace hierarchy.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_NETHOOD                  : _SM_Name(SM_Pos,0)= "CSIDL_NETHOOD"                   : _SM_Name(SM_Pos,1)= "A file system folder that contains the link objects that can exist in the My network Places virtual folder."+Chr(13)+"It is not the same as CSIDL_NETWORK, which represents the network namespace root."+Chr(13)+"A typical path is C:\Documents and Settings\username\NetHood.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_FONTS                    : _SM_Name(SM_Pos,0)= "CSIDL_FONTS"                     : _SM_Name(SM_Pos,1)= "Virtual folder that contains fonts."+Chr(13)+"A typical path is C:\WINNT\fonts.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_TEMPLATES                : _SM_Name(SM_Pos,0)= "CSIDL_TEMPLATES"                 : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for document templates.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_STARTMENU         : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_STARTMENU"          : _SM_Name(SM_Pos,1)= "File system directory that contains the programs and folders that appear on the Start menu for all users."+Chr(13)+"A typical path is C:\Documents and Settings\All users\Start menu. Valid only for Windows NT systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_PROGRAMS          : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_PROGRAMS"           : _SM_Name(SM_Pos,1)= "File system directory that contains the directories for the common program groups that appear in the Start menu for all users."+Chr(13)+"A typical path is C:\Documents and Settings\All users\Start menu\programs. Valid only for Windows NT systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_STARTUP           : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_STARTUP"            : _SM_Name(SM_Pos,1)= "File system directory that contains the programs that appear in the Startup folder for all users."+Chr(13)+"A typical path is C:\Documents and Settings\All users\Start menu\programs\Startup. Valid only for Windows NT systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_DESKTOPDIRECTORY  : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_DESKTOPDIRECTORY"   : _SM_Name(SM_Pos,1)= "File system directory that contains files and folders that appear on the desktop for all users."+Chr(13)+"A typical path is C:\Documents and Settings\All users\desktop. Valid only for Windows NT systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_APPDATA                  : _SM_Name(SM_Pos,0)= "CSIDL_APPDATA"                   : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for application-specific data."+Chr(13)+"A typical path is C:\Documents and Settings\username\application Data. This CSIDL is supported by the redistributable ShFolder.dll for systems that do not have the Microsoft® Internet Explorer 4.0 integrated Shell installed.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PRINTHOOD                : _SM_Name(SM_Pos,0)= "CSIDL_PRINTHOOD"                 : _SM_Name(SM_Pos,1)= "File system directory that contains the link objects that can exist in the Printers virtual folder."+Chr(13)+"A typical path is C:\Documents and Settings\username\PrintHood.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_LOCAL_APPDATA            : _SM_Name(SM_Pos,0)= "CSIDL_LOCAL_APPDATA"             : _SM_Name(SM_Pos,1)= "File system directory that serves as a data repository for local (nonroaming) applications."+Chr(13)+"A typical path is C:\Documents and Settings\username\Local Settings\application Data.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_ALTSTARTUP               : _SM_Name(SM_Pos,0)= "CSIDL_ALTSTARTUP"                : _SM_Name(SM_Pos,1)= "File system directory that corresponds to the user's nonlocalized Startup program group.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_ALTSTARTUP        : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_ALTSTARTUP"         : _SM_Name(SM_Pos,1)= "File system directory that corresponds to the nonlocalized Startup program group for all users. Valid only for Windows NT systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_FAVORITES         : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_FAVORITES"          : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for all user's favorite items. Valid only for Windows NT systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_INTERNET_CACHE           : _SM_Name(SM_Pos,0)= "CSIDL_INTERNET_CACHE"            : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for temporary Internet files."+Chr(13)+"A typical path is C:\Documents and Settings\username\temporary Internet files.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COOKIES                  : _SM_Name(SM_Pos,0)= "CSIDL_COOKIES"                   : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for Internet cookies."+Chr(13)+"A typical path is C:\Documents and Settings\username\cookies.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_HISTORY                  : _SM_Name(SM_Pos,0)= "CSIDL_HISTORY"                   : _SM_Name(SM_Pos,1)= "File system directory that serves as a common repository for Internet history items.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_APPDATA           : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_APPDATA"            : _SM_Name(SM_Pos,1)= "Application data for all users."+Chr(13)+"A typical path is C:\Documents and Settings\All users\Application Data.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_WINDOWS                  : _SM_Name(SM_Pos,0)= "CSIDL_WINDOWS"                   : _SM_Name(SM_Pos,1)= "Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables."+Chr(13)+"A typical path is C:\WINNT.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_SYSTEM                   : _SM_Name(SM_Pos,0)= "CSIDL_SYSTEM"                    : _SM_Name(SM_Pos,1)= "System folder."+Chr(13)+"A typical path is C:\WINNT\SYSTEM32.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PROGRAM_FILES            : _SM_Name(SM_Pos,0)= "CSIDL_PROGRAM_FILES"             : _SM_Name(SM_Pos,1)= "Program files folder."+Chr(13)+"A typical path is C:\program files.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_MYPICTURES               : _SM_Name(SM_Pos,0)= "CSIDL_MYPICTURES"                : _SM_Name(SM_Pos,1)= "My Pictures folder."+Chr(13)+"A typical path is C:\Documents and Settings\username\My documents\My Pictures.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PROFILE                  : _SM_Name(SM_Pos,0)= "CSIDL_PROFILE"                   : _SM_Name(SM_Pos,1)= "User's profile folder.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_SYSTEMX86                : _SM_Name(SM_Pos,0)= "CSIDL_SYSTEMX86"                 : _SM_Name(SM_Pos,1)= "The x86 system directory on Reduced Instruction Set Computer (RISC) systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PROGRAM_FILESX86         : _SM_Name(SM_Pos,0)= "CSIDL_PROGRAM_FILESX86"          : _SM_Name(SM_Pos,1)= "The x86 program files folder on RISC systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PROGRAM_FILES_COMMON     : _SM_Name(SM_Pos,0)= "CSIDL_PROGRAM_FILES_COMMON"      : _SM_Name(SM_Pos,1)= "A folder for components that are shared across applications."+Chr(13)+"A typical path is C:\Program Files\common. Valid only for Windows NT And Windows 2000 systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PROGRAM_FILES_COMMONX86  : _SM_Name(SM_Pos,0)= "CSIDL_PROGRAM_FILES_COMMONX86"   : _SM_Name(SM_Pos,1)= "The x86 program files common folder on RISC systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_TEMPLATES         : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_TEMPLATES"          : _SM_Name(SM_Pos,1)= "File system directory that contains the templates that are available to all users."+Chr(13)+"A typical path is C:\Documents and Settings\All users\templates. Valid only for Windows NT systems.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_DOCUMENTS         : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_DOCUMENTS"          : _SM_Name(SM_Pos,1)= "File system directory that contains documents that are common to all users."+Chr(13)+"Typical paths are C:\Documents and Settings\All users\documents. Valid for Windows NT systems and Windows 95 and Windows 98 systems With ShFolder.dll installed": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_ADMINTOOLS        : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_ADMINTOOLS"         : _SM_Name(SM_Pos,1)= "File system directory that contains administrative tools for all users.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_ADMINTOOLS               : _SM_Name(SM_Pos,0)= "CSIDL_ADMINTOOLS"                : _SM_Name(SM_Pos,1)= "File system directory used to store administrative tools for an individual user."+Chr(13)+"The Microsoft Management Console (MMC) saves customized consoles to this directory, and it roams with the user.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_CONNECTIONS              : _SM_Name(SM_Pos,0)= "CSIDL_CONNECTIONS"               : _SM_Name(SM_Pos,1)= "Virtual folder that contains network and dial-up connections.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_MUSIC             : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_MUSIC"              : _SM_Name(SM_Pos,1)= "My music folder for all users.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_PICTURES          : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_PICTURES"           : _SM_Name(SM_Pos,1)= "My Pictures folder for all users.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_VIDEO             : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_VIDEO"              : _SM_Name(SM_Pos,1)= "My video folder for all users.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_RESOURCES                : _SM_Name(SM_Pos,0)= "CSIDL_RESOURCES"                 : _SM_Name(SM_Pos,1)= "System resource directory."+Chr(13)+"A typical path is C:\WINNT\Resources.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_RESOURCES_LOCALIZED      : _SM_Name(SM_Pos,0)= "CSIDL_RESOURCES_LOCALIZED"       : _SM_Name(SM_Pos,1)= "Localized resource directory.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMMON_OEM_LINKS         : _SM_Name(SM_Pos,0)= "CSIDL_COMMON_OEM_LINKS"          : _SM_Name(SM_Pos,1)= "Folder containing links to OEM specific applications for all users": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_CDBURN_AREA              : _SM_Name(SM_Pos,0)= "CSIDL_CDBURN_AREA"               : _SM_Name(SM_Pos,1)= "File system folder used to hold data for burning to a CD."+Chr(13)+"Typically [user Profile folder]\Local Settings\Application Data\Microsoft\CD Burning.": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_COMPUTERSNEARME          : _SM_Name(SM_Pos,0)= "CSIDL_COMPUTERSNEARME"           : _SM_Name(SM_Pos,1)= "Computers Near Me folder. Virtual folder that contains links to nearby computers on the network. Nearness is established by common work group membership": SM_Pos+1
  _SM_No(SM_Pos)= #CSIDL_PROFILES                 : _SM_Name(SM_Pos,0)= "CSIDL_PROFILES"                  : _SM_Name(SM_Pos,1)= "The File system directory containing user Profile folders."+Chr(13)+"A typical path is C:\Documents and Settings.": SM_Pos+1
EndProcedure 

Procedure.s SpecialFolder(folderno)
  Protected listptr, result$
  listptr=0
  result$=Space(270)
  SHGetSpecialFolderLocation_(0,folderno,@listptr)
  SHGetPathFromIDList_(listptr,@result$)
  ProcedureReturn Trim(result$)
EndProcedure

Procedure _SM_FillTable() 
  Protected SM_Pos.l, SM_ID$, SM_NAME$, SM_INFO$ 
  For SM_Pos = 0 To #SM_ENTRYCOUNT 
    SM_ID$   = "$"+RSet(Hex(_SM_No(SM_Pos)),4,"0")+Chr(10)+"("+RSet(Str(_SM_No(SM_Pos)),4,"0")+")"+Chr(10) 
    SM_NAME$ = _SM_Name(SM_Pos,0)+Chr(10) 
    SM_INFO$ =  SpecialFolder(_SM_No(SM_Pos))
    AddGadgetItem(_SM_TableNo,-1,SM_ID$+SM_NAME$+SM_INFO$) 
  Next 
EndProcedure 

Procedure _SM_InitTable() 
  Protected SM_Pos.l, SM_Flags.l 
  SM_Flags = #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#LVS_NOCOLUMNHEADER 
  _SM_TableNo = ListIconGadget(#PB_Any,0,0,0,0,"",0,SM_Flags) 
  _SM_TableID = GadgetID(_SM_TableNo) 
  For SM_Pos = 1 To 4 
    AddGadgetColumn(_SM_TableNo,0,"",0) 
  Next 
  _SM_FillTable() 
  SetGadgetState(_SM_TableNo,0) 
EndProcedure 

Procedure _SM_InitInfo() 
  Protected SM_Flags.l 
  SM_Flags = #PB_Editor_ReadOnly 
  _SM_InfoNo = EditorGadget(#PB_Any,0,0,0,0,SM_Flags) 
  _SM_InfoID = GadgetID(_SM_InfoNo) 
  SendMessage_(_SM_InfoID, #EM_SETTARGETDEVICE, 0, 0) 
  SendMessage_(_SM_InfoID, #EM_SETMARGINS, #EC_LEFTMARGIN, 5) 
  SendMessage_(_SM_InfoID, #EM_SETMARGINS, #EC_RIGHTMARGIN, 5) 
EndProcedure 

Procedure _SM_InitButtons() 
  _SM_ButtonInsertCodeNo     = ButtonGadget(#PB_Any,0,0,0,0,"jaPBe: insert code") 
  _SM_ButtonInsertCodeID     = GadgetID(_SM_ButtonInsertCodeNo) 
  _SM_ButtonInsertConstantNo = ButtonGadget(#PB_Any,0,0,0,0,"jaPBe: insert constant") 
  _SM_ButtonInsertConstantID = GadgetID(_SM_ButtonInsertConstantNo) 
  _SM_ButtonInsertValueNo    = ButtonGadget(#PB_Any,0,0,0,0,"jaPBe: insert value") 
  _SM_ButtonInsertValueID    = GadgetID(_SM_ButtonInsertValueNo) 
  _SM_CheckBoxjaPBeNo        = CheckBoxGadget(#PB_Any,0,0,0,0,"copy code to clipBoard") 
  _SM_CheckBoxjaPBeID        = GadgetID(_SM_CheckBoxjaPBeNo) 
  _SM_ButtonQuitNo           = ButtonGadget(#PB_Any,0,0,0,0,"Quit") 
  _SM_ButtonQuitID           = GadgetID(_SM_ButtonQuitNo) 
EndProcedure 

Procedure.l _SM_ButtonWidth(SM_ButtonNo.l) 
  Protected SM_ButtonWidth.l 
  StartDrawing(WindowOutput(_SM_MainWIndowNo)) 
    DrawingFont(_SM_FontID) 
    If SM_ButtonNo 
      SM_ButtonWidth = TextWidth(GetGadgetText(SM_ButtonNo)) 
    Else 
      SM_ButtonWidth = TextWidth("copy code to clipBoard") + GetSystemMetrics_(#SM_CXICON) 
    EndIf 
  StopDrawing() 
  ProcedureReturn SM_ButtonWidth + GetSystemMetrics_(#SM_CXDLGFRAME)*2 + GetSystemMetrics_(#SM_CXFRAME)*2 
EndProcedure 

Procedure _SM_Resize() 
  Protected SM_TableWidth.l, SM_TableHeight.l, SM_InfoWidth.l, SM_InfoHeight.l, SM_WindowX.l, SM_WindowY.l, SM_WindowHeight.l, SM_ButtonY.l, SM_ButtonX.l, SM_ButtonWidth.l 
  SM_TableWidth   = _SM_ColumnAutoSize(GadgetID(_SM_TableNo))+GetSystemMetrics_(#SM_CXVSCROLL)+GetSystemMetrics_(#SM_CXFRAME) 
  SM_TableHeight  = (SendMessage_(_SM_TableID, #LVM_GETITEMSPACING, #True, 0) >> 16) * 20 + GetSystemMetrics_(#SM_CYFRAME) 
  SM_InfoWidth    = SM_TableWidth 
  SM_InfoHeight   = SM_TableHeight >> 2 
  SM_WindowHeight = SM_TableHeight+SM_InfoHeight+GetSystemMetrics_(#SM_CYFRAME)*3+GetSystemMetrics_(#SM_CYMENU) 
  SM_WindowX      = (GetSystemMetrics_(#SM_CXFULLSCREEN)-SM_TableWidth-GetSystemMetrics_(#SM_CYFRAME)*2)>>1 
  SM_WindowY      = (GetSystemMetrics_(#SM_CYFULLSCREEN)-SM_WindowHeight-GetSystemMetrics_(#SM_CYFRAME)*2)>>1 
  SM_ButtonX      = GetSystemMetrics_(#SM_CXFRAME) 
  SM_ButtonY      = SM_WindowHeight-(GetSystemMetrics_(#SM_CYFRAME)+GetSystemMetrics_(#SM_CYMENU)) 
  ResizeGadget(_SM_TableNo,#PB_Ignore,#PB_Ignore,SM_TableWidth,SM_TableHeight) 
  ResizeGadget(_SM_InfoNo,#PB_Ignore,SM_TableHeight+GetSystemMetrics_(#SM_CXFRAME),SM_InfoWidth,SM_InfoHeight) 
  SM_ButtonWidth = _SM_ButtonWidth(_SM_ButtonInsertCodeNo) 
  ResizeGadget(_SM_ButtonInsertCodeNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU)) 
  DisableGadget(_SM_ButtonInsertCodeNo, jaPBe_Found!1) 
  SM_ButtonX + SM_ButtonWidth + GetSystemMetrics_(#SM_CXFRAME) 
  SM_ButtonWidth = _SM_ButtonWidth(_SM_ButtonInsertConstantNo) 
  ResizeGadget(_SM_ButtonInsertConstantNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU)) 
  DisableGadget(_SM_ButtonInsertConstantNo, jaPBe_Found!1) 
  SM_ButtonX + SM_ButtonWidth + GetSystemMetrics_(#SM_CXFRAME) 
  SM_ButtonWidth = _SM_ButtonWidth(_SM_ButtonInsertValueNo) 
  ResizeGadget(_SM_ButtonInsertValueNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU)) 
  DisableGadget(_SM_ButtonInsertValueNo, jaPBe_Found!1) 
  SM_ButtonX + SM_ButtonWidth + GetSystemMetrics_(#SM_CXFRAME) 
  SM_ButtonWidth =  _SM_ButtonWidth(0) 
  ResizeGadget(_SM_CheckBoxjaPBeNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU)) 
  SetGadgetState(_SM_CheckBoxjaPBeNo, jaPBe_Found!1) 
  SM_ButtonWidth = _SM_ButtonWidth(_SM_ButtonQuitNo) 
  SM_ButtonX = SM_TableWidth - SM_ButtonWidth - GetSystemMetrics_(#SM_CXFRAME) 
  ResizeGadget(_SM_ButtonQuitNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU)) 
  ResizeWindow(_SM_MainWIndowNo,SM_WindowX,SM_WindowY,SM_TableWidth,SM_WindowHeight) 
  SetActiveGadget(_SM_TableNo) 
  SetGadgetText(_SM_InfoNo,_SM_Name(GetGadgetState(_SM_TableNo),1)) 
EndProcedure 

Procedure _SM_Send(what.l=1) 
  Protected  SM_Pos.l, CB_Text$ 
  Static NextTime.l
  SM_Pos = GetGadgetState(_SM_TableNo) 
  Select what 
    Case #SM_SendCode 
      If NextTime
        CB_Text$ = "GetSpecialFolder(#"+_SM_Name(SM_Pos,0)+")" 
      Else
        CB_Text$ = SpecialFolderCode + "GetSpecialFolder(#"+_SM_Name(SM_Pos,0)+")" 
        NextTime = #True
      EndIf
    Case #SM_SendConstant 
      CB_Text$ = "#"+_SM_Name(SM_Pos,0) 
    Case #SM_SendValue 
      CB_Text$ = Str(GetSystemMetrics_(_SM_No(SM_Pos))) 
    Default 
      CB_Text$ = "" 
  EndSelect 
  If jaPBe_Found 
    SendDataS(jaPBe_Handle,#WMCD_InsertText,CB_Text$) 
    If GetGadgetState(_SM_CheckBoxjaPBeNo) 
      SetClipboardText(CB_Text$) 
    EndIf  
  EndIf 
EndProcedure 

Procedure DisplaySpecialFolders() 
  Protected SM_Event.l, SM_Pos.l, SM_Flags.l, CB_Text$ 
  SM_Parameter$ = ProgramParameter() 
  SM_Flags = #PB_Window_SystemMenu | #PB_Window_Invisible
  _SM_MainWIndowNo = OpenWindow(#PB_Any,0,0,0,0,"SpecialFolders",SM_Flags) 
  If _SM_MainWIndowNo 
    _SM_MainWIndowID = WindowID(_SM_MainWIndowNo) 
    StickyWindow(_SM_MainWIndowNo, #True) 
    _SM_Init() 
    _SM_InitTable() 
    _SM_InitInfo() 
    _SM_InitButtons() 
    HideWindow(_SM_MainWIndowNo, #False)
    SetWindowCallback(@Callback()) 
    If SM_Parameter$="jaPBe" 
      jaPBe_Found    = #True 
      jaPBe_Handle   = Val(ProgramParameter()) 
      jaPBe_Version$ = ProgramParameter() 
      PostMessage_(jaPBe_Handle,#mywm_plugin_EnablejaPBe,0,_SM_MainWIndowID) 
      SetWindowTitle(_SM_MainWIndowNo, GetWindowTitle(_SM_MainWIndowNo)+" plugin") 
    EndIf 
    _SM_Resize() 
    Repeat 
      SM_Event = WaitWindowEvent() 
      Select SM_Event 
        Case #PB_Event_Gadget 
          Select EventGadget() 
            Case _SM_ButtonInsertCodeNo     : _SM_Send(#SM_SendCode) 
            Case _SM_ButtonInsertConstantNo : _SM_Send(#SM_SendConstant) 
            Case _SM_ButtonInsertValueNo    : _SM_Send(#SM_SendValue) 
            Case _SM_ButtonQuitNo           : SM_Event = #PB_Event_CloseWindow 
            Case _SM_TableNo 
              SM_Pos = GetGadgetState(_SM_TableNo) 
              SetGadgetText(_SM_InfoNo,_SM_Name(SM_Pos,1)) 
              If GetGadgetState(_SM_CheckBoxjaPBeNo) 
                SetClipboardText(SpecialFolderCode + "GetSpecialFolder(#" +_SM_Name(SM_Pos,0)+")") 
              EndIf 
          EndSelect 
      EndSelect 
    Until SM_Event = #PB_Event_CloseWindow 
    If jaPBe_Found 
      PostMessage_(jaPBe_Handle,#mywm_Plugin_Cancel,0,WindowID(1)) 
    EndIf 
  EndIf 
  SetClipboardText(_SM_ClipBoard$) 
EndProcedure 

DisplaySpecialFolders() 

End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).