예제 #1
0
        static public Dictionary <string, string> GetDisks()
        {
            Dictionary <string, string> res = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase);

            ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\Microsoft\\Windows\\Storage");
            ObjectQuery     query = new ObjectQuery("SELECT * FROM MSFT_Disk");

            ManagementObjectSearcher   searcher        = new ManagementObjectSearcher(scope, query);
            ManagementObjectCollection queryCollection = searcher.Get();

            foreach (ManagementObject m in queryCollection)
            {
                string DiskUID  = Convert.ToString(m["UniqueId"]);
                string DiskName = Convert.ToString(m["Model"]).Trim() +
                                  " - SIZE=" + FileTools.MakeNiceSize(Convert.ToInt64(m["Size"])) + " - USED=" + FileTools.MakeNiceSize(Convert.ToInt64(m["AllocatedSize"])) +
                                  " (" + (Convert.ToString(m["SerialNumber"]).Trim() == "" ? "" : "SN: " + Convert.ToString(m["SerialNumber"]).Trim() + ", ") +
                                  "Loc: " + Convert.ToString(m["Location"]).Trim() + ")";
                res.Add(DiskUID, DiskName);
            }
            return(res);
        }
예제 #2
0
 public IcoListData(string id, IcoListRegType t, RegistryKey reg)
 {
     Type = t;
     ID   = id;
     Name = Convert.ToString(reg.GetValue("Name", ""));
     if (Name == "")
     {
         return;
     }
     Group = Convert.ToString(reg.GetValue("Group", ""));
     if (Group == "")
     {
         return;
     }
     IcoFile = Convert.ToString(reg.GetValue("IcoFile", ""));
     if (IcoFile == "")
     {
         return;
     }
     Execute = Convert.ToString(reg.GetValue("Execute", ""));
     if (Execute == "")
     {
         return;
     }
     try
     {
         Order = Convert.ToInt32(reg.GetValue("Order"));
     }
     catch
     {
         return;
     }
     try
     {
         UseShellEx = Convert.ToInt32(reg.GetValue("UseShellEx")) == 1 ? true : false;
     }
     catch
     {
     }
     InitSuccess = true;
     try
     {
         string FullPath = FileTools.GetFullPath(Environment.ExpandEnvironmentVariables(IcoFile));
         if (FullPath != null)
         {
             Ico = Icon.ExtractAssociatedIcon(Environment.ExpandEnvironmentVariables(FullPath));
         }
         else
         {
             Ico = Icon.ExtractAssociatedIcon(Environment.ExpandEnvironmentVariables(IcoFile));
         }
         if (Ico == null)
         {
             Ico = Resources.exec;
         }
     }
     catch
     {
         Ico = Resources.exec;
     }
 }