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
1e56f949
Commit
1e56f949
authored
Aug 29, 2008
by
Alexander Nicolaysen Sørnes
Committed by
Alexandre Julliard
Sep 02, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Convert value editing to unicode.
parent
377f14c7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
40 deletions
+79
-40
edit.c
programs/regedit/edit.c
+73
-30
framewnd.c
programs/regedit/framewnd.c
+5
-9
main.h
programs/regedit/main.h
+1
-1
No files found.
programs/regedit/edit.c
View file @
1e56f949
...
...
@@ -34,14 +34,14 @@
#include "regproc.h"
#include "resource.h"
static
const
T
CHAR
*
editValueName
;
static
T
CHAR
*
stringValueData
;
static
const
W
CHAR
*
editValueName
;
static
W
CHAR
*
stringValueData
;
static
BOOL
isDecimal
;
struct
edit_params
{
HKEY
hKey
;
LPC
T
STR
lpszValueName
;
LPC
W
STR
lpszValueName
;
void
*
pData
;
LONG
cbData
;
};
...
...
@@ -114,14 +114,14 @@ static BOOL change_dword_base(HWND hwndDlg, BOOL toHex)
static
INT_PTR
CALLBACK
modify_dlgproc
(
HWND
hwndDlg
,
UINT
uMsg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
T
CHAR
*
valueData
;
W
CHAR
*
valueData
;
HWND
hwndValue
;
int
len
;
switch
(
uMsg
)
{
case
WM_INITDIALOG
:
SetDlgItemText
(
hwndDlg
,
IDC_VALUE_NAME
,
editValueName
);
SetDlgItemText
(
hwndDlg
,
IDC_VALUE_DATA
,
stringValueData
);
SetDlgItemText
W
(
hwndDlg
,
IDC_VALUE_NAME
,
editValueName
);
SetDlgItemText
W
(
hwndDlg
,
IDC_VALUE_DATA
,
stringValueData
);
CheckRadioButton
(
hwndDlg
,
IDC_DWORD_HEX
,
IDC_DWORD_DEC
,
isDecimal
?
IDC_DWORD_DEC
:
IDC_DWORD_HEX
);
return
TRUE
;
case
WM_COMMAND
:
...
...
@@ -134,10 +134,10 @@ static INT_PTR CALLBACK modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
break
;
case
IDOK
:
if
((
hwndValue
=
GetDlgItem
(
hwndDlg
,
IDC_VALUE_DATA
)))
{
len
=
GetWindowTextLength
(
hwndValue
);
if
((
valueData
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
stringValueData
,
(
len
+
1
)
*
sizeof
(
T
CHAR
))))
{
len
=
GetWindowTextLength
W
(
hwndValue
);
if
((
valueData
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
stringValueData
,
(
len
+
1
)
*
sizeof
(
W
CHAR
))))
{
stringValueData
=
valueData
;
if
(
!
GetWindowText
(
hwndValue
,
stringValueData
,
len
+
1
))
if
(
!
GetWindowText
W
(
hwndValue
,
stringValueData
,
len
+
1
))
*
stringValueData
=
0
;
}
}
...
...
@@ -162,9 +162,9 @@ static INT_PTR CALLBACK bin_modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPara
params
=
(
struct
edit_params
*
)
lParam
;
SetWindowLongPtr
(
hwndDlg
,
DWLP_USER
,
(
ULONG_PTR
)
params
);
if
(
params
->
lpszValueName
)
SetDlgItemText
(
hwndDlg
,
IDC_VALUE_NAME
,
params
->
lpszValueName
);
SetDlgItemText
W
(
hwndDlg
,
IDC_VALUE_NAME
,
params
->
lpszValueName
);
else
SetDlgItemText
(
hwndDlg
,
IDC_VALUE_NAME
,
g_pszDefaultValueName
);
SetDlgItemText
W
(
hwndDlg
,
IDC_VALUE_NAME
,
g_pszDefaultValueNameW
);
SendDlgItemMessage
(
hwndDlg
,
IDC_VALUE_DATA
,
HEM_SETDATA
,
(
WPARAM
)
params
->
cbData
,
(
LPARAM
)
params
->
pData
);
return
TRUE
;
case
WM_COMMAND
:
...
...
@@ -176,8 +176,8 @@ static INT_PTR CALLBACK bin_modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPara
if
(
pData
)
{
SendDlgItemMessage
(
hwndDlg
,
IDC_VALUE_DATA
,
HEM_GETDATA
,
(
WPARAM
)
cbData
,
(
LPARAM
)
pData
);
lRet
=
RegSetValueEx
(
params
->
hKey
,
params
->
lpszValueName
,
0
,
REG_BINARY
,
pData
,
cbData
);
SendDlgItemMessage
W
(
hwndDlg
,
IDC_VALUE_DATA
,
HEM_GETDATA
,
(
WPARAM
)
cbData
,
(
LPARAM
)
pData
);
lRet
=
RegSetValueEx
W
(
params
->
hKey
,
params
->
lpszValueName
,
0
,
REG_BINARY
,
pData
,
cbData
);
}
else
lRet
=
ERROR_OUTOFMEMORY
;
...
...
@@ -242,6 +242,45 @@ done:
return
NULL
;
}
static
LPWSTR
read_valueW
(
HWND
hwnd
,
HKEY
hKey
,
LPCWSTR
valueName
,
DWORD
*
lpType
,
LONG
*
len
)
{
DWORD
valueDataLen
;
LPWSTR
buffer
=
NULL
;
LONG
lRet
;
WCHAR
empty
=
0
;
lRet
=
RegQueryValueExW
(
hKey
,
valueName
?
valueName
:
&
empty
,
0
,
lpType
,
0
,
&
valueDataLen
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
==
ERROR_FILE_NOT_FOUND
&&
!
valueName
)
{
/* no default value here, make it up */
if
(
len
)
*
len
=
1
;
if
(
lpType
)
*
lpType
=
REG_SZ
;
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
WCHAR
));
*
buffer
=
'\0'
;
return
buffer
;
}
error
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
goto
done
;
}
if
(
*
lpType
==
REG_DWORD
)
valueDataLen
=
sizeof
(
DWORD
);
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
valueDataLen
+
sizeof
(
WCHAR
))))
{
error
(
hwnd
,
IDS_TOO_BIG_VALUE
,
valueDataLen
);
goto
done
;
}
lRet
=
RegQueryValueExW
(
hKey
,
valueName
,
0
,
0
,
(
LPBYTE
)
buffer
,
&
valueDataLen
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
error
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
goto
done
;
}
if
((
valueDataLen
%
sizeof
(
WCHAR
))
==
0
)
buffer
[
valueDataLen
/
sizeof
(
WCHAR
)]
=
0
;
if
(
len
)
*
len
=
valueDataLen
;
return
buffer
;
done:
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
NULL
;
}
BOOL
CreateKey
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
LPWSTR
keyName
)
{
BOOL
result
=
FALSE
;
...
...
@@ -281,7 +320,7 @@ done:
return
result
;
}
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPC
TSTR
keyPath
,
LPCT
STR
valueName
)
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPC
WSTR
keyPath
,
LPCW
STR
valueName
)
{
BOOL
result
=
FALSE
;
DWORD
type
;
...
...
@@ -289,30 +328,34 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName)
HKEY
hKey
;
LONG
len
;
lRet
=
RegOpenKeyEx
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
lRet
=
RegOpenKeyEx
W
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
error_code_messagebox
(
hwnd
,
lRet
);
return
FALSE
;
}
editValueName
=
valueName
?
valueName
:
g_pszDefaultValueName
;
if
(
!
(
stringValueData
=
read_value
(
hwnd
,
hKey
,
valueName
,
&
type
,
&
len
)))
goto
done
;
editValueName
=
valueName
?
valueName
:
g_pszDefaultValueName
W
;
if
(
!
(
stringValueData
=
read_value
W
(
hwnd
,
hKey
,
valueName
,
&
type
,
&
len
)))
goto
done
;
if
(
(
type
==
REG_SZ
)
||
(
type
==
REG_EXPAND_SZ
)
)
{
if
(
DialogBox
(
0
,
MAKEINTRESOURCE
(
IDD_EDIT_STRING
),
hwnd
,
modify_dlgproc
)
==
IDOK
)
{
lRet
=
RegSetValueEx
(
hKey
,
valueName
,
0
,
type
,
(
LPBYTE
)
stringValueData
,
lstrlen
(
stringValueData
)
+
1
);
if
(
DialogBox
W
(
0
,
MAKEINTRESOURCEW
(
IDD_EDIT_STRING
),
hwnd
,
modify_dlgproc
)
==
IDOK
)
{
lRet
=
RegSetValueEx
W
(
hKey
,
valueName
,
0
,
type
,
(
LPBYTE
)
stringValueData
,
(
lstrlenW
(
stringValueData
)
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
lRet
==
ERROR_SUCCESS
)
result
=
TRUE
;
else
error_code_messagebox
(
hwnd
,
lRet
);
}
}
else
if
(
type
==
REG_DWORD
)
{
wsprintf
(
stringValueData
,
isDecimal
?
"%u"
:
"%x"
,
*
((
DWORD
*
)
stringValueData
));
if
(
DialogBox
(
0
,
MAKEINTRESOURCE
(
IDD_EDIT_DWORD
),
hwnd
,
modify_dlgproc
)
==
IDOK
)
{
const
WCHAR
u
[]
=
{
'%'
,
'u'
,
0
};
const
WCHAR
x
[]
=
{
'%'
,
'x'
,
0
};
wsprintfW
(
stringValueData
,
isDecimal
?
u
:
x
,
*
((
DWORD
*
)
stringValueData
));
if
(
DialogBoxW
(
0
,
MAKEINTRESOURCEW
(
IDD_EDIT_DWORD
),
hwnd
,
modify_dlgproc
)
==
IDOK
)
{
DWORD
val
;
if
(
_stscanf
(
stringValueData
,
isDecimal
?
"%u"
:
"%x"
,
&
val
))
{
lRet
=
RegSetValueEx
(
hKey
,
valueName
,
0
,
type
,
(
BYTE
*
)
&
val
,
sizeof
(
val
));
CHAR
*
valueA
=
GetMultiByteString
(
stringValueData
);
if
(
_stscanf
(
valueA
,
isDecimal
?
"%u"
:
"%x"
,
&
val
))
{
lRet
=
RegSetValueExW
(
hKey
,
valueName
,
0
,
type
,
(
BYTE
*
)
&
val
,
sizeof
(
val
));
if
(
lRet
==
ERROR_SUCCESS
)
result
=
TRUE
;
else
error_code_messagebox
(
hwnd
,
lRet
);
}
HeapFree
(
GetProcessHeap
(),
0
,
valueA
);
}
}
else
if
(
type
==
REG_BINARY
)
{
struct
edit_params
params
;
...
...
@@ -323,14 +366,14 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName)
result
=
DialogBoxParam
(
NULL
,
MAKEINTRESOURCE
(
IDD_EDIT_BINARY
),
hwnd
,
bin_modify_dlgproc
,
(
LPARAM
)
&
params
);
}
else
if
(
type
==
REG_MULTI_SZ
)
{
TCHAR
char1
=
(
TCHAR
)
'\r'
,
char2
=
(
TCHAR
)
'\n'
;
T
CHAR
*
tmpValueData
=
NULL
;
WCHAR
char1
=
'\r'
,
char2
=
'\n'
;
W
CHAR
*
tmpValueData
=
NULL
;
INT
i
,
j
,
count
;
for
(
i
=
0
,
count
=
0
;
i
<
len
-
1
;
i
++
)
if
(
!
stringValueData
[
i
]
&&
stringValueData
[
i
+
1
]
)
count
++
;
tmpValueData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
count
)
*
sizeof
(
T
CHAR
));
tmpValueData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
count
)
*
sizeof
(
W
CHAR
));
if
(
!
tmpValueData
)
goto
done
;
for
(
i
=
0
,
j
=
0
;
i
<
len
-
1
;
i
++
)
...
...
@@ -348,10 +391,10 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName)
stringValueData
=
tmpValueData
;
tmpValueData
=
NULL
;
if
(
DialogBox
(
0
,
MAKEINTRESOURCE
(
IDD_EDIT_MULTI_STRING
),
hwnd
,
modify_dlgproc
)
==
IDOK
)
if
(
DialogBox
W
(
0
,
MAKEINTRESOURCEW
(
IDD_EDIT_MULTI_STRING
),
hwnd
,
modify_dlgproc
)
==
IDOK
)
{
len
=
lstrlen
(
stringValueData
);
tmpValueData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
2
)
*
sizeof
(
T
CHAR
));
len
=
lstrlen
W
(
stringValueData
);
tmpValueData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
2
)
*
sizeof
(
W
CHAR
));
if
(
!
tmpValueData
)
goto
done
;
for
(
i
=
0
,
j
=
0
;
i
<
len
-
1
;
i
++
)
...
...
@@ -371,7 +414,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName)
HeapFree
(
GetProcessHeap
(),
0
,
stringValueData
);
stringValueData
=
tmpValueData
;
lRet
=
RegSetValueEx
(
hKey
,
valueName
,
0
,
type
,
(
LPBYTE
)
stringValueData
,
j
*
sizeof
(
TCHAR
));
lRet
=
RegSetValueEx
W
(
hKey
,
valueName
,
0
,
type
,
(
LPBYTE
)
stringValueData
,
j
*
sizeof
(
TCHAR
));
if
(
lRet
==
ERROR_SUCCESS
)
result
=
TRUE
;
else
error_code_messagebox
(
hwnd
,
lRet
);
}
...
...
programs/regedit/framewnd.c
View file @
1e56f949
...
...
@@ -715,15 +715,11 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break
;
case
ID_EDIT_MODIFY
:
{
LPCWSTR
valueNameW
=
GetValueName
(
g_pChildWnd
->
hListWnd
);
CHAR
*
valueNameA
=
GetMultiByteString
(
valueNameW
);
WCHAR
*
keyPathW
=
GetItemPathW
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
hKeyRoot
);
CHAR
*
keyPathA
=
GetMultiByteString
(
keyPathW
);
if
(
ModifyValue
(
hWnd
,
hKeyRoot
,
keyPathA
,
valueNameA
))
RefreshListView
(
g_pChildWnd
->
hListWnd
,
hKeyRoot
,
keyPathW
,
valueNameW
);
HeapFree
(
GetProcessHeap
(),
0
,
valueNameA
);
HeapFree
(
GetProcessHeap
(),
0
,
keyPathW
);
HeapFree
(
GetProcessHeap
(),
0
,
keyPathA
);
LPCWSTR
valueName
=
GetValueName
(
g_pChildWnd
->
hListWnd
);
WCHAR
*
keyPath
=
GetItemPathW
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
hKeyRoot
);
if
(
ModifyValue
(
hWnd
,
hKeyRoot
,
keyPath
,
valueName
))
RefreshListView
(
g_pChildWnd
->
hListWnd
,
hKeyRoot
,
keyPath
,
valueName
);
HeapFree
(
GetProcessHeap
(),
0
,
keyPath
);
break
;
}
case
ID_EDIT_FIND
:
...
...
programs/regedit/main.h
View file @
1e56f949
...
...
@@ -142,7 +142,7 @@ extern HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mod
/* edit.c */
extern
BOOL
CreateKey
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
LPWSTR
newKeyName
);
extern
BOOL
CreateValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
DWORD
valueType
,
LPWSTR
valueName
);
extern
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPC
TSTR
keyPath
,
LPCT
STR
valueName
);
extern
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPC
WSTR
keyPath
,
LPCW
STR
valueName
);
extern
BOOL
DeleteKey
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
);
extern
BOOL
DeleteValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
LPCWSTR
valueName
,
BOOL
showMessageBox
);
extern
BOOL
RenameValue
(
HWND
hwnd
,
HKEY
hRootKey
,
LPCTSTR
keyPath
,
LPCTSTR
oldName
,
LPCTSTR
newName
);
...
...
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