[c#] HELP with code (Get a unique serial from bios/cpu/harddisk...)

Discussion in 'Mixed Languages' started by Bornung1, Mar 23, 2011.

  1. Bornung1

    Bornung1 MDL Member

    Oct 9, 2010
    147
    37
    10
    I found this code on a danish site, and it should work.
    But i dont now how to compile it / use it / create a gui

    Anybody who can help with that

    My guees is that a developer can check this code in 25 sek, to see if something is wrong with the code.
    -----------------------------------------------------------------------------------------------------
    using System;
    using System.Management;

    public class MainClass
    {
    public static void Main(string[] args)
    {
    ObjectQuery wmicpus = new WqlObjectQuery("SELECT * FROM Win32_Processor");
    ManagementObjectSearcher cpus = new ManagementObjectSearcher(wmicpus);
    foreach (ManagementObject cpu in cpus.Get())
    {
    Console.WriteLine(cpu["DeviceId"] + " -- " + cpu["Name"] + " -- " + (cpu["UniqueId"] ?? "Unknown"));
    }
    ObjectQuery wmidisks = new WqlObjectQuery("SELECT * FROM Win32_LogicalDisk");
    ManagementObjectSearcher disks = new ManagementObjectSearcher(wmidisks);
    foreach (ManagementObject disk in disks.Get())
    {
    Console.WriteLine(disk["Caption"] + " -- " + (disk["VolumeName"] ?? "Empty") + " -- " + (disk["VolumeSerialNumber"] ?? "Unknown"));
    }
    Console.ReadLine();
    }
    }
     
  2. BobSheep

    BobSheep Moderator
    Staff Member

    Apr 19, 2010
    2,326
    1,358
    90
    This is c#. To compile this you will need a c# compiler. A free one is available from http://www.microsoft.com/express/Downloads/Download-2010.aspx
    And the code does look ok but I suspect that you not knowing about what the language used means you are not familiar with programming in c# and I think there's a steep learning curve ahead for you.
     
  3. Bornung1

    Bornung1 MDL Member

    Oct 9, 2010
    147
    37
    10
    You are absoluty right bobsheep :)

    I have much to learn, and i am reading to my eye's bleed. I think its very difficult and
    i might be to old to understand abstract things like coding, should have started 20 years ago :eek:

    You go where life take you :)

    Regards
    Bornung1