Jump to content

Detecting Network adapter and creating variables with the info


ravaged1
 Share

Recommended Posts

The code below pulled the info needed, but I want to build a drop down list so the user can select the "Description"

Then I'll bind to the corresponding "ServiceName" of that Nic. So I need to get this info into Variables somehow.

$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"
For $i = 1 To 50
    $var = RegEnumKey($key, $i)
    If @error <> 0 Then ExitLoop
    Local $var2 = RegRead($key & $var, "ServiceName")
    Local $var3 = RegRead($key & $var, "Description")

    MsgBox(4096, "ServiceName:", $var & $var2 & $var3)
Next

 Anyone know the best way to accomplish this goal?

Do I need to use an array?

Link to comment
Share on other sites

raveged1,

This may help get you started... 

#include <array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

local $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"

local $aResult[50][2]   ; max of 50 as indicated by your loop

For $i = 1 To 50
    $var = RegEnumKey($key, $i)
    If @error <> 0 Then ExitLoop
    $aResult[$i-1][0] = RegRead($key & $var, "ServiceName")
    $aResult[$i-1][1] = RegRead($key & $var, "Description")
Next

redim $aResult[$i][2]   ; reduce array to used number of rows

_arraydisplay($aResult)

local $gui010   =   guicreate('Simple Drop Down Box From Array')
local $cards    =   guictrlcreatecombo('Select a Network Card...',20,20,300,20)

local $pop_str
for $1 = 0 to ubound($aResult) - 1
    if $aResult[$1][1] <> '' then $pop_str &= $aResult[$1][1] & '|'
Next

GUICtrlSetData($cards,$pop_str)

guisetstate()

while 1
    switch guigetmsg()
        case $GUI_EVENT_CLOSE
            Exit
        case $cards
            ConsoleWrite('Item selected = ' & guictrlread($cards) & @LF)
    EndSwitch
wend

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...