WinCE下使用获取设备名

时间:2022-08-17 17:37:59
       public static string GetDeviceName()
        {
            RegistryKey folders;
            folders = OpenRegistryPath(Registry.LocalMachine, @"/Ident");
            string name = folders.GetValue("Name").ToString();
            return name;
        }

        private static 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;
        }