Results 1 to 15 of 15

Thread: [1.0/1.1] Could anyone explain this code for me?

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    [1.0/1.1] Could anyone explain this code for me?

    HI guys. I have a piece of code to find the temperature of a computer but I just cannot understand it. Could someone help in explaining this piece of code to me and also why it is finding the temperature for some operating systems and others it is returning an error?

    Code:
    using System.Management; // Need to add reference System.Management
    
    ....
    
    string strsearch=string.Format(@"Select * from MSAcpi_ThermalZoneTemperature"); 
    System.Management.ManagementObjectSearcher p_objSet=new ManagementObjectSearcher();
    p_objSet.Scope=new ManagementScope(@"root\wmi");
    p_objSet.Query=new ObjectQuery(strsearch);
    			
    try
    {
            foreach(System.Management.ManagementObject objItem in     
            p_objSet.Get())
    	{
    		int RawData=Convert.ToInt32(objItem["CurrentTemperature"]);
    		RawData = (RawData-2732)/10;
    		txtCpu.Text = string.Format(RawData.ToString());
    
    	}// end foreach
    
    }// end try
    catch(ManagementException ee)
    {
    	MessageBox.Show("ERROR: \r\n\r\n" +ee.Message);
    
    }// end try catch

    Thanks - Jennifer
    Last edited by drattansingh; May 26th, 2006 at 08:10 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width