Among the various CSIDL values you can pass to functions like SHGetSpecialFolderLocation are CSIDL_DESKTOP and CSIDL_DESKTOPDIRECTORY. What's the difference between them?

The CSIDL_DESKTOP is the virtual folder that represents the desktop. The contents of this virtual folder is what gets displayed on top of your wallpaper.

The CSIDL_DESKTOP virtual folder is populated from various locations, some of them virtual, and some of them physical. The CSIDL_DESKTOPDIRECTORY special folder is a physical folder that contains the files that you think of as on your desktop. These are the files that you've saved to your desktop, files that you've dragged to your desktop, that sort of thing. Some files on the desktop come from CSIDL_COMMON_DESKTOPDIRECTORY, which is the shared desktop. Files in the shared desktop directory are visible to all users.

What does this mean for you, the programmer? (Well, assuming you are still using CSIDL values and haven't switched over to the new FOLDERID model.)

Programs shouldn't care about CSIDL_DESKTOPDIRECTORY; they should just operate on CSIDL_DESKTOP, because that's what the user sees. If you want to generate an ITEMIDLIST for a file on the desktop, use the CSIDL_DESKTOP folder. The physical folder behind the desktop can change (for example, due to roaming user profiles), but the logical location on the desktop remains fixed. If you had generated the ITEMIDLIST based on CSIDL_DESKTOPDIRECTORY, then the experience for your users will be much more annoying: They will get file not found errors if the user profile roams to another machine (since the directory has changed). If they perform a Save As operation, the default save location will be some deep file system path instead of just being the desktop.

The CSIDL_DESKTOPDIRECTORY is the plumbing behind the scenes. Don't show it to the user; it's ugly.