ViSiToR
Silver Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору В общем вот моя версия на аналог к RegEdit: Код: #include <GuiConstants.au3> #include <GuiTreeView.au3> #include <GuiListView.au3> Opt("GuiOnEventMode", 1) Global $My_Computer_TVID Global $HKRoot_ID_Arr[5], $TreeViewItemsArr[1] Global $HKRoot_Names_Arr[5] = ["HKCR", "HKCU", "HKLM", "HKU", "HKCC"] $Gui = GUICreate("RegEdit Ex", 600, 400) GUISetOnEvent(-3, "MainEvents") $TreeView = GUICtrlCreateTreeView(20, 30, 250, 320, _ BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), _ $WS_EX_CLIENTEDGE+$WS_EX_STATICEDGE) $ListView = GUICtrlCreateListView("Name|Type|Value", 280, 30, 300, 320, $LVS_NOSORTHEADER) $RegPath_Input = GUICtrlCreateInput("", 20, 370, 560, 20, $ES_READONLY) GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState() InitializeRegistry() While 1 Sleep(100) WEnd Func MainEvents() Switch @GUI_CtrlId Case -3 Exit EndSwitch EndFunc Func TreeViewEvents() Local $SelTree = _GUICtrlTreeViewGetTree($TreeView, "\") Local $KeyName = StringTrimLeft($SelTree, StringInStr($SelTree, "\")) GUICtrlSetData($RegPath_Input, $KeyName) _GUICtrlListViewDeleteAllItems($ListView) If @GUI_CtrlId = $My_Computer_TVID Then Return Local $DefaultItemStr = "(Default)|REG_SZ|(No Value)" Local $Instance = 0, $Value, $LV_Data = "" While 1 $Instance += 1 $Value = RegEnumVal($KeyName, $Instance) If @error Then If $LV_Data = "" Then $LV_Data = $DefaultItemStr & @LF ExitLoop EndIf $ItemValue = $Value If $Value = "" Then $ItemValue = "(Default)" $LV_Data &= $ItemValue & "|" & GetExtendedType(@extended) & "|" & RegRead($KeyName, $Value) & @LF WEnd If $LV_Data <> "" Then If Not StringInStr($LV_Data, "(Default)|") Then $LV_Data = $DefaultItemStr & @LF & $LV_Data $LV_DataArr = StringSplit($LV_Data, @LF) For $i = 1 To $LV_DataArr[0] If $LV_DataArr[$i] <> "" Then GUICtrlCreateListViewItem($LV_DataArr[$i], $ListView) Next GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, -1) GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 1, -1) GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 2, -1) Local $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($ListView)] _GUICtrlListViewSort($ListView, $B_DESCENDING, 0) EndIf EndFunc Func GetExtendedType($Extended) Local $RegTypeArr[6] = [5, "REG_SZ", "REG_MULTI_SZ", "REG_EXPAND_SZ", "REG_DWORD", "REG_BINARY"] For $i = 1 To 5 If $Extended = $i Then Return $RegTypeArr[$i] Next EndFunc Func InitializeRegistry() $My_Computer_TVID = GUICtrlCreateTreeViewItem("My Computer", $TreeView) GUICtrlSetOnEvent($My_Computer_TVID, "TreeViewEvents") GUICtrlSetColor($My_Computer_TVID, 0x0000C0) GUICtrlSetImage($My_Computer_TVID, "shell32.dll", 15) Local $WaitID_Arr[5] For $i = 0 To 4 $HKRoot_ID_Arr[$i] = GUICtrlCreateTreeViewItem($HKRoot_Names_Arr[$i], $My_Computer_TVID) GUICtrlSetOnEvent($HKRoot_ID_Arr[$i], "TreeViewEvents") GUICtrlSetImage($HKRoot_ID_Arr[$i], "shell32.dll", 5, 2) GUICtrlSetImage($HKRoot_ID_Arr[$i], "shell32.dll", 4, 4) GUICtrlSetState($HKRoot_ID_Arr[$i], $GUI_DEFBUTTON) $WaitID_Arr[$i] = GUICtrlCreateTreeViewItem("Please wait...", $HKRoot_ID_Arr[$i]) GUICtrlSetImage($WaitID_Arr[$i], "shell32.dll", 0) Next GUICtrlSetState($My_Computer_TVID, $GUI_EXPAND+$GUI_DEFBUTTON) For $i = 0 To 4 BuildRegTree($HKRoot_Names_Arr[$i], $HKRoot_ID_Arr[$i]) GUICtrlDelete($WaitID_Arr[$i]) Next EndFunc Func BuildRegTree($sPath, $TreeViewID) Local $KeysListArr[1], $SubKeysListArr, $Instance = 0, $Enum, $CurrentKeyPath Local $Ubound While 1 Sleep(1) $Instance += 1 $Enum = RegEnumKey($sPath, $Instance) If @error Then ExitLoop $CurrentKeyPath = $sPath & "\" & $Enum $Ubound = UBound($TreeViewItemsArr) ReDim $TreeViewItemsArr[$Ubound+1] $TreeViewItemsArr[$UBound] = GUICtrlCreateTreeViewItem($Enum, $TreeViewID) GUICtrlSetOnEvent($TreeViewItemsArr[$UBound], "TreeViewEvents") GUICtrlSetImage($TreeViewItemsArr[$UBound], "shell32.dll", 5, 2) GUICtrlSetImage($TreeViewItemsArr[$UBound], "shell32.dll", 4, 4) RegEnumKey($sPath, $Instance) If Not @error Then BuildRegTree($CurrentKeyPath, $TreeViewItemsArr[$UBound]) WEnd EndFunc | Паузу при обработке (Sleep(1)) я поставил только для предотвращения загрузки ЦП на момент считывания пунктов, без паузы конечно быстрее, но не достаточно быстро чтобы оправдать нагрузку на процессор. Плюс здесь в том, что в момент считывания всё же можно просматривать уже готовые разделы, прямо как в обычном RegEdit'е
---------- ViSiToR a.k.a CreatoR CreatoR это не ник, CreatoR это стиль жизни! |
|