Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

The only thing i've used it the hdd serial number. I don't know about the MAC address, and i'd like to find out :)

Here is what i have:

First you need a reference to Microsoft Windows Scripting Runtime

which is a COM component and you add it as reference in your solution

 

After that you can get the serial number of any media like this

Dim fso As Scripting.FileSystemObject
fso = New Scripting.FileSystemObject()
fso.GetDrive("C").SerialNumber

Note: This will not give you the HEX xxxx-xxxx that you get on dir command but a long number, which is the media serial number.

you can get the number for any kind of media like cds and flopy disks.

Posted

i just thought another way about the MAC address if you're interested

step1:

You make .bat file with the command

@ipconfig /all >> ipconf.txt

step2:

you run it through your application like

system.diagnostics.process.start("xxx.bat")

step3:

you parse the ipconf.txt

it's not the best way .. but it's an idea

  • 11 months later...
Posted

I came out with this function based on the code found from http://www.dotnet247.com/247reference/msgs/4/21219.aspx

I use this to create computer specific md5sum for identifying. Btw you need to add System.Management reference to your project.

 


Imports System.Management

       Public Function GetFirstMac() As String
           'returns the mac address without :'s for first network adapter found
           'returns "" if none found

           Const sQuery = "SELECT MacAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = true"
           Dim oRet As ManagementObjectSearcher = New ManagementObjectSearcher(sQuery)
           Dim MCol As ManagementObjectCollection = oRet.Get()
           Dim MObj As ManagementObject
           Dim MacNow As String
           For Each MObj In MCol
               Debug.WriteLine(MObj("MacAddress"))
               MacNow = MObj("MacAddress")
               If (Not IsNothing(MacNow)) Then
                   MacNow = Replace(MacNow, ":", "")
                   If Len(MacNow) = 6 * 2 Then '6 x hex
                       Return MacNow
                   End If
               End If
           Next
           Return ""
       End Function

BS - Beer Specialist

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...