internal static int AddConnection(IWin32Window owner, NETRESOURCE resource)
 {
     if (owner == null)
     {
         return Winnetwk.WNetAddConnection2(ref resource, null, null, CONNECT.CONNECT_PROMPT | CONNECT.CONNECT_INTERACTIVE);
     }
     Control control = owner as Control;
     if ((control != null) && control.InvokeRequired)
     {
         return (int) control.Invoke(new AddConnectionHanlder(NetworkFileSystemCreator.AddConnection), new object[] { owner, resource });
     }
     return Winnetwk.WNetAddConnection3(owner.Handle, ref resource, null, null, CONNECT.CONNECT_PROMPT | CONNECT.CONNECT_INTERACTIVE);
 }
        public static IVirtualFolder FromFullName(string fullName, IVirtualFolder parent)
        {
            if (fullName == null)
            {
                throw new ArgumentNullException("fullName");
            }
            if (fullName.StartsWith(PathHelper.UncPrefix))
            {
                return new NetworkFolder(fullName, parent);
            }
            Uri uri = new Uri(fullName);
            if (uri.Scheme != UriScheme)
            {
                throw new ArgumentException(string.Format(Resources.sErrorAnotherSchemeExpected, UriScheme, uri.Scheme));
            }
            if (uri.Host != ".")
            {
                throw new ArgumentException(string.Format(Resources.sErrorOnlyDotHostAccepted, uri.Host));
            }
            string[] strArray = uri.LocalPath.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
            NETRESOURCE resource = new NETRESOURCE {
                dwType = RESOURCETYPE.RESOURCETYPE_ANY,
                dwUsage = RESOURCEUSAGE.RESOURCEUSAGE_CONTAINER
            };
            switch (strArray.Length)
            {
                case 0:
                    return NetworkRoot;

                case 1:
                    resource.lpProvider = strArray[0];
                    resource.lpRemoteName = strArray[0];
                    resource.dwUsage |= (RESOURCEUSAGE) (-2147483648);
                    resource.dwDisplayType = RESOURCEDISPLAYTYPE.RESOURCEDISPLAYTYPE_NETWORK;
                    return new NetworkFolder(resource, parent ?? NetworkRoot);

                case 2:
                    resource.lpProvider = strArray[0];
                    resource.lpRemoteName = strArray[1];
                    resource.dwDisplayType = RESOURCEDISPLAYTYPE.RESOURCEDISPLAYTYPE_DOMAIN;
                    return new NetworkFolder(resource, parent);
            }
            throw new ArgumentException(string.Format("'{0}' is not valid network folder name", fullName));
        }
Пример #3
0
 public static extern int SHGetDataFromIDList(IShellFolder psf, IntPtr pidl, SHGetDataFromIDListFormat nFormat, ref NETRESOURCE pv, int cb);
Пример #4
0
 public static int SHGetDataFromIDList(IShellFolder psf, IntPtr pidl, ref NETRESOURCE pv)
 {
     return SHGetDataFromIDList(psf, pidl, SHGetDataFromIDListFormat.SHGDFIL_NETRESOURCE, ref pv, Marshal.SizeOf((NETRESOURCE) pv));
 }