Author |
Message |
Joseph Toulie #1 / 9
|
 Getting MAC Address
Hello Sorry if this question was posted before. I need to get the MAC address, in Win95/98/NT. If this is not possible, please tell me if I can get another *unique* PC number. The IP address is not enough. Thanks in advance
|
Tue, 04 Mar 2003 03:00:00 GMT |
|
 |
James M. Parke #2 / 9
|
 Getting MAC Address
Check out: http://www.mvps.org/vbnet/code/network/macaddress.htm HTW.
Quote: > Hello > Sorry if this question was posted before. > I need to get the MAC address, in Win95/98/NT. > If this is not possible, please tell me if I can get another *unique* PC > number. The IP address is not enough. > Thanks in advance
|
Sat, 08 Mar 2003 03:00:00 GMT |
|
 |
Michel Wals #3 / 9
|
 Getting MAC Address
Hi, There is a nice article in VBPJ (September 2000), by Ken Getz about using WMI to get that kind of info: Get the WMI Scripting 1.1 reference in your project. -------------- Public Function GetMACAddress() Dim objs As WbemScripting.SWbemObjectSet Dim obj As WbemScripting.SWbemObject Set objs = GetObject("winmgmts:").ExecQuery("SELECT MACAddress FROM Win32_NetworkAdapter WHERE " & _ " (MACAddress IS NOT Null) AND (Manufacturer <>'Microsoft')") For Each obj In objs: GetMACAddress = obj.MACAddress: Exit For: Next obj End Function --------------- Hoping it may help, Vanderghast, Access MVP
Quote: > Hello > Sorry if this question was posted before. > I need to get the MAC address, in Win95/98/NT. > If this is not possible, please tell me if I can get another *unique* PC > number. The IP address is not enough. > Thanks in advance
|
Mon, 10 Mar 2003 03:00:00 GMT |
|
 |
Nivihd_Secair #4 / 9
|
 Getting MAC Address
Quote: > Hello > Sorry if this question was posted before. > I need to get the MAC address, in Win95/98/NT. > If this is not possible, please tell me if I can get another *unique* PC > number. The IP address is not enough. > Thanks in advance > I'm From Basque Country and i don't speak english but do this:
shell("nbtstat -a IP > c:\windows\temp\net.tmp") open("c:\windows \temp\net.tmp") for input as #1 The Ultimate Line have the MAC Adress in this format MAC 04-04-E9-39-01-3D The 3rd line have then First Unique Hi!!!
|
Fri, 14 Mar 2003 03:00:00 GMT |
|
 |
lsd #5 / 9
|
 Getting MAC Address
Try this Joseph http://www.mvps.org/vbnet/code/network/macaddress.htm On Fri, 15 Sep 2000 16:29:43 -0500, "Joseph Toulier" Quote:
>Hello >Sorry if this question was posted before. >I need to get the MAC address, in Win95/98/NT. >If this is not possible, please tell me if I can get another *unique* PC >number. The IP address is not enough. >Thanks in advance
|
Sun, 06 Apr 2003 03:00:00 GMT |
|
 |
D #6 / 9
|
 Getting MAC Address
This code was kindly given to me by Jerry Aguilar, put it in a module: Option Explicit Public gintCtr As Integer Public gstrMacAdd As String Private Const NCBASTAT = &H33 Private Const NCBNAMSZ = 16 Private Const HEAP_ZERO_MEMORY = &H8 Private Const HEAP_GENERATE_EXCEPTIONS = &H4 Private Const NCBRESET = &H32 Private Type NCB ncb_command As Byte 'Integer ncb_retcode As Byte 'Integer ncb_lsn As Byte 'Integer ncb_num As Byte ' Integer ncb_buffer As Long 'String ncb_length As Integer ncb_callname As String * NCBNAMSZ ncb_name As String * NCBNAMSZ ncb_rto As Byte 'Integer ncb_sto As Byte ' Integer ncb_post As Long ncb_lana_num As Byte 'Integer ncb_cmd_cplt As Byte 'Integer ncb_reserve(9) As Byte ' Reserved, must be 0 ncb_event As Long End Type Private Type ADAPTER_STATUS adapter_address(5) As Byte 'As String * 6 rev_major As Byte 'Integer reserved0 As Byte 'Integer adapter_type As Byte 'Integer rev_minor As Byte 'Integer duration As Integer frmr_recv As Integer frmr_xmit As Integer iframe_recv_err As Integer xmit_aborts As Integer xmit_success As Long recv_success As Long iframe_xmit_err As Integer recv_buff_unavail As Integer t1_timeouts As Integer ti_timeouts As Integer Reserved1 As Long free_ncbs As Integer max_cfg_ncbs As Integer max_ncbs As Integer xmit_buf_unavail As Integer max_dgram_size As Integer pending_sess As Integer max_cfg_sess As Integer max_sess As Integer max_sess_pkt_size As Integer name_count As Integer End Type Private Type NAME_BUFFER name As String * NCBNAMSZ name_num As Integer name_flags As Integer End Type Private Type ASTAT adapt As ADAPTER_STATUS NameBuff(30) As NAME_BUFFER End Type Private Declare Function Netbios Lib "netapi32.dll" _ (pncb As NCB) As Byte Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _ hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long) Private Declare Function GetProcessHeap Lib "kernel32" () As Long Private Declare Function HeapAlloc Lib "kernel32" _ (ByVal hHeap As Long, ByVal dwFlags As Long, _ ByVal dwBytes As Long) As Long Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, _ ByVal dwFlags As Long, lpMem As Any) As Long Public strFilePath As String Public strFileName As String Public strFileName2 As String Public strPathFileSrc As String Public strFileDestName As String Public strFTP As String Public strMacFileName As String Public gintFileCtr As Integer Public gbolRunning As Boolean Public Function fnGetMac() As String Dim myNcb As NCB Dim bRet As Byte Dim str1 As String Dim str2 As String Dim str3 As String Dim str4 As String Dim str5 As String Dim str6 As String myNcb.ncb_command = NCBRESET bRet = Netbios(myNcb) myNcb.ncb_command = NCBASTAT myNcb.ncb_lana_num = 0 myNcb.ncb_callname = "* " 'The * means local, put IP in for remote. Dim myASTAT As ASTAT, tempASTAT As ASTAT Dim pASTAT As Long myNcb.ncb_length = Len(myASTAT) Debug.Print Err.LastDllError pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS _ Or HEAP_ZERO_MEMORY, myNcb.ncb_length) If pASTAT = 0 Then Debug.Print "memory allcoation failed!" Exit Function End If myNcb.ncb_buffer = pASTAT bRet = Netbios(myNcb) Debug.Print Err.LastDllError CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT) str1 = Format$(Hex(myASTAT.adapt.adapter_address(0)), "00") If Len(Trim(str1)) < 2 Then str1 = "0" & str1 str2 = Format$(Hex(myASTAT.adapt.adapter_address(1)), "00") If Len(Trim(str2)) < 2 Then str2 = "0" & str2 str3 = Format$(Hex(myASTAT.adapt.adapter_address(2)), "00") If Len(Trim(str3)) < 2 Then str3 = "0" & str3 str4 = Format$(Hex(myASTAT.adapt.adapter_address(3)), "00") If Len(Trim(str4)) < 2 Then str4 = "0" & str4 str5 = Format$(Hex(myASTAT.adapt.adapter_address(4)), "00") If Len(Trim(str5)) < 2 Then str5 = "0" & str5 str6 = Format$(Hex(myASTAT.adapt.adapter_address(5)), "00") If Len(Trim(str6)) < 2 Then str6 = "0" & str6 gstrMacAdd = str1 & "-" & str2 & "-" & str3 & "-" & str4 & "-" & str5 & "-" & str6 fnGetMac = gstrMacAdd MsgBox gstrMacAdd HeapFree GetProcessHeap(), 0, pASTAT End Function
Quote: > Try this Joseph > http://www.mvps.org/vbnet/code/network/macaddress.htm > On Fri, 15 Sep 2000 16:29:43 -0500, "Joseph Toulier"
> >Hello > >Sorry if this question was posted before. > >I need to get the MAC address, in Win95/98/NT. > >If this is not possible, please tell me if I can get another *unique* PC > >number. The IP address is not enough. > >Thanks in advance
|
Sun, 06 Apr 2003 03:00:00 GMT |
|
 |
John K #7 / 9
|
 Getting MAC Address
I know it's late, but I had the same question. The NetBios thing does not work in Win95. Last weekend, I wrote a routine to get the MAC address from the registry. I first found the MAC address in the registry. Some times it is twelve characters, and some times two chars, a space, two more chars, another space etc until you have the 12 characters. Novell stores as 33 chars, just use the last 12... Public Function MAC_From_REG() As String Dim Work As Long, StrLen As Long, KeyHandle As Long, Options As Long Dim Reserved As Long, QueryType As Long, ThisName As String, I As Byte Dim TryThis As Byte, String_Address As String, ThisByte As String ThisName = "HardwareAddress" Do ReDim ThisAddress(10) As Byte Work = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Services\VxD\DHCP\DHCPInfo0" & Trim$(Str$(TryThis)), Options, KEY_READ, KeyHandle) If Work Then Exit Do End If 'MsgBox KeyHandle StrLen = 11 Work = RegQueryValueEx(KeyHandle, ThisName, Reserved, QueryType, ThisAddress(0), StrLen) If Work Then 'MsgBox "BAD Address looking for MAC. Tell John because this won't run until it is fixed." String_Address = "" Work = RegCloseKey(KeyHandle) Exit Do End If String_Address = "" For I = 0 To StrLen - 1 ThisByte = Hex(ThisAddress(I)) If Len(ThisByte) = 1 Then ThisByte = "0" & ThisByte End If String_Address = String_Address & ThisByte Next TryThis = TryThis + 1 Work = RegCloseKey(KeyHandle) If Work Then MsgBox "Could not close Key Handle" End If Loop 'MsgBox "The Active MAC is " & String_Address & " found in " & TryThis & " iterations." If String_Address > "" Then MAC_From_REG = String_Address Exit Function End If ThisName = "0" ReDim ThisAddress(100) As Byte Work = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "network\novell\system config\Netware Dos Requester\Workstation GUID", Options, KEY_READ, KeyHandle) If Work Then MAC_From_REG = "No Reg MAC" Exit Function End If StrLen = 101 Work = RegQueryValueEx(KeyHandle, ThisName, Reserved, QueryType, ThisAddress(0), StrLen) If Work Then 'MsgBox "BAD Address looking for MAC. Tell John because this won't run until it is fixed." String_Address = "" Work = RegCloseKey(KeyHandle) MAC_From_REG = "Bad MAC Addr" Exit Function End If String_Address = "" For I = 0 To StrLen - 2 String_Address = String_Address & Chr$(ThisAddress(I)) Next If StrLen >= 13 Then String_Address = Right$(String_Address, 12) Else MAC_From_REG = "No Find MAC" 'MsgBox "Cannot find MAC Address. Tell John so he can fix this." Work = RegCloseKey(KeyHandle) 'If Work Then ' MsgBox "Cannot close Key Handle" ' Stop 'End If Exit Function End If Work = RegCloseKey(KeyHandle) If Work Then MsgBox "Cannot close Key Handle" Stop End If MAC_From_REG = String_Address End Function Hope this helps. John. Quote:
> Hello > Sorry if this question was posted before. > I need to get the MAC address, in Win95/98/NT. > If this is not possible, please tell me if I can get another *unique* PC > number. The IP address is not enough. > Thanks in advance
|
Thu, 10 Apr 2003 03:00:00 GMT |
|
 |
D #8 / 9
|
 Getting MAC Address
Doesn't work on Win95 !!! Well MS could have told me !!! That code I gave works on Win95 when the callname is "* " (16 chars long starting with a *) - this gives the local information, I have since modified this program to give computer + username aswell. Now the problem i have is trying to get it to work when given an IP and going on from that get it to work remotly. Are you saying I cant do this on Win95 ?? I got it to work once on Win98 when given the IP but my Win98 machine is not on the network and i just f*cked it up like 10 mins ago. -D
Quote: > I know it's late, but I had the same question. The NetBios thing does not > work in Win95. Last weekend, I wrote a routine to get the MAC address from > the registry. > I first found the MAC address in the registry. Some times it is twelve > characters, and some times two chars, a space, two more chars, another space > etc until you have the 12 characters. Novell stores as 33 chars, just use > the last 12... > Public Function MAC_From_REG() As String > Dim Work As Long, StrLen As Long, KeyHandle As Long, Options As Long > Dim Reserved As Long, QueryType As Long, ThisName As String, I As Byte > Dim TryThis As Byte, String_Address As String, ThisByte As String > ThisName = "HardwareAddress" > Do > ReDim ThisAddress(10) As Byte > Work = RegOpenKeyEx(HKEY_LOCAL_MACHINE, > "System\CurrentControlSet\Services\VxD\DHCP\DHCPInfo0" & > Trim$(Str$(TryThis)), Options, KEY_READ, KeyHandle) > If Work Then > Exit Do > End If > 'MsgBox KeyHandle > StrLen = 11 > Work = RegQueryValueEx(KeyHandle, ThisName, Reserved, QueryType, > ThisAddress(0), StrLen) > If Work Then > 'MsgBox "BAD Address looking for MAC. Tell John because this won't > run until it is fixed." > String_Address = "" > Work = RegCloseKey(KeyHandle) > Exit Do > End If > String_Address = "" > For I = 0 To StrLen - 1 > ThisByte = Hex(ThisAddress(I)) > If Len(ThisByte) = 1 Then > ThisByte = "0" & ThisByte > End If > String_Address = String_Address & ThisByte > Next > TryThis = TryThis + 1 > Work = RegCloseKey(KeyHandle) > If Work Then > MsgBox "Could not close Key Handle" > End If > Loop > 'MsgBox "The Active MAC is " & String_Address & " found in " & TryThis & " > iterations." > If String_Address > "" Then > MAC_From_REG = String_Address > Exit Function > End If > ThisName = "0" > ReDim ThisAddress(100) As Byte > Work = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "network\novell\system > config\Netware Dos Requester\Workstation GUID", Options, KEY_READ, > KeyHandle) > If Work Then > MAC_From_REG = "No Reg MAC" > Exit Function > End If > StrLen = 101 > Work = RegQueryValueEx(KeyHandle, ThisName, Reserved, QueryType, > ThisAddress(0), StrLen) > If Work Then > 'MsgBox "BAD Address looking for MAC. Tell John because this won't run > until it is fixed." > String_Address = "" > Work = RegCloseKey(KeyHandle) > MAC_From_REG = "Bad MAC Addr" > Exit Function > End If > String_Address = "" > For I = 0 To StrLen - 2 > String_Address = String_Address & Chr$(ThisAddress(I)) > Next > If StrLen >= 13 Then > String_Address = Right$(String_Address, 12) > Else > MAC_From_REG = "No Find MAC" > 'MsgBox "Cannot find MAC Address. Tell John so he can fix this." > Work = RegCloseKey(KeyHandle) > 'If Work Then > ' MsgBox "Cannot close Key Handle" > ' Stop > 'End If > Exit Function > End If > Work = RegCloseKey(KeyHandle) > If Work Then > MsgBox "Cannot close Key Handle" > Stop > End If > MAC_From_REG = String_Address > End Function > Hope this helps. > John.
> > Hello > > Sorry if this question was posted before. > > I need to get the MAC address, in Win95/98/NT. > > If this is not possible, please tell me if I can get another *unique* PC > > number. The IP address is not enough. > > Thanks in advance
|
Fri, 11 Apr 2003 03:00:00 GMT |
|
 |
Mark Townshen #9 / 9
|
 Getting MAC Address
A short form using WMI Sub Network() Set NICSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Ne tworkAdapter") For Each NIC In NICSet debug.print NIC.Name & vbTab & NIC.MACAddress Next End Sub
Quote: > Hello > Sorry if this question was posted before. > I need to get the MAC address, in Win95/98/NT. > If this is not possible, please tell me if I can get another *unique* PC > number. The IP address is not enough. > Thanks in advance
|
Fri, 20 Jun 2003 23:45:38 GMT |
|
|
|