fb:porticula NoPaste
TreeView
Uploader: | csde_rats |
Datum/Zeit: | 18.10.2009 17:45:09 |
Case WM_NOTIFY
Dim As NMHDR Ptr nmhdr
nmhdr = Cast(NMHDR Ptr, LPARAM)
If nmhdr->hwndFrom = GetDlgItem(hDlg, IDC_TRV1) Then
Select Case nmhdr->code
Case TVN_SELCHANGED
SendDlgItemMessage(hDlg, IDC_GRD3, GM_RESETCONTENT, 0, 0)
Dim As String path(), fullpath
Dim As TVITEMEX tim
Dim As ZString * MAX_KEY_LENGTH szKey
Dim As Integer n = 0
tim.hItem = TreeView_GetSelection (GetDlgItem(hDlg, IDC_TRV1))
tim.mask = TVIF_TEXT
tim.pszText = @szKey
tim.cchTextMax = MAX_KEY_LENGTH
SendDlgItemMessage(hDlg, IDC_TRV1, TVM_GETITEM, 0, Cast(LPARAM, @tim))
ReDim Preserve path(0 To n)
path(0) = *tim.pszText
Do
n += 1
ReDim Preserve path(0 To n)
tim.hItem = TreeView_GetParent (GetDlgItem(hDlg, IDC_TRV1), tim.hItem)
tim.mask = TVIF_TEXT
tim.pszText = @szKey
tim.cchTextMax = MAX_KEY_LENGTH
If (tim.hItem = TVI_ROOT) Or (tim.hItem = 0) Then Exit Do
SendDlgItemMessage(hDlg, IDC_TRV1, TVM_GETITEM, 0, Cast(LPARAM, @tim))
path(n) = *tim.pszText
szKey = ""
Loop
For n = UBound(path) To 0 Step -1
fullpath += "\" & path(n)
Next
fullpath = Right(fullpath, Len(fullpath) - 2)
SetDlgItemText(hDlg, IDC_EDT19, StrPtr(fullpath))
Dim As HKEY hKey
Dim As String achKey
achKey = Right(fullpath, Len(fullpath) - InStr(fullpath, "\"))
Select Case UCase(Mid(fullpath, 1, InStr(fullpath, "\") - 1))
Case "HKEY_CLASSES_ROOT"
RegOpenKey(HKEY_CLASSES_ROOT, StrPtr(achKey), @hKey)
Case "HKEY_CURRENT_USER"
RegOpenKey(HKEY_CURRENT_USER, StrPtr(achKey), @hKey)
Case "HKEY_LOCAL_MACHINE"
RegOpenKey(HKEY_LOCAL_MACHINE, StrPtr(achKey), @hKey)
Case "HKEY_USERS"
RegOpenKey(HKEY_USERS, StrPtr(achKey), @hKey)
Case "HKEY_CURRENT_CONFIG"
RegOpenKey(HKEY_CURRENT_CONFIG, StrPtr(achKey), @hKey)
End Select
Dim As Dword cValues, cchValue = MAX_VALUE_NAME, cchCon = MAX_VALUE_CONTENT, retCode, dwClass
Dim As ROWDATA_REGEDIT regval
Dim As ZString * MAX_VALUE_NAME achValue
Dim As ZString * MAX_VALUE_CONTENT achCon
Dim As Integer i
Dim As String stmp
If hKey <> 0 Then
RegQueryInfoKey( _
hKey, _
NULL, NULL, NULL, _
NULL, NULL, NULL, _
@cValues, _
NULL, NULL, NULL, _
NULL)
If cValues >= 1 Then
i = 0
Do
cchValue = MAX_VALUE_NAME
achValue = "\0"
cchCon = MAX_VALUE_CONTENT
achCon = "\0"
retCode = RegEnumValue(hKey, i, _
@achValue, @cchValue, _
NULL, @dwClass, @achCon, @cchCon)
If retCode = 0 Then
If (dwClass = REG_SZ) Or _
(dwClass = REG_MULTI_SZ) Or _
(dwClass = REG_EXPAND_SZ) Then
regval.nImage = 1
Else
regval.nImage = 0
EndIf
regval.lpszName = StrPtr(achValue)
If achValue = "" Then regval.lpszName = StrPtr("(Default)")
Select Case dwClass
Case REG_BINARY: regval.lpszType = StrPtr("REG_BINARY")
Case REG_DWORD: regval.lpszType = StrPtr("REG_DWORD")
Case REG_DWORD_LITTLE_ENDIAN: regval.lpszType = StrPtr("REG_DWORD_LITTLE_ENDIAN")
Case REG_DWORD_BIG_ENDIAN: regval.lpszType = StrPtr("REG_DWORD_BIG_ENDIAN")
Case REG_EXPAND_SZ: regval.lpszType = StrPtr("REG_EXPAND_SZ")
Case REG_LINK: regval.lpszType = StrPtr("REG_LINK")
Case REG_MULTI_SZ: regval.lpszType = StrPtr("REG_MULTI_SZ")
Case REG_NONE: regval.lpszType = StrPtr("REG_NONE")
Case REG_QWORD: regval.lpszType = StrPtr("REG_QWORD")
Case REG_QWORD_LITTLE_ENDIAN: regval.lpszType = StrPtr("REG_QWORD_LITTLE_ENDIAN")
Case REG_SZ: regval.lpszType = StrPtr("REG_SZ")
End Select
If (dwClass = REG_BINARY) Or (dwClass = REG_NONE) Then
regval.lpszValue = StrPtr("Binary data, cannot display!")
Else
If (dwClass = REG_DWORD) Or _
(dwClass = REG_DWORD_LITTLE_ENDIAN) Or _
(dwClass = REG_DWORD_BIG_ENDIAN) Then
Dim As Dword dwVal
memcpy(@dwVal, @achCon, 2)
stmp = "0x" & Hex(dwVal, 8) & " (" & dwVal & ")"
regval.lpszValue = StrPtr(stmp)
ElseIf (dwClass = REG_QWORD) Or _
(dwClass = REG_QWORD_LITTLE_ENDIAN) Then
Dim As LongInt qwVal
memcpy(@qwVal, @achCon, 4)
stmp = "0x" & Hex(qwVal) & " (" & qwVal & ")"
regval.lpszValue = StrPtr(stmp)
Else
regval.lpszValue = StrPtr(achCon)
EndIf
EndIf
SendDlgItemMessage(hDlg, IDC_GRD3, GM_ADDROW, 0, Cast(LPARAM, @regval))
Else
Exit Do
EndIf
If i > cValues Then Exit Do
i += 1
Loop
EndIf
RegCloseKey(hKey)
EndIf
End Select
EndIf