Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c6d01ac8
Commit
c6d01ac8
authored
Aug 26, 2008
by
Alexander Nicolaysen Sørnes
Committed by
Alexandre Julliard
Aug 27, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Add listview entries as unicode.
parent
b0a8b667
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
38 deletions
+54
-38
listview.c
programs/regedit/listview.c
+54
-38
No files found.
programs/regedit/listview.c
View file @
c6d01ac8
...
...
@@ -25,6 +25,7 @@
#include <stdio.h>
#include "main.h"
#include "regproc.h"
#include "wine/unicode.h"
static
INT
Image_String
;
...
...
@@ -33,7 +34,7 @@ static INT Image_Binary;
typedef
struct
tagLINE_INFO
{
DWORD
dwValType
;
LP
T
STR
name
;
LP
W
STR
name
;
void
*
val
;
size_t
val_len
;
}
LINE_INFO
;
...
...
@@ -48,6 +49,7 @@ static BOOL g_invertSort = FALSE;
static
LPTSTR
g_valueName
;
static
LPTSTR
g_currentPath
;
static
HKEY
g_currentRootKey
;
static
WCHAR
g_szValueNotSetW
[
64
];
static
TCHAR
g_szValueNotSet
[
64
];
#define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
...
...
@@ -94,7 +96,7 @@ LPCTSTR GetValueName(HWND hwndLV)
}
/* convert '\0' separated string list into ',' separated string list */
static
void
MakeMULTISZDisplayable
(
LP
T
STR
multi
)
static
void
MakeMULTISZDisplayable
(
LP
W
STR
multi
)
{
do
{
...
...
@@ -111,30 +113,34 @@ static void MakeMULTISZDisplayable(LPTSTR multi)
/*******************************************************************************
* Local module support methods
*/
static
void
AddEntryToList
(
HWND
hwndLV
,
LP
TSTR
Name
,
DWORD
dwValType
,
static
void
AddEntryToList
(
HWND
hwndLV
,
LP
WSTR
Name
,
DWORD
dwValType
,
void
*
ValBuf
,
DWORD
dwCount
,
BOOL
bHighlight
)
{
LINE_INFO
*
linfo
;
LVITEM
item
;
LVITEM
W
item
;
int
index
;
linfo
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
LINE_INFO
)
+
dwCount
);
linfo
->
dwValType
=
dwValType
;
linfo
->
val_len
=
dwCount
;
memcp
y
(
&
linfo
[
1
],
ValBuf
,
dwCount
);
CopyMemor
y
(
&
linfo
[
1
],
ValBuf
,
dwCount
);
if
(
Name
)
linfo
->
name
=
_tcsdup
(
Name
);
else
{
linfo
->
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
Name
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
linfo
->
name
,
Name
);
}
else
{
linfo
->
name
=
NULL
;
}
item
.
mask
=
LVIF_TEXT
|
LVIF_PARAM
|
LVIF_STATE
|
LVIF_IMAGE
;
item
.
iItem
=
ListView_GetItemCount
(
hwndLV
);
/*idx; */
item
.
iSubItem
=
0
;
item
.
state
=
0
;
item
.
stateMask
=
LVIS_FOCUSED
|
LVIS_SELECTED
;
item
.
pszText
=
Name
?
Name
:
LPSTR_TEXTCALLBACK
;
item
.
cchTextMax
=
Name
?
_tcslen
(
item
.
pszText
)
:
0
;
item
.
pszText
=
Name
?
Name
:
LPSTR_TEXTCALLBACK
W
;
item
.
cchTextMax
=
Name
?
lstrlenW
(
item
.
pszText
)
:
0
;
if
(
bHighlight
)
{
item
.
stateMask
=
item
.
state
=
LVIS_FOCUSED
|
LVIS_SELECTED
;
}
...
...
@@ -155,43 +161,45 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType,
item
.
iIndent
=
0
;
#endif
index
=
ListView_InsertItem
(
hwndLV
,
&
item
);
index
=
ListView_InsertItem
W
(
hwndLV
,
&
item
);
if
(
index
!=
-
1
)
{
switch
(
dwValType
)
{
case
REG_SZ
:
case
REG_EXPAND_SZ
:
if
(
ValBuf
)
{
ListView_SetItemText
(
hwndLV
,
index
,
2
,
ValBuf
);
ListView_SetItemText
W
(
hwndLV
,
index
,
2
,
ValBuf
);
}
else
{
ListView_SetItemText
(
hwndLV
,
index
,
2
,
g_szValueNotSet
);
ListView_SetItemText
W
(
hwndLV
,
index
,
2
,
g_szValueNotSetW
);
}
break
;
case
REG_DWORD
:
{
TCHAR
buf
[
64
];
wsprintf
(
buf
,
_T
(
"0x%08x (%u)"
),
*
(
DWORD
*
)
ValBuf
,
*
(
DWORD
*
)
ValBuf
);
ListView_SetItemText
(
hwndLV
,
index
,
2
,
buf
);
WCHAR
buf
[
64
];
WCHAR
format
[]
=
{
'0'
,
'x'
,
'%'
,
'0'
,
'8'
,
'x'
,
' '
,
'('
,
'%'
,
'u'
,
')'
,
0
};
wsprintfW
(
buf
,
format
,
*
(
DWORD
*
)
ValBuf
,
*
(
DWORD
*
)
ValBuf
);
ListView_SetItemTextW
(
hwndLV
,
index
,
2
,
buf
);
}
break
;
case
REG_BINARY
:
{
unsigned
int
i
;
LPBYTE
pData
=
(
LPBYTE
)
ValBuf
;
LPTSTR
strBinary
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwCount
*
sizeof
(
TCHAR
)
*
3
+
1
);
LPWSTR
strBinary
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwCount
*
sizeof
(
WCHAR
)
*
3
+
sizeof
(
WCHAR
));
WCHAR
format
[]
=
{
'%'
,
'0'
,
'2'
,
'X'
,
' '
,
0
};
for
(
i
=
0
;
i
<
dwCount
;
i
++
)
wsprintf
(
strBinary
+
i
*
3
,
_T
(
"%02X "
)
,
pData
[
i
]
);
wsprintf
W
(
strBinary
+
i
*
3
,
format
,
pData
[
i
]
);
strBinary
[
dwCount
*
3
]
=
0
;
ListView_SetItemText
(
hwndLV
,
index
,
2
,
strBinary
);
ListView_SetItemText
W
(
hwndLV
,
index
,
2
,
strBinary
);
HeapFree
(
GetProcessHeap
(),
0
,
strBinary
);
}
break
;
case
REG_MULTI_SZ
:
MakeMULTISZDisplayable
(
ValBuf
);
ListView_SetItemText
(
hwndLV
,
index
,
2
,
ValBuf
);
ListView_SetItemText
W
(
hwndLV
,
index
,
2
,
ValBuf
);
break
;
default:
{
T
CHAR
szText
[
128
];
LoadString
(
hInst
,
IDS_REGISTRY_VALUE_CANT_DISPLAY
,
szText
,
COUNT_OF
(
szText
));
ListView_SetItemText
(
hwndLV
,
index
,
2
,
szText
);
W
CHAR
szText
[
128
];
LoadString
W
(
hInst
,
IDS_REGISTRY_VALUE_CANT_DISPLAY
,
szText
,
COUNT_OF
(
szText
));
ListView_SetItemText
W
(
hwndLV
,
index
,
2
,
szText
);
break
;
}
}
...
...
@@ -335,7 +343,7 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor
if
(
g_columnToSort
==
2
)
{
/* FIXME: Sort on value */
}
return
g_invertSort
?
_tcscmp
(
r
->
name
,
l
->
name
)
:
_tcscmp
(
l
->
name
,
r
->
name
);
return
g_invertSort
?
lstrcmpW
(
r
->
name
,
l
->
name
)
:
lstrcmpW
(
l
->
name
,
r
->
name
);
}
HWND
StartValueRename
(
HWND
hwndLV
)
...
...
@@ -461,6 +469,7 @@ HWND CreateListView(HWND hwndParent, UINT id)
/* prepare strings */
LoadString
(
hInst
,
IDS_REGISTRY_VALUE_NOT_SET
,
g_szValueNotSet
,
COUNT_OF
(
g_szValueNotSet
));
LoadStringW
(
hInst
,
IDS_REGISTRY_VALUE_NOT_SET
,
g_szValueNotSetW
,
COUNT_OF
(
g_szValueNotSetW
));
/* Get the dimensions of the parent window's client area, and create the list view control. */
GetClientRect
(
hwndParent
,
&
rcClient
);
...
...
@@ -488,33 +497,38 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR highli
DWORD
max_val_name_len
,
valNameLen
;
DWORD
max_val_size
,
valSize
;
DWORD
val_count
,
index
,
valType
;
T
CHAR
*
valName
=
0
;
W
CHAR
*
valName
=
0
;
BYTE
*
valBuf
=
0
;
HKEY
hKey
=
0
;
LONG
errCode
;
INT
count
,
i
;
LVITEM
item
;
LVITEMW
item
;
WCHAR
*
keyPathW
;
WCHAR
*
highlightValueW
;
if
(
!
hwndLV
)
return
FALSE
;
SendMessage
(
hwndLV
,
WM_SETREDRAW
,
FALSE
,
0
);
SendMessageW
(
hwndLV
,
WM_SETREDRAW
,
FALSE
,
0
);
keyPathW
=
GetWideString
(
keyPath
);
highlightValueW
=
GetWideString
(
highlightValue
);
errCode
=
RegOpenKeyEx
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
,
&
hKey
);
errCode
=
RegOpenKeyEx
W
(
hKeyRoot
,
keyPathW
,
0
,
KEY_READ
,
&
hKey
);
if
(
errCode
!=
ERROR_SUCCESS
)
goto
done
;
count
=
ListView_GetItemCount
(
hwndLV
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
item
.
mask
=
LVIF_PARAM
;
item
.
iItem
=
i
;
SendMessage
(
hwndLV
,
LVM_GETITEM
,
0
,
(
LPARAM
)
&
item
);
free
(
((
LINE_INFO
*
)
item
.
lParam
)
->
name
);
SendMessage
W
(
hwndLV
,
LVM_GETITEM
,
0
,
(
LPARAM
)
&
item
);
HeapFree
(
GetProcessHeap
(),
0
,
((
LINE_INFO
*
)
item
.
lParam
)
->
name
);
HeapFree
(
GetProcessHeap
(),
0
,
(
void
*
)
item
.
lParam
);
}
g_columnToSort
=
~
0U
;
SendMessage
(
hwndLV
,
LVM_DELETEALLITEMS
,
0
,
0L
);
SendMessage
W
(
hwndLV
,
LVM_DELETEALLITEMS
,
0
,
0L
);
/* get size information and resize the buffers if necessary */
errCode
=
RegQueryInfoKey
(
hKey
,
NULL
,
NULL
,
NULL
,
NULL
,
&
max_sub_key_len
,
NULL
,
errCode
=
RegQueryInfoKey
W
(
hKey
,
NULL
,
NULL
,
NULL
,
NULL
,
&
max_sub_key_len
,
NULL
,
&
val_count
,
&
max_val_name_len
,
&
max_val_size
,
NULL
,
NULL
);
if
(
errCode
!=
ERROR_SUCCESS
)
goto
done
;
...
...
@@ -522,24 +536,24 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR highli
max_val_name_len
++
;
max_val_size
++
;
valName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
max_val_name_len
*
sizeof
(
T
CHAR
));
valName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
max_val_name_len
*
sizeof
(
W
CHAR
));
valBuf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
max_val_size
);
if
(
RegQueryValueEx
(
hKey
,
NULL
,
NULL
,
&
valType
,
valBuf
,
&
valSize
)
==
ERROR_FILE_NOT_FOUND
)
{
if
(
RegQueryValueEx
W
(
hKey
,
NULL
,
NULL
,
&
valType
,
valBuf
,
&
valSize
)
==
ERROR_FILE_NOT_FOUND
)
{
AddEntryToList
(
hwndLV
,
NULL
,
REG_SZ
,
NULL
,
0
,
!
highlightValue
);
}
for
(
index
=
0
;
index
<
val_count
;
index
++
)
{
BOOL
bSelected
=
(
valName
==
highlightValue
);
/* NOT a bug, we check for double NULL here */
BOOL
bSelected
=
(
valName
==
highlightValue
W
);
/* NOT a bug, we check for double NULL here */
valNameLen
=
max_val_name_len
;
valSize
=
max_val_size
;
valType
=
0
;
errCode
=
RegEnumValue
(
hKey
,
index
,
valName
,
&
valNameLen
,
NULL
,
&
valType
,
valBuf
,
&
valSize
);
errCode
=
RegEnumValue
W
(
hKey
,
index
,
valName
,
&
valNameLen
,
NULL
,
&
valType
,
valBuf
,
&
valSize
);
if
(
errCode
!=
ERROR_SUCCESS
)
goto
done
;
valBuf
[
valSize
]
=
0
;
if
(
valName
&&
highlightValue
&&
!
_tcscmp
(
valName
,
highlightValue
))
if
(
valName
&&
highlightValue
W
&&
lstrcmpW
(
valName
,
highlightValueW
))
bSelected
=
TRUE
;
AddEntryToList
(
hwndLV
,
valName
[
0
]
?
valName
:
NULL
,
valType
,
valBuf
,
valSize
,
bSelected
);
}
SendMessage
(
hwndLV
,
LVM_SORTITEMS
,
(
WPARAM
)
hwndLV
,
(
LPARAM
)
CompareFunc
);
SendMessage
W
(
hwndLV
,
LVM_SORTITEMS
,
(
WPARAM
)
hwndLV
,
(
LPARAM
)
CompareFunc
);
g_currentRootKey
=
hKeyRoot
;
if
(
keyPath
!=
g_currentPath
)
{
...
...
@@ -554,7 +568,9 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR highli
done:
HeapFree
(
GetProcessHeap
(),
0
,
valBuf
);
HeapFree
(
GetProcessHeap
(),
0
,
valName
);
SendMessage
(
hwndLV
,
WM_SETREDRAW
,
TRUE
,
0
);
HeapFree
(
GetProcessHeap
(),
0
,
keyPathW
);
HeapFree
(
GetProcessHeap
(),
0
,
highlightValueW
);
SendMessageW
(
hwndLV
,
WM_SETREDRAW
,
TRUE
,
0
);
if
(
hKey
)
RegCloseKey
(
hKey
);
return
result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment