|
-
Apr 6th, 2005, 01:43 PM
#1
Thread Starter
Lively Member
Obtaining MAC Address
Hi. I am using VB6 and need to obtain the MAC address of the network card in my computer. The end result I would like is simply a label which displays the MAC address of the network card.
I have looked on the net already and found lots of very complicated code which I think maybe not what I need anyway.
Any help is appreciated
-
Apr 6th, 2005, 02:17 PM
#2
Hyperactive Member
Re: Obtaining MAC Address
This would work. This code uses WMI calls to get the computer information. This section of code will get the mac address of the network card that is in use that the time.
Code:
Public Sub GetWMIAdapter()
Dim oAdapters As Object
Dim oAdapter As Object
On Error Resume Next
Set oAdapters = GetObject("winmgmts:").ExecQuery( _
"SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each oAdapter In oAdapters
With oAdapter
Label1.Caption "MAC:" & vbTab & vbTab & .MACAddress
End With
Next
End Sub
If my post was helpful please rate it 
-
Apr 12th, 2005, 02:53 PM
#3
New Member
Re: Obtaining MAC Address
Hi Wiccaan
Ive done this sujestion:
Code:
Private Sub Command1_Click()
Call GetWMIAdapter
End Sub
Public Sub GetWMIAdapter()
Dim oAdapters As Object
Dim oAdapter As Object
On Error Resume Next
Set oAdapters = GetObject("winmgmts:").ExecQuery( _
"SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each oAdapter In oAdapters
With oAdapter
Label1.Caption "MAC:" & vbTab & vbTab & .MACAddress
End With
Next
End Sub
I get a compile error which says invalid use of property and highlights .caption
Im a noob to all this VB sorry if its a silly question
-
Apr 13th, 2005, 02:02 PM
#4
Thread Starter
Lively Member
Re: Obtaining MAC Address
I think you need to change the line:
Label1.caption "MAC ...
to
Label1.caption = "MAC ...
-
Apr 16th, 2005, 12:31 AM
#5
Hyperactive Member
Re: Obtaining MAC Address
As TheBoy pointed out... it was missing the '=' that was my fault. Sorry about that, but it should work.
If my post was helpful please rate it 
-
Apr 16th, 2005, 08:16 PM
#6
New Member
Re: Obtaining MAC Address
Cheers guys, silly me, im a noob 
Heres one for you wiccaan,
I need to write some code that can do a tracert www.yahoo.com (any url) and save the first Hop ip address.
Can this be done?
cheers
-
Apr 16th, 2005, 10:04 PM
#7
Re: Obtaining MAC Address
You could shellexecute tracert.exe passing the correct parameters and output to a textfile. Then read the file into your program.
Code:
tracert -d -h 1 > C:\OneHop.txt www.yahoo.com
Tracing route to www.yahoo.akadns.net [66.94.230.32]
over a maximum of 1 hops:
1 <1 ms <1 ms <1 ms 192.168.1.1
Trace complete.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|