Jump to content

Need Reg Listview and Treeview Help


Recommended Posts

I have 2 problem:

1:

I want to create a Treeview which display a Registry key and all its subkey and when the Key Expand it has one icon, Collapes has other icon. I've tried some way but failed ;)(

2: I found a useful UDF (KaFu's _EnumRegKeys2Array() UDF) and i've tried to display it using ListView and still fail

Eg:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
$URL = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"

$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$ListView = GUICtrlCreateListView("Name|Type|Data", 16, 24, 602, 406,BitOR($LVS_REPORT,$LVS_EDITLABELS,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$LVS_SORTDESCENDING))
        _GUICtrlListView_SetUnicodeFormat($ListView, True)
        _GUICtrlListView_SetColumnWidth($ListView, 0, 120)
        _GUICtrlListView_SetColumnWidth($ListView, 1, 50)
        _GUICtrlListView_SetColumnWidth($ListView, 2, 200)
$Result = _EnumRegKeys2Array($URL)
_Example1()
;_Example2()
Func _Example1()
For $i = 1 to $Result[0][0]
        ;_GUICtrlListView_SetItemImage($ListView,0, "C:\Documents and Settings\HippyNotRight\Desktop\New Folder\RegEdit\REG_SZ.ico")
        _GUICtrlListView_AddItem($ListView,$Result[$i][0],$i)
        _GUICtrlListView_AddSubItem($ListView,0,$Result[$i][2],1,1)
        _GUICtrlListView_AddSubItem($ListView, 0,$Result[$i][1],2,2)
Next
GUISetState(@SW_SHOW)
EndFunc


Func _Example2()
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView))
    _GUICtrlListView_AddArray($ListView,$Result)
GUISetState(@SW_SHOW)
EndFunc

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd


Func _EnumRegKeys2Array($sRegKey)
    Local Const $REG_NONE = 0
    Local Const $REG_SZ = 1
    Local Const $REG_EXPAND_SZ = 2
    Local Const $REG_BINARY = 3
    Local Const $REG_DWORD = 4
    Local Const $REG_DWORD_BIG_ENDIAN = 5
    Local Const $REG_LINK = 6
    Local Const $REG_MULTI_SZ = 7
    Local Const $REG_RESOURCE_LIST = 8
    Local Const $REG_FULL_RESOURCE_DESCRIPTOR = 9
    Local Const $REG_RESOURCE_REQUIREMENTS_LIST = 10
    Local Const $REG_QWORD = 11 ; Vista
   
    Local $aResult[1][3], $aResult_sub, $i, $y
    Local $sRegKey_Name, $sRegKey_Value, $sRegKey_Type
   
    if stringright($sRegKey,1) <> "\" then $sRegKey = $sRegKey & "\"
    $aResult[0][0] = "0"
   
    $i = 1
    while 1
        $sRegKey_Name = RegEnumVal($sRegKey, $i)
        if @error then ExitLoop
        redim $aResult[ubound($aResult)+1][3]
        $aResult[ubound($aResult)-1][0] = $sRegKey & $sRegKey_Name
        $sRegKey_Value = RegRead($sRegKey,$sRegKey_Name)
        $sRegKey_Type = @extended

        if $sRegKey_Type = $REG_NONE then $sRegKey_Type = "REG_NONE"
        if $sRegKey_Type = $REG_SZ then $sRegKey_Type = "REG_SZ"
        if $sRegKey_Type = $REG_EXPAND_SZ then $sRegKey_Type = "REG_EXPAND_SZ"
        if $sRegKey_Type = $REG_BINARY then $sRegKey_Type = "REG_BINARY"
        if $sRegKey_Type = $REG_DWORD then $sRegKey_Type = "REG_DWORD"
        if $sRegKey_Type = $REG_DWORD_BIG_ENDIAN then $sRegKey_Type = "REG_DWORD_BIG_ENDIAN"
        if $sRegKey_Type = $REG_LINK then $sRegKey_Type = "REG_LINK"
        if $sRegKey_Type = $REG_MULTI_SZ then $sRegKey_Type = "REG_MULTI_SZ"
        if $sRegKey_Type = $REG_RESOURCE_LIST then $sRegKey_Type = "REG_RESOURCE_LIST"
        if $sRegKey_Type = $REG_FULL_RESOURCE_DESCRIPTOR then $sRegKey_Type = "REG_FULL_RESOURCE_DESCRIPTOR"
        if $sRegKey_Type = $REG_RESOURCE_REQUIREMENTS_LIST then $sRegKey_Type = "REG_RESOURCE_REQUIREMENTS_LIST"
        if $sRegKey_Type = $REG_QWORD then $sRegKey_Type = "REG_QWORD" ; Vista
               
        $aResult[ubound($aResult)-1][1] = $sRegKey_Value
        $aResult[ubound($aResult)-1][2] = $sRegKey_Type
        $i += 1
    WEnd

    $i = 1
    while 1
        $sRegKey_Name = RegEnumKey($sRegKey, $i)
        if @error then ExitLoop
        $aResult_sub = _EnumRegKeys2Array($sRegKey & $sRegKey_Name)
        if ubound($aResult_sub) > 1 Then
            for $y = 1 to UBound($aResult_sub)-1
                redim $aResult[ubound($aResult)+1][3]
                $aResult[ubound($aResult)-1][0] = $aResult_sub[$y][0]
                $aResult[ubound($aResult)-1][1] = $aResult_sub[$y][1]
                $aResult[ubound($aResult)-1][2] = $aResult_sub[$y][2]
            next
        EndIf
        $i += 1
    WEnd

    $aResult[0][0] = UBound($aResult)-1
    return $aResult

EndFunc

You can see the Eg1 and Eg2 not display the Array correctly. How can i display $result to a Listview?

Thanks in advanced!

4m848p10.gif 

Link to comment
Share on other sites

Your current script is a ListView, not a TreeView. Start out with the help file examples for either the native GuiCtrlCreateTreeViewItem(), or the UDF functions _GuiCtrlTreeView_*.

Once you have recoded for a TreeView, what did you want these buttons to do? A TreeView control already has expand/collapse controls built in to it (the "+/-" at the juctions).

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

i mean i have 2 problems, the example you said is problem 2. I dont know to display this listview correctly

and problem 1(treeview prob) i still unsolve it ;)

Edit: Problem 2 solved ;) still have problem 1 :)

Edited by LeHuynhNam

4m848p10.gif 

Link to comment
Share on other sites

OK, it's more clear now and I think I should have recognized it quicker: You want a "folder" treeview, with the contents of the selected treeview item displayed in the listview. Is that right?

I would start off coding your basic GUI layout with the treeview (empty for now) and listview both displayed, then add the functional parts a little at a time, like the basic registry search to populate the tree view, determining which item is selected, then listing the contents of that item in the listview, etc.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

i found some useful link

http://www.autoitscript.com/forum/index.php?showtopic=115334&view=findpost&p=809823

i'm now still try to make my own scripts ;) but seem difficult.

I have another Listview question? how could i display (Default) Key name to listview? (Default) key always return "" and doesnt appear on listview :)

4m848p10.gif 

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...