Due to the development of a MIS system some time ago, the MIS is a non-free software, so the corresponding registration module must be developed when the system is developed, because it is a B/S system, I chose a unique Nic MAC address for the pattern registration. If you have less time to talk about it, let's get into the question below. Because the system is a commercial software, the following code only contains the code idea and simple implementation code. For details, you can freely use the code or share it with me.
---------------------- Extract information of all NICs --------------------'
Public Function getmacinfo ()
On Error resume next
Dim FSO, filestr, aspsleepthread, inclustr, Sysdir, wshshell, cmsid, macfilecontentfile, macfilecontent
Const MacFile = "tmpyesoulsoft001.llp"
Set FSO = server. Createobject ("scripting. FileSystemObject ")
Sysdir = Split (globalmod. getsysdir, ",") (1)
If instr (lcase (Sysdir), "System32") = 0 then
Getmacinfo = "this system can only run in 32-bit systems, such as NT, Windows 2000, Windows. net, Windows XP, and Windows 2003. It does not support 32-bit or lower systems! "
'Www .knowsky.com
Exit Function
Else
Using STR = Sysdir + "/cmd.exe/C" + Sysdir + "/ipconfig.exe/All>" + server. mappath (MacFile)
End if
Cmsid = shell (reverse STR, vbhide)
If cmsid <> 0 then
Set macfilecontentfile = FSO. opentextfile (server. mappath (MacFile), 1, false, tristateusedefault)
'Getmacinfo = macfilecontentfile. readall ()
'Response. Flush
Filestr = macfilecontentfile. readall ()
Macfilecontentfile. Close
Set macfilecontentfile = nothing
Set aspsleepthread = server. Createobject ("yesoulsoft. sleepthread ")
'Defines the thread suspension time, in milliseconds.
Aspsleepthread. sleeptime = 500
Aspsleepthread. beginsleepthread
Getmacinfo = executeone (filestr, "physical address .........:(.*)")
Set aspsleepthread = nothing
Else
Getmacinfo = "the system cannot obtain your network information currently. Check the permission inheritance relationship before running the system! "
Exit Function
End if
Delfile MacFile
Set FSO = nothing
End Function
'------------------ Match the result in a string -------------------'
Public Function executeone (inpstr, patstr)
Dim ore, omatch, omatches
Set ORE = new Regexp
Ore. pattern = patstr
Inpstr = lcase (inpstr)
Ore. ignorecase = true
Set omatches = ore. Execute (inpstr)
Set omatch = omatches (0)
Executeone = omatch. submatches (0)
End Function
In the code, the getmacinfo function can only obtain the MAC address of the first Nic. You can refer to DNS, gateway, and other information.