View Single Post
Old 24-02-2005, 10:53 PM   #12 (permalink)
clipse
Member
 
Join Date: Oct 2003
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Hi

I have the following little program so far. I have got it to output the network name, description, and MAC into a little form. (I havent formatted the output or anything yet, mainly cause I don't know how to yet!)

However, I can't get a MAC to appear in Windows ME. It's fine in XP and 2000. Here is the code:

Code:
Private Sub Command1_Click()

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")
For Each objItem In colItems

    If objItem.MACAddress <> "" Then
    ListView1.ListItems.Add = (objItem.AdapterType) 'Adapter Type
    'Listview1.Width= ADJUST WIDTH!
 
   ' Select Case objItem.AdapterTypeID
     '   Case 0 strAdapterType = "Ethernet 802.3"
      '  Case 1 strAdapterType = "Token Ring 802.5"
       ' Case 2 strAdapterType = "Fiber Distributed Data Interface (FDDI)"
       ' Case 3 strAdapterType = "Wide Area Network (WAN)"
       ' Case 4 strAdapterType = "LocalTalk"
       ' Case 5 strAdapterType = "Ethernet using DIX header format"
       ' Case 6 strAdapterType = "ARCNET"
       ' Case 7 strAdapterType = "ARCNET (878.2)"
      '  Case 8 strAdapterType = "ATM"
      '  Case 9 strAdapterType = "Wireless"
      '  Case 10 strAdapterType = "Infrared Wireless"
      '  Case 11 strAdapterType = "Bpc"
      '  Case 12 strAdapterType = "CoWan"
       ' Case 13 strAdapterType = "1394"
  '  End Select
 
    'MsgBox ("Adapter Type Id: " & strAdapterType)
    'MsgBox ("AutoSense: " & objItem.AutoSense)
    ListView1.ListItems.Add = ("Description: " & objItem.Description)
    'MsgBox ("Device ID: " & objItem.DeviceID)
    Wscript.Echo "Index: " & objItem.Index
    ListView1.ListItems.Add = ("MAC: " & objItem.MACAddress) 'MAC Address
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Maximum Number Controlled: " & objItem.MaxNumberControlled
    Wscript.Echo "Maximum Speed: " & objItem.MaxSpeed
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Net Connection ID: " & objItem.NetConnectionID
    Wscript.Echo "Net Connection Status: " & objItem.NetConnectionStatus
    For Each strNetworkAddress In objItem.NetworkAddresses
        Label1.Caption = "NetworkAddress: " & strNetworkAddress
    Next
    'ListView1.ListItems.Add = ("Permanent Address: " & objItem.PermanentAddress)
    'ListView1.ListItems.Add = ("PNP Device ID: " & objItem.PNPDeviceID)
    'ListView1.ListItems.Add = (objItem.ProductName) 'Product Name
    'ListView1.ListItems.Add = ("Service Name: " & objItem.ServiceName)
    'ListView1.ListItems.Add = ("Speed: " & objItem.Speed)
    ListView1.ListItems.Add = ("END OF ITEM")
    
    End If
Next

End Sub

Private Sub Form_Load()
With ListView1
      .ListItems.Clear
      .ColumnHeaders.Clear
      .ColumnHeaders.Add , , "Adapter Type"
      .ColumnHeaders.Add , , "MAC Address"
      .ColumnHeaders.Add , , "Type"
      .ColumnHeaders.Add , , "Manufacturer"
      .ColumnHeaders.Add , , "Description"
      .View = lvwReport
      .Sorted = False
   End With
End Sub
Is there something wrong with my code or is it impossible to make it appear? Google and MSDN suggests it cannot be done though, as I can't find anything really on it. Would it work if the user installed WSH 5.x or whatever?

Thanks
clipse is offline   Reply With Quote