Beispiel #1
0
        /// <summary>
        /// Get all mount points for a volume.
        /// </summary>
        /// <param name="path">Volume Guid Path.</param>
        /// <returns>An array of strings that represent mount points.</returns>
        /// <remarks></remarks>
        public static string[] GetVolumePaths(string path)
        {
            string[] GetVolumePathsRet = default;
            int      cc   = 1024;
            int      retc = 0;
            var      mm   = new MemPtr();
            bool     r;

            mm.Alloc(cc);

            r = NativeDisk.GetVolumePathNamesForVolumeName(path, mm.Handle, cc, ref retc);
            if (!r)
            {
                return(null);
            }
            if (retc > 1024)
            {
                mm.ReAlloc(retc);
                r = NativeDisk.GetVolumePathNamesForVolumeName(path, mm, retc, ref retc);
            }

            GetVolumePathsRet = mm.GetStringArray(0L);
            mm.Free();
            return(GetVolumePathsRet);
        }
Beispiel #2
0
        public static bool GetVolumePathNamesForVolumeName(string lpszVolumeName, ref string[] lpszVolumePathNames)
        {
            var  sp = new MemPtr();
            uint ul = 0U;

            IO.GetVolumePathNamesForVolumeNameW(lpszVolumeName, IntPtr.Zero, 0U, ref ul);

            sp.Alloc((ul + 1L) * sizeof(char));

            IO.GetVolumePathNamesForVolumeNameW(lpszVolumeName, sp, (uint)sp.Length, ref ul);
            lpszVolumePathNames = sp.GetStringArray(0L);
            sp.Free();

            return(true);
        }