RE: SHBrowseForFolder
- Posted by Henri.Goffin at sbs.be Sep 06, 2001
- 441 views
Hi Thomas, Too bad. On an NT4 platform i sporadically get a: "The instruction at 00417608 referenced memory at 455c3a4c. The memory could not be written" This seems to occur when the selected folder is deeply nested (say over 4-5 levels) but not always. Henri > -----Original Message----- > From: Thomas Parslow (PatRat) [SMTP:patrat at rat-software.com] > Sent: Thursday, September 06, 2001 11:09 AM > To: EUforum > Subject: Re: SHBrowseForFolder > > > > I too have worked with this API and got bogged down when it came to > > retrieving the full path from the ITEMIDLIST structure. Here's the code > > up to where I left off (I was having trouble getting the length of the > > first item in the list): > > Hi, > > I've modified your code so that it uses SHGetPathFromIDList to > convert the result (tested and working): > > include win32lib.ew > with trace > > atom binfo, result,memfolder > sequence folder > > constant xSHBrowseForFolder = registerw32Function(shell32, > "SHBrowseForFolder", > {C_POINTER}, C_POINTER) > > constant xSHGetPathFromIDList = > registerw32Function(shell32,"SHGetPathFromIDList",{C_ULONG,C_POINTER},C_ULONG) > > global constant > bfOwner = allot( Long ), > bfpidlRoot = allot( Long ), > bfDisplayName = allot( Lpsz ), > bfTitle = allot( Lpsz ), > bfFlags = allot( Long ), > bfFunction = allot( Long ), > bfParam = allot( Long ), > bfImage = allot( Long ), > SIZEOF_BROWSEINFO = allotted_size() > > binfo = acquire_mem(0, SIZEOF_BROWSEINFO) > > store( binfo, bfOwner, 0) > store( binfo, bfpidlRoot, NULL) > store( binfo, bfDisplayName, "") > store( binfo, bfTitle, "Select a Folder") > store( binfo, bfFlags, NULL) > store( binfo, bfFunction, NULL) > store( binfo, bfParam, NULL) > store( binfo, bfImage, NULL) > > result = w32Func(xSHBrowseForFolder, {binfo}) > > memfolder= allocate_string(repeat(512,0)) > if w32Func(xSHGetPathFromIDList,{result,memfolder}) then > --the string pointed to by folder now contains the path > folder = peek_string(memfolder) > else > folder = "" > end if > free(memfolder) > release_mem(binfo) > > if message_box("Folder: " & folder, "Test", MB_OK) then end if > > Thomas Parslow (PatRat) ICQ #:26359483 > Rat Software > http://www.rat-software.com/ > Please leave quoted text in place when replying > > >