*Experts* DiverDan Posted October 3, 2005 *Experts* Posted October 3, 2005 This will return the CPU serial number. Imports System.Management Dim sysID As String = String.Empty Dim manClass As New ManagementClass("Win32_Processor") Dim mObjCol As ManagementObjectCollection = manClass.GetInstances Dim m As ManagementObject For Each m In mObjCol If sysID = "" Then sysID = m.Properties("ProcessorId").Value Exit For End If Next MessageBox.Show(sysID) Hope this helps. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
JDYoder Posted October 3, 2005 Author Posted October 3, 2005 The first line (Imports) doesn't work for me -- I don't have a "System.Management" namespace. Do I have to do something to enable it? Quote
*Experts* DiverDan Posted October 4, 2005 *Experts* Posted October 4, 2005 You'll need to add a reference to the System.Management dll. From the VS IDE's main menu select Project | Add Reference | .NET tab | System.Management. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
JDYoder Posted October 4, 2005 Author Posted October 4, 2005 Thanks. I thought having "System" available made everything within it available, but I guess not. Interesting that even though mObjCol is a ManagementObjectCollection, that I couldn't access the first element directly, which is why I'm guessing you made the loop. Is there any particular reason this object is set up that way? Thanks again. Quote
*Experts* DiverDan Posted October 5, 2005 *Experts* Posted October 5, 2005 I'm just guessing, but the Management Object Collection is probably setup this way to allow for various combinations and quantities of processors within a single computer. I used a loop because I only needed the first processor as a reference. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
mandelbrot Posted October 6, 2005 Posted October 6, 2005 I thought having "System" available made everything within it available No - Namespaces simply declare a hierachy, similar to a directory structure scenario, in that even though you specify System (namespace), it only provides access to the Classes within that namespace, and not to any sub-namespaces. It's very much like the With statement from VB6, allowing you to act upon that particular level (of an object/class within VB6, but Namespace within .NET) Paul. Quote
Leaders snarfblam Posted October 7, 2005 Leaders Posted October 7, 2005 Also, different libraries can define classes in the same dlls. You can reference System.Windows.Forms.dll but there still may be classes in System.Windows.Forms that you cannot access because they are defined in System.Design.Dll (not sure that that is true, but it is just an example). Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.