The question of how to open the folder browser comes up a lot. So here is a function you can use in your own programs.
SUB main()
{
string folder = GetFolder(null,"Select a folder");
print(folder);
While GetKey() == "";
}
/* subroutine to open the system folder browser */
struct BROWSEINFO
{
UINT hOwner;
UINT pidlRoot;
POINTER pszDisplayName;
POINTER lpszTitle;
UINT ulFlags;
UINT lpfn;
INT lParam;
INT iImage;
}
DECLARE IMPORT,SHGetPathFromIDList(int pidl,string pszPath),INT;
DECLARE IMPORT,SHBrowseForFolder(BROWSEINFO lpbi),INT;
DECLARE IMPORT,CoTaskMemFree(int pidl);
DECLARE IMPORT,ZeroMemory ALIAS RtlZeroMemory(pData as POINTER,length as INT);
declare import,SHParseDisplayName(WSTRING pszName,UINT *pbc,UINT *ppidl,UINT sfgaoIn,UINT *psfgaoOut),INT;
declare import,SHGetSpecialFolderLocation(UINT hwnd,int nFoloder,UINT *ppidl),int;
SUB GetFolder(UINT hwnd,string title),STRING
{
DSTRING path[260];
BROWSEINFO bi;
UINT lpIDList;
UINT pRoot,pTemp;
//initialize variables
path[0] = 0;
ZeroMemory(bi,LEN(bi));
//for Windows XP and above we can use SHParseDisplayName which can take a file path
//such as "c:\\progs" or a CLSID. The CLSID being used is for the My Computer folder.
SHParseDisplayName(s2w("::{20d04fe0-3aea-1069-a2d8-08002b30309d}"),NULL,pRoot,0,pTemp);
//for all Windows version this gets the pidl of the My Computer folder.
//So if you are targeting Windows 9x and above use this instead
//SHGetSpecialFolderLocation(null,0x0011,pRoot);
bi.pidlRoot = pRoot;
bi.hOwner = hwnd;
bi.pszDisplayName = path;
bi.lpszTitle = title;
bi.ulFlags = 0x00000041;
lpIDList = SHBrowseForFolder(bi);
if lpIDList <> 0
{
SHGetPathFromIDList(lpIDList,path);
CoTaskMemFree(lpIDList);
}
RETURN path;
}
/* other common CLSID's for use with SHParseDisplayName:
My Documents ::{450d8fba-ad25-11d0-98a8-0800361b1103}
Programs Folder ::{7be9d83c-a729-4d97-b5a7-1b7313c39e0a}
Start Menu Folder ::{48e7caab-b918-4e58-a94d-505519c795dc}
Temporary Internet Files ::{7bd29e00-76c1-11cf-9dd0-00a0c9034933}
My Network Places ::{208d2c60-3aea-1069-a2d7-08002b30309d}
*/