Jump to content
Sign in to follow this  
JohnRichard

ListViewItem help

Recommended Posts

JohnRichard

i have this script which returns network info of remote PC. I 'm able to return the values in array. my problem is i cannot make the array values to be set in the ListView control. can please someone help me.

thanks very much.

code:

#include <Array.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Local $objItem, $listview, $Data

Dim $NICInfo[1][4], $i = 1

GUICreate("Network Information", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)

$listview = GUICtrlCreateListView("DHCP Server|DNSHostName|MACAddress|Description", 10, 10, 200, 150)

GUICtrlSetState(-1, $GUI_DROPACCEPTED)

GUISetState()

$strComputer = Inputbox("Network Information", "Enter computer name.")

$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$colNicConfigs = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

If IsObj($colNicConfigs) Then

For $objItem in $colNicConfigs

ReDim $NICInfo[uBound($NICInfo) + 1][4]

$NICInfo[$i][0] = $objItem.DHCPServer

$NICInfo[$i][1] = $objItem.DNSHostName

$NICInfo[$i][2] = $objItem.MACAddress

$NICInfo[$i][3] = $objItem.Description

;$NICInfo[$i][3] = $objItem.IPAddress

$i += 1

Next

$NICInfo[0][0] = UBound($NICInfo) - 1

If $NICInfo[0][0] < 1 Then

SetError(1, 1, 0)

EndIf

Else

SetError(1, 2, 0)

EndIf

$array = _ArrayDisplay($NICInfo, "Network Information List")

$Data = GUICtrlCreateListViewItem($array, $listview)

GUICtrlSetData($Data, $listview)

Share this post


Link to post
Share on other sites
Zedna

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


Local $objItem, $listview, $Data
Dim $NICInfo[1][4], $i = 1

GUICreate("Network Information", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
$listview = GUICtrlCreateListView("DHCP Server|DNSHostName|MACAddress|Description", 10, 10, 200, 150)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState()

$strComputer = InputBox("Network Information", "Enter computer name.")
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
$colNicConfigs = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
If IsObj($colNicConfigs) Then
 For $objItem In $colNicConfigs
    ReDim $NICInfo[UBound($NICInfo) + 1][4]
    $NICInfo[$i][0] = $objItem.DHCPServer
    $NICInfo[$i][1] = $objItem.DNSHostName
    $NICInfo[$i][2] = $objItem.MACAddress
    $NICInfo[$i][3] = $objItem.Description
    ;$NICInfo[$i][3] = $objItem.IPAddress
    $i += 1
 Next
 $NICInfo[0][0] = UBound($NICInfo) - 1
 If $NICInfo[0][0] < 1 Then
    SetError(1, 1, 0)
 EndIf
Else
 SetError(1, 2, 0)
EndIf

;~ $array = _ArrayDisplay($NICInfo, "Network Information List")
;~ $Data = GUICtrlCreateListViewItem($array, $listview)
;~ GUICtrlSetData($Data, $listview)

For $i = 1 To UBound($NICInfo) - 1
 $tmp = $NICInfo[$i][0] & "|" & $NICInfo[$i][1] & "|" & $NICInfo[$i][2] & "|" & $NICInfo[$i][3]
 GUICtrlCreateListViewItem($tmp, $listview)
Next

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Share this post


Link to post
Share on other sites
JohnRichard

it works like a champ. thanks for the help. i appreciate it very much. is there a way to copy the information on the listview item?

thanks.

Share this post


Link to post
Share on other sites
Zedna

it works like a champ. thanks for the help. i appreciate it very much. is there a way to copy the information on the listview item?

thanks.

Look at: _GUICtrlListView_GetNextItem(), _GUICtrlListView_GetItemText(), ClipPut()

Share this post


Link to post
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
Sign in to follow this  

×