Esempio n. 1
0
        public CGFolder(
CGPidl pidl
)
        {
            Open(pidl);
        }
Esempio n. 2
0
        public void Close()
        {
            // Should we cleanup the identifier?
            if (m_pidl != null)
            m_pidl.Dispose();

            m_pidl = null;

            // Should we cleanup the folder?
            if (m_folder != null)
            Marshal.ReleaseComObject(m_folder);

            m_folder = null;
        }
Esempio n. 3
0
        public void Open(
CGPidl pidl
)
        {
            // Clone the identifier.
            m_pidl = (CGPidl)pidl.Clone();

            // Create the folder reference.
            InitializeFolder();
        }
Esempio n. 4
0
        public void Open(
string fullPath
)
        {
            // Create the identifier.
            m_pidl = new CGPidl(fullPath);

            // Create the folder reference.
            InitializeFolder();
        }
Esempio n. 5
0
        public void Open(
Environment.SpecialFolder specialFolder
)
        {
            // Free any open resources.
            Close();

            // Create the identifier.
            m_pidl = new CGPidl(specialFolder);

            // Create the folder reference.
            InitializeFolder();
        }
Esempio n. 6
0
        public System.Collections.ArrayList GetChildren(
bool showHiddenObjects,
bool showNonFolders,
bool sortResults
)
        {
            ArrayList children = new ArrayList();
            NativeMethods.IEnumIDList enumList = null;

            try
            {
            // Sanity check the folder before attempting to use it.
            if (m_pidl == null || !m_pidl.IsFolder || m_folder == null)
            return children;

            // Get the enumerator for the object.
            int hr = m_folder.EnumObjects(
            IntPtr.Zero,
            NativeMethods.SHCONTF.SHCONTF_FOLDERS |
            (showNonFolders ?
            NativeMethods.SHCONTF.SHCONTF_NONFOLDERS : 0) |
            (showHiddenObjects ?
            NativeMethods.SHCONTF.SHCONTF_INCLUDEHIDDEN : 0),
            out enumList
            );

            // Did we fail?
            if (hr != 0)
            Marshal.ThrowExceptionForHR(hr);

            IntPtr pidl = IntPtr.Zero;
            int fetched = 0;

            // Loop and walk through the child objects.
            while (enumList.Next(1, ref pidl, out fetched) == 0 &&
            fetched == 1)
            {

            // Create a new identifier for the object.
            CGPidl child = new CGPidl(
            m_pidl.Pidl,
            pidl
            );

            // Add the object to the array.
            children.Add(child);

            } // End while there are more child objects.

            // Should we sort the results?
            if (sortResults)
            children.Sort();

            } // End try

            finally
            {

            // Should we cleanup the enumerator reference?
            if (enumList != null)
            Marshal.ReleaseComObject(enumList);

            enumList = null;

            } // End finally

            // Return the list of children.
            return children;
        }
Esempio n. 7
0
        public object Clone()
        {
            // Clone the object.
            CGPidl pidl = new CGPidl();
            pidl.m_pidl = NativeMethods.ILClone(m_pidl);
            pidl.m_displayName = m_displayName;
            pidl.m_typeName = m_typeName;
            pidl.m_attributes = m_attributes;
            pidl.m_physicalPath = m_physicalPath;

            // Return the clone.
            return pidl;
        }