C# WinForm如何或取网上邻居

解决方案 »

  1.   

       //得到路径        private RegistryKey folders;        private RegistryKey OpenRegistryPath(RegistryKey root, string s)
            {
                s = s.Remove(0, 1) + @"\";
                while (s.IndexOf(@"\") != -1)
                {
                    root = root.OpenSubKey(s.Substring(0, s.IndexOf(@"\")));
                    s = s.Remove(0, s.IndexOf(@"\") + 1);
                }
                return root;
            }        public string Customize(string path)
            {
                folders = OpenRegistryPath(Registry.CurrentUser, @"\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders");  
                return folders.GetValue(path).ToString();
            } public void OpenNetWork()       //打开网上邻居 --------->
            {
                string path = Customize("NetHood");
                System.Diagnostics.Process.Start(path);
            }