how to release the item identifier list of SHBrowseForFolder

May 11, 2008
21,389
1,245
126
Hello everybody,
I am programming under visual studio C++ 2008 an c program.
I am using the SHBrowseForFolder function with succes.
I need to know how to release the item identifier list declared with LPITEMIDLIST. In this case the pidl_browseinfo i have declared.
According to the documentation i have to free the list but does not show how. I have an example but that code does not make sense and is not working either. The function does nothing at the moment since i am not finished with programming and am still learning my way through to get to the end result.

Thank you in advance.

Here is my code snippet that does work but does not clean up the item identifier list :
Code:
// ************************************************************************************************
// This function lets the user select a new path as replacement for the outdated project path.
// Returns 1 if succesfull.
// Returns 0 on fail.
//
//
int	GetUpdatedProjectPath(HWND hWnd, struct_configdata *pntr_configdata)
{
	int						i_returnvalue = 0;
	int						i_errorvalue = 1;
	char					*sz_workbuffer;
	char					*sz_namebuffer;
	int						i = 0;
	LPITEMIDLIST	pidl_browseinfo;    // PIDL selected by user

	
		sz_workbuffer =		(char*) calloc (300,sizeof(char));
		sz_namebuffer =		(char*) calloc (100,sizeof(char));
		
		// Setup the browserinfo struct first.
		bi.hwndOwner = hWnd;
		bi.ulFlags = 0;
		//bi.ulFlags |= BIF_USENEWUI; // Shows the (new folder) option.
		bi.pidlRoot = NULL;
		bi.lpszTitle = "Please select the new project path...";
		bi.pszDisplayName = sz_namebuffer;
		bi.lpfn = NULL;
		bi.lParam = 0;
		//bi.iImage = 0;

		pidl_browseinfo = SHBrowseForFolder(&bi);

    if (pidl_browseinfo != NULL)
			{ 
      SHGetPathFromIDList(pidl_browseinfo, sz_workbuffer); 
	
 
      

      
			}
			
		// Free the PIDL returned by SHBrowseForFolder. 
		// TODO :release itemlist 
		
		free(sz_workbuffer);
		free(sz_namebuffer);
	return (i_errorvalue);
}