本文整理汇总了C#中System.Management.ManagementObject.GetPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementObject.GetPropertyValue方法的具体用法?C# ManagementObject.GetPropertyValue怎么用?C# ManagementObject.GetPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.ManagementObject
的用法示例。
在下文中一共展示了ManagementObject.GetPropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnterLicense_Load
private void EnterLicense_Load(object sender, EventArgs e)
{
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
string temp = Des.EncryptDES(disk.GetPropertyValue("VolumeSerialNumber").ToString(), Des.ConstKey);
tempStr = Des.EncryptDES(Des.EncryptDES(disk.GetPropertyValue("VolumeSerialNumber").ToString(), Des.ConstKey), Des.ConstKey);
this.txtOnlyMsg.Text = temp.Trim();
this.txtLicense.Text = DealXml.ReadSysConfig("appSettings", "license");
}
示例2: DisplayResourcePool
DisplayResourcePool(
ManagementObject pool)
{
Console.WriteLine("Msvm_ResourcePool:");
Console.WriteLine("\tPoolID: {0}", pool.GetPropertyValue("PoolID"));
Console.WriteLine("\tInstanceID: {0}", pool.GetPropertyValue("InstanceID"));
Console.WriteLine("\tResourceType: {0}", pool.GetPropertyValue("ResourceType"));
Console.WriteLine("\tResourceSubtype: {0}", pool.GetPropertyValue("ResourceSubType"));
}
示例3: GetDiskVolumeSerialNumber
//获取硬盘卷标号
public static string GetDiskVolumeSerialNumber()
{
ManagementClass mc = new ManagementClass("win32_NetworkAdapterConfiguration");
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
return disk.GetPropertyValue("VolumeSerialNumber").ToString();
}
示例4: CService
/// <summary>
/// Initializes a new instance of TaskManager.CService class to the value of System.ServiceProcess.ServiceController object.
/// </summary>
/// <param name="Srvc">Object of System.ServiceProcess.ServiceController to initialize TaskManager.CService object.</param>
public CService(ServiceController Srvc)
{
Name = Srvc.ServiceName;
Description = Srvc.DisplayName;
Status = Srvc.Status;
ManagementObject MO = new ManagementObject(@"Win32_service.Name='" + Srvc.ServiceName + "'");
Id = Int32.Parse(MO.GetPropertyValue("ProcessID").ToString());
}
示例5: GetDiskVolumeSerialNumber
/// <summary>
/// 取得设备硬盘的卷标号
/// </summary>
/// <returns></returns>
private string GetDiskVolumeSerialNumber() {
try {
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
return disk.GetPropertyValue("VolumeSerialNumber").ToString();
} catch {
return "unknow";
} finally {
}
}
示例6: IsThisExecutable
private static bool IsThisExecutable(ManagementObject mo)
{
var path = mo.GetPropertyValue("PathName").ToString();
return path.Contains(Assembly.GetEntryAssembly().Location);
}
示例7: getVolumnSerial
/// <summary>
/// ȡӲ�����к�
/// </summary>
/// <returns></returns>
private string getVolumnSerial()
{
string serial;
try
{
System.Management.ManagementObject disk = new System.Management.ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
//ȡ�������
System.Net.IPHostEntry myHost = new System.Net.IPHostEntry();
myHost = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName());
string computername = myHost.HostName.ToString().Trim();
computername = "";
serial=disk.GetPropertyValue("VolumeSerialNumber").ToString();
return serial;
}
catch
{
return "24F779C7";
}
}
示例8: GetVolumeID
public string GetVolumeID()
{
ManagementObject managementObject = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
string result;
try
{
managementObject.Get();
result = managementObject.GetPropertyValue("VolumeSerialNumber").ToString();
return result;
}
catch
{
}
result = "ABC";
return result;
}
示例9: DisplayPoolResourceAllocationSettingData
DisplayPoolResourceAllocationSettingData(
ManagementScope scope,
ManagementObject pool)
{
using (ManagementObject rasd =
MsvmResourceAllocationSettingData.GetAllocationSettingsForPool(
scope,
pool.GetPropertyValue("ResourceType").ToString(),
pool.GetPropertyValue("ResourceSubType").ToString(),
pool.GetPropertyValue("PoolId").ToString()))
{
DisplayPoolResourceAllocationSettingData(rasd);
}
}
示例10: ServiceStartupType
static string ServiceStartupType(string ServiceName)
{
string objPath = string.Format("Win32_Service.Name='{0}'", ServiceName);
using (ManagementObject service = new ManagementObject(new ManagementPath(objPath)))
{
try
{
return (string)service.GetPropertyValue("StartMode");
}
catch
{
return string.Empty;
}
}
}
示例11: Update
public void Update(ManagementObject proc)
{
this.PreviousProcTime = this.CurrentProcTime;
this.PreviousTimeStamp = this.CurrentTimeStamp;
this.Name = Convert.ToString(proc.GetPropertyValue(PROC_NAME));
this.CurrentProcTime = Convert.ToInt64(proc.GetPropertyValue(PROC_TIME));
this.CurrentTimeStamp = Convert.ToInt64(proc.GetPropertyValue(TIME_STAMP));
this.CurrentMemory = Convert.ToInt64(proc.GetPropertyValue(WorkingSet()));
this.ProcessId = Convert.ToInt32(proc.GetPropertyValue(PROC_ID));
this.CalculateProcPercent();
}
示例12: CountQueueMessages
private void CountQueueMessages(QSetQueueItem queueItem)
{
//first of all, ensure we have a node to work with
QueueItemListViewItemPair itemPair = null;
if (_itemPairHashTable.ContainsKey(queueItem.ID))
itemPair = (QSetMonitorWorker.QueueItemListViewItemPair)_itemPairHashTable[queueItem.ID];
else
{
//TODO create icon
itemPair = new QueueItemListViewItemPair(queueItem, new ListViewItem(queueItem.Name, (int)Images.IconType.Queue));
for (int subItemCounter = 0; subItemCounter < _COLUMNS; subItemCounter ++)
itemPair.ListViewItem.SubItems.Add(string.Empty);
_itemPairHashTable.Add(itemPair.QSetQueueItem.ID, itemPair);
Action x = delegate { _monitorListView.Items.Add(itemPair.ListViewItem); };
_monitorListView.Invoke(x);
}
ManagementObject counter = null;
try
{
counter = new ManagementObject(String.Format("Win32_PerfRawdata_MSMQ_MSMQQueue.name='{0}'", itemPair.QSetQueueItem.Name));
counter.Get();
uint outgoingMessageCount = Convert.ToUInt32(counter.GetPropertyValue("MessagesInQueue"));
uint outgoingBytes = Convert.ToUInt32(counter.GetPropertyValue("BytesInQueue"));
Action herewegoagain = () =>
{
if (itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingMessageCount].Text != outgoingMessageCount.ToString()) //note: only do if necessary, to avoid flicker
itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingMessageCount].Text = outgoingMessageCount.ToString();
if (itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingBytes].Text != outgoingBytes.ToString()) //note: only do if necessary, to avoid flicker
itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingBytes].Text = outgoingBytes.ToString();
};
_monitorListView.Invoke(herewegoagain);
}
catch
{
//exception will occur when cannot get access to performance counters
}
finally
{
if (counter != null)
counter.Dispose();
}
}
示例13: ServiceStartupType
static string ServiceStartupType(string ServiceName)
{
string objPath = string.Format("Win32_Service.Name='{0}'", ServiceName);
using (ManagementObject service = new ManagementObject(new ManagementPath(objPath)))
{
try
{
string value = (string)service.GetPropertyValue("StartMode");
return value; // Auto, Manual or Disabled (note Auto not Automatic)
}
catch
{
return string.Empty;
}
}
}
示例14: GetOSServicePack
private string GetOSServicePack(string servicePack, ManagementObject managementObject)
{
int servicePackNumber = Convert.ToInt32(managementObject.GetPropertyValue("ServicePackMajorVersion"));
if (servicePackNumber != 0)
{
servicePack = $"Service Pack {servicePackNumber}";
}
return servicePack;
}
示例15: Instantiate80211
private static LinkSAP80211 Instantiate80211(ManagementObject linkSap80211MO, ushort fromMIHFPort, System.Net.IPAddress mihAddr)
{
return new LinkSAP80211((string)linkSap80211MO.GetPropertyValue("GUID"), fromMIHFPort, mihAddr);
}