0

I have the following code

object objectValue1 = RuntimeHelpers.GetObjectValue(NewLateBinding.LateGet(RuntimeHelpers.GetObjectValue(Interaction.GetObject("winmgmts:\\\\.\\root\\cimv2", (string) null)), (Type) null, "ExecQuery", new object[1]
    {
      (object) "Select * from WIN32_NetworkAdapterConfiguration"
    }, (string[]) null, (Type[]) null, (bool[]) null));
    try
    {
      foreach (object obj in (IEnumerable) objectValue1)
      {
        object objectValue2 = RuntimeHelpers.GetObjectValue(obj);
        string Left;
        try
        {
          Left = Conversions.ToString(NewLateBinding.LateGet(objectValue2, (Type) null, "MACAddress", new object[0], (string[]) null, (Type[]) null, (bool[]) null));
        }

I am trying to read out my mac addresses but the problem is that i sometimes have 3 times the same mac address and sometimes my mac address of the ras adapter changes. Can you help me?

wmicguy
  • 1
  • 1
  • your code is very unreadable, I suggest you use c# built-in [WMI Query](https://stackoverflow.com/questions/6264453/how-to-construct-wmi-query). Or even better use wrapper like [Kexla](https://www.nuget.org/packages/Ofir.Kexla) or [ORMi](https://github.com/nicoriff/ORMi).If the problem persist please a screen capture of you new code and the results – styx Apr 02 '19 at 12:41
  • do you have any idea if the rsa adapter can change its network address? – wmicguy Apr 02 '19 at 12:43
  • there is something called [random hardware addresses](https://support.microsoft.com/en-us/help/4027925/windows-how-and-why-to-use-random-hardware-addresses) your RSA adapter might use this technique – styx Apr 02 '19 at 12:51
  • Each IP address will have a MAC. If you have multiple adapter cards on PC or an adapter card that can have multiple IP addresses you may get more than one MAC. – jdweng Apr 02 '19 at 13:03
  • ok so far i understand, but what i dont understand is the following: the ras adapter how can i choose random hardware addresses on win7 – wmicguy Apr 02 '19 at 13:08

0 Answers0