typedef struct _BROWSEINFO
{
	long		hwndOwner;
	char*		pidlRoot;
	char*		pszDisplayName;
	char*		lpszTitle;
	long		ulFlags;
	long		lpfn;
	long		lParam;
	int		iImage;
}BROWSEINFO;

DWORD WINAPI SHBrowseForFolder(DWORD);
DWORD WINAPI SHGetPathFromIDList(long,long);
API(SHBrowseForFolder,shell32)
API(SHGetPathFromIDList,shell32)


function folder_dialog(STRING* dir)
{
	STRING* DirName = str_create("#255"); *DirName.chars=0;
	
	BROWSEINFO FOdlg;   memset(FOdlg, 0, sizeof(BROWSEINFO));   
	FOdlg.pszDisplayName    = DirName.chars;
	FOdlg.ulFlags				= NULL;
	
	long lpItem = SHBrowseForFolder(&FOdlg);
	
	if(lpItem==0)
	{
		str_remove(DirName);
		return(0);
	}
	else
	{
		SHGetPathFromIDList(lpItem, DirName.chars);
		str_cpy(dir, DirName);
		str_remove(DirName);
		return(1);
	}
}