public void CanBouncePidl() { IntPtr pidl = default(IntPtr); try { NativeMethods.SHGetKnownFolderIDList(KnownFolderGuids.FOLDERID_Documents, KNOWN_FOLDER_FLAG.KF_NO_FLAGS, IntPtr.Zero, out pidl); var idList = PidlManager.PidlToIdlist(pidl); // Convert pidl to idlist NativeMethods.ILFree(pidl); pidl = default(IntPtr); pidl = PidlManager.IdListToPidl(idList); // Convert idlist to pidl var displayName = PidlManager.GetPidlDisplayName(pidl); Assert.AreEqual(displayName, "Documents"); } finally { if (pidl != default(IntPtr)) { NativeMethods.ILFree(pidl); } } }
private static List <string> ProcessCIDA(IntPtr p) { List <string> lFiles = new List <string>(); // Get number of items. UInt32 cidl = (UInt32)Marshal.ReadInt32(p); // Get parent folder. int offset = sizeof(UInt32); IntPtr parentpidl = (IntPtr)((int)p + (UInt32)Marshal.ReadInt32(p, offset)); StringBuilder path = new StringBuilder(256); bool br = User32.SHGetPathFromIDListW(parentpidl, path); string sParrent = PidlManager.GetPidlDisplayName(parentpidl); // Get subitems. for (int i = 1; i <= cidl; ++i) { offset += sizeof(UInt32); IntPtr relpidl = (IntPtr)((int)p + (UInt32)Marshal.ReadInt32(p, offset)); IntPtr abspidl = Shell32.ILCombine(parentpidl, relpidl); bool br1 = User32.SHGetPathFromIDListW(abspidl, path); string sFile = PidlManager.GetPidlDisplayName(abspidl); Shell32.ILFree(abspidl); if (br1) { lFiles.Add(path.ToString()); } else { lFiles.Add(string.Format("{0}\\{1}", sParrent, sFile)); } } return(lFiles); }
public void CanGetPidlDisplayName() { IntPtr pidl; Shell32.SHGetKnownFolderIDList(KnownFolders.FOLDERID_Documents, KNOWN_FOLDER_FLAG.KF_NO_FLAGS, IntPtr.Zero, out pidl); var displayName = PidlManager.GetPidlDisplayName(pidl); Shell32.ILFree(pidl); Assert.AreEqual(displayName, "Documents"); }
public void CanGetPidlDisplayName() { IntPtr pidl; Shell32.SHGetKnownFolderIDList(KnownFolders.FOLDERID_Documents, KNOWN_FOLDER_FLAG.KF_NO_FLAGS, IntPtr.Zero, out pidl); var displayName = PidlManager.GetPidlDisplayName(pidl); Shell32.ILFree(pidl); string expectedName = GetTestKnownFolderDisplayNameForMyCulture(); Assert.AreEqual(expectedName, displayName); }
public void CanBouncePidl() { IntPtr pidl; Shell32.SHGetKnownFolderIDList(KnownFolders.FOLDERID_Documents, KNOWN_FOLDER_FLAG.KF_NO_FLAGS, IntPtr.Zero, out pidl); var idList = PidlManager.PidlToIdlist(pidl); Shell32.ILFree(pidl); pidl = PidlManager.IdListToPidl(idList); var pszPath = new StringBuilder(); var displayName = PidlManager.GetPidlDisplayName(pidl); Assert.AreEqual(displayName, "Documents"); }
public void CanGetPidlDisplayName() { IntPtr pidl = default(IntPtr); try { NativeMethods.SHGetKnownFolderIDList(KnownFolderGuids.FOLDERID_Documents, KNOWN_FOLDER_FLAG.KF_NO_FLAGS, IntPtr.Zero, out pidl); var displayName = PidlManager.GetPidlDisplayName(pidl); Assert.AreEqual(displayName, "Documents"); } finally { if (pidl != default(IntPtr)) { NativeMethods.ILFree(pidl); } } }