开发者

GetSaveFileName() not returning path of CD burning staging area on XP

I have a feature where I save a file to a location that user specifies. I'm using GetSaveFileName() to show the Save As dialog. I then use the path that it returns to write out the file to that location. I've noticed that it does not work when the user chooses the CD-RW drive on an XP machine. This same process works correctly on Vista and Windows 7. I've made the following observations:

  1. The path returned by GetSaveFileName() returns the path of the temporary staging area when choosing the CD burner root folder (F: in my case) on Win7/Vista.
  2. On XP, choosing the CD burner root folder just returns F:\ as the path. HOWEVER, if I create a sub folder using the Save As dialog and save the file in this folder (e.g. F:\folder), the path is that of the temporary folder.
  3. Using another application such as Notepad in XP will correctly redirect to the temp folder for F:\ .

So the problem only exists when saving to the root folder of the CD burner on XP. How can I achieve the same functionality as Notepad in XP and h开发者_Python百科ave Save As redirect to the temp folder so I have have a path I can write to for CreateFile()?


I think the fact that you get back the CD staging area for some paths is a "by-product" of the way the IShellFolder::GetDisplayNameOf function works. I've found that for CD burners, a PIDL for a file or folder that only exists in the staging area, will convert to a string referencing the staging area. A PIDL for a file or folder that exists on the CD (whether or not it exists in the staging area as well) will convert to a string referencing the CD. Because the root folder (by definition) exists on the CD, it's the CD path you get back as a string.

I would suggest handling this yourself. You can use the ICDBurn::GetRecorderDriveLetter function to get the recorder's drive letter - then it's trivial to compare against the string you get back from GetSaveFileName(). If you do get back a path on the CD burner, you can use SHGetFolderLocation with CSIDL_CDBURN_AREA to get the path of the staging area - then it's simply a matter of replacing the drive letter at the beginning of the path string with the path of the staging area.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜