donaldc104 Posted April 14, 2003 Posted April 14, 2003 Can the framework read the MAC address from Ethernet card? Or any other machine-specific data? Quote
otherside Posted April 14, 2003 Posted April 14, 2003 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. Quote
otherside Posted April 14, 2003 Posted April 14, 2003 I just calculated out of curiosity the number that exports and it's the demical value of the HEX number that you see on the dir command. Quote
donaldc104 Posted April 14, 2003 Author Posted April 14, 2003 The HDD number should be good enough - thanks! But how do I reference Microsoft Windows Scripting Runtime ? Quote
otherside Posted April 14, 2003 Posted April 14, 2003 Solution explorer -> References (right click)-> Add Reference -> COM -> Microsoft Windows Scripting Runtime Also i found something else about the MAC Address but it's a bit complicated. take a look here http://www.dotnet247.com/247reference/msgs/4/21219.aspx Quote
donaldc104 Posted April 14, 2003 Author Posted April 14, 2003 I don't have "Microsoft Windows Scripting Runtime" in my list of components. Is it a special add-on? Quote
donaldc104 Posted April 14, 2003 Author Posted April 14, 2003 Problem fixed - the reference is named "Microsoft Scripting Runtime". It was buried in a very long list of items starting with Microsoft. Quote
otherside Posted April 14, 2003 Posted April 14, 2003 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 Quote
keitsi Posted April 5, 2004 Posted April 5, 2004 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 Quote BS - Beer Specialist
CattleRustler Posted April 6, 2004 Posted April 6, 2004 yes the Windows Management Instrumentation Objects are very sweet! - So are Performance Counter Objects. have a look :) Quote mod2software Home of the VB.NET Class Builder Utility - Demo and Full versions available now!
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.