Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a LPSHELLFOLDER according to a path


C++
void CLeftView::ParseSHFromPath(LPCSTR path,LPSHELLFOLDER &psfFolder)
{
	     
 LPSHELLFOLDER psfDesktop;
 SHGetDesktopFolder(&psfDesktop);
 OLECHAR olePath[MAX_PATH];   //   wide-char   version   of   path   name   
 MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,path,-1,olePath,MAX_PATH);   
 LPITEMIDLIST pidl = NULL;   //   general   purpose   
 psfDesktop->ParseDisplayName(NULL,NULL,olePath,NULL,&pidl,NULL);  
 psfDesktop->BindToObject(pidl,NULL,IID_IShellFolder,(void**)&psfFolder);
		

}

Then when i use
C++
STRRET str;
hr=SHGetDesktopFolder(&lpsf,SHGDN_NORMAL,str);

Then a ram error occurred ,can any one help me
Posted
Updated 28-Oct-11 23:25pm
v2

1 solution

Have a look at:
Selecting a Subfolder from a Particular Folder[^] - it seems like a working example of what you are trying to do.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
akira101 29-Oct-11 21:43pm    
I still cannot solve my problem,thanks all the same.is there any thing wrong with the prfFolder i get?
Espen Harlinn 30-Oct-11 18:09pm    
Did the sample application run OK?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900