[DllImport("shell32.dll", SetLastError=true)]
private static extern uint SHGetSpecialFolderLocation(IntPtr hwndOwner, int nFolder, out IntPtr ppidl);
/// <summary>
/// Retrieves a pointer to the <b>ITEMIDLIST</b> structure of a special folder.
/// </summary>
/// <param name="hwndOwner">Handle to the owner window the client should
/// specify if it displays a dialog box or message box.</param>
/// <param name="folder">The folder of interest.</param>
/// <returns>A pointer to the <b>ITEMIDLIST</b> structure of a special folder.</returns>
/// <exception cref="Win32Exception">When the the unmanaged function returns a failure error code.</exception>
public static IntPtr GetSpecialFolderLocation(IntPtr hwndOwner, Environment.SpecialFolder folder)
{
IntPtr ppidl;
uint result = SHGetSpecialFolderLocation(hwndOwner, (int) folder, out ppidl);
if(result != 0)
throw new Win32Exception();
return ppidl;
}