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
7a6d6aab
Commit
7a6d6aab
authored
Jan 16, 2004
by
Dimitrie O. Paun
Committed by
Alexandre Julliard
Jan 16, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Streamline the editing interfaces a bit.
Open the registry with only the required permissions for the operation. Fix a few leaks.
parent
14263ab0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
43 deletions
+57
-43
edit.c
programs/regedit/edit.c
+45
-25
framewnd.c
programs/regedit/framewnd.c
+8
-14
main.h
programs/regedit/main.h
+4
-4
No files found.
programs/regedit/edit.c
View file @
7a6d6aab
...
...
@@ -155,18 +155,20 @@ done:
return
NULL
;
}
BOOL
CreateKey
(
H
KEY
hKey
)
BOOL
CreateKey
(
H
WND
hwnd
,
HKEY
hKeyRoot
,
LPCTSTR
keyPath
)
{
BOOL
result
=
FALSE
;
LONG
lRet
=
ERROR_SUCCESS
;
HKEY
retKey
;
TCHAR
keyName
[
32
];
TCHAR
newKey
[
COUNT_OF
(
keyName
)
-
4
];
int
keyNum
;
HKEY
hKey
;
/* If we have illegal parameter return with operation failure */
if
(
!
hKey
)
return
FALSE
;
lRet
=
RegOpenKeyEx
(
hKeyRoot
,
keyPath
,
0
,
KEY_CREATE_SUB_KEY
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
return
FALSE
;
if
(
!
LoadString
(
GetModuleHandle
(
0
),
IDS_NEWKEY
,
newKey
,
COUNT_OF
(
newKey
)))
return
FALSE
;
if
(
!
LoadString
(
GetModuleHandle
(
0
),
IDS_NEWKEY
,
newKey
,
COUNT_OF
(
newKey
)))
goto
done
;
/* try to find out a name for the newly create key (max 100 times) */
for
(
keyNum
=
1
;
keyNum
<
100
;
keyNum
++
)
{
...
...
@@ -175,22 +177,26 @@ BOOL CreateKey(HKEY hKey)
if
(
lRet
!=
ERROR_SUCCESS
)
break
;
RegCloseKey
(
retKey
);
}
if
(
lRet
==
ERROR_SUCCESS
)
return
FALSE
;
if
(
lRet
==
ERROR_SUCCESS
)
goto
done
;
lRet
=
RegCreateKey
(
hKey
,
keyName
,
&
retKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
return
FALSE
;
if
(
lRet
!=
ERROR_SUCCESS
)
goto
done
;
result
=
TRUE
;
done:
RegCloseKey
(
retKey
);
return
TRUE
;
return
result
;
}
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKey
,
LPCTSTR
valueName
)
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKey
Root
,
LPCTSTR
keyPath
,
LPCTSTR
valueName
)
{
BOOL
result
=
FALSE
;
DWORD
type
;
LONG
lRet
;
BOOL
result
=
FALSE
;
HKEY
hKey
;
if
(
!
hKey
||
!
valueName
)
return
FALSE
;
lRet
=
RegOpenKeyEx
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
return
FALSE
;
editValueName
=
valueName
;
if
(
!
(
stringValueData
=
read_value
(
hwnd
,
hKey
,
valueName
,
&
type
,
0
)))
goto
done
;
...
...
@@ -216,38 +222,48 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
done:
HeapFree
(
GetProcessHeap
(),
0
,
stringValueData
);
stringValueData
=
NULL
;
RegCloseKey
(
hKey
);
return
result
;
}
BOOL
DeleteValue
(
HWND
hwnd
,
HKEY
hKey
,
LPCTSTR
valueName
)
BOOL
DeleteValue
(
HWND
hwnd
,
HKEY
hKey
Root
,
LPCTSTR
keyPath
,
LPCTSTR
valueName
)
{
BOOL
result
=
FALSE
;
LONG
lRet
;
HKEY
hKey
;
if
(
!
hKey
||
!
valueName
)
return
FALSE
;
lRet
=
RegOpenKeyEx
(
hKeyRoot
,
keyPath
,
0
,
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
return
FALSE
;
if
(
messagebox
(
hwnd
,
MB_YESNO
|
MB_ICONEXCLAMATION
,
IDS_DELETE_BOX_TITLE
,
IDS_DELETE_BOX_TEXT
,
valueName
)
!=
IDYES
)
return
FALSE
;
goto
done
;
lRet
=
RegDeleteValue
(
hKey
,
valueName
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
error
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
}
return
lRet
==
ERROR_SUCCESS
;
if
(
lRet
!=
ERROR_SUCCESS
)
goto
done
;
result
=
TRUE
;
done:
RegCloseKey
(
hKey
);
return
result
;
}
BOOL
CreateValue
(
HWND
hwnd
,
HKEY
hKey
,
DWORD
valueType
)
BOOL
CreateValue
(
HWND
hwnd
,
HKEY
hKey
Root
,
LPCTSTR
keyPath
,
DWORD
valueType
)
{
LONG
lRet
=
ERROR_SUCCESS
;
TCHAR
valueName
[
32
];
TCHAR
newValue
[
COUNT_OF
(
valueName
)
-
4
];
DWORD
valueDword
=
0
;
BOOL
result
=
FALSE
;
int
valueNum
;
HKEY
hKey
;
/* If we have illegal parameter return with operation failure */
if
(
!
hKey
)
return
FALSE
;
lRet
=
RegOpenKeyEx
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
return
FALSE
;
if
(
!
LoadString
(
GetModuleHandle
(
0
),
IDS_NEWVALUE
,
newValue
,
COUNT_OF
(
newValue
)))
return
FALSE
;
if
(
!
LoadString
(
GetModuleHandle
(
0
),
IDS_NEWVALUE
,
newValue
,
COUNT_OF
(
newValue
)))
goto
done
;
/* try to find out a name for the newly create key (max 100 times) */
for
(
valueNum
=
1
;
valueNum
<
100
;
valueNum
++
)
{
...
...
@@ -255,15 +271,18 @@ BOOL CreateValue(HWND hwnd, HKEY hKey, DWORD valueType)
lRet
=
RegQueryValueEx
(
hKey
,
valueName
,
0
,
0
,
0
,
0
);
if
(
lRet
!=
ERROR_SUCCESS
)
break
;
}
if
(
lRet
==
ERROR_SUCCESS
)
return
FALSE
;
if
(
lRet
==
ERROR_SUCCESS
)
goto
done
;
lRet
=
RegSetValueEx
(
hKey
,
valueName
,
0
,
valueType
,
(
BYTE
*
)
&
valueDword
,
sizeof
(
DWORD
));
if
(
lRet
!=
ERROR_SUCCESS
)
return
FALSE
;
if
(
lRet
!=
ERROR_SUCCESS
)
goto
done
;
result
=
TRUE
;
return
TRUE
;
done:
RegCloseKey
(
hKey
);
return
result
;
}
BOOL
RenameValue
(
HWND
hwnd
,
HKEY
h
RootKey
,
LPCTSTR
keyPath
,
LPCTSTR
oldName
,
LPCTSTR
newName
)
BOOL
RenameValue
(
HWND
hwnd
,
HKEY
h
KeyRoot
,
LPCTSTR
keyPath
,
LPCTSTR
oldName
,
LPCTSTR
newName
)
{
LPTSTR
value
=
NULL
;
DWORD
type
;
...
...
@@ -271,8 +290,8 @@ BOOL RenameValue(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR oldName, LPC
BOOL
result
=
FALSE
;
HKEY
hKey
;
lRet
=
RegOpenKeyEx
(
h
RootKey
,
keyPath
,
0
,
KEY_ALL_ACCESS
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
goto
done
;
lRet
=
RegOpenKeyEx
(
h
KeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
return
FALSE
;
value
=
read_value
(
hwnd
,
hKey
,
oldName
,
&
type
,
&
len
);
if
(
!
value
)
goto
done
;
lRet
=
RegSetValueEx
(
hKey
,
newName
,
0
,
type
,
(
BYTE
*
)
value
,
len
);
...
...
@@ -286,5 +305,6 @@ BOOL RenameValue(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR oldName, LPC
done:
HeapFree
(
GetProcessHeap
(),
0
,
value
);
RegCloseKey
(
hKey
);
return
result
;
}
programs/regedit/framewnd.c
View file @
7a6d6aab
...
...
@@ -435,17 +435,12 @@ BOOL RefreshView(HWND hWnd)
*/
static
BOOL
_CmdWndProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
HKEY
hKeyRoot
=
0
,
hKey
=
0
;
HKEY
hKeyRoot
=
0
;
LPCTSTR
keyPath
;
LPCTSTR
valueName
;
BOOL
result
=
TRUE
;
LONG
lRet
;
DWORD
valueType
;
if
((
keyPath
=
GetItemPath
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
hKeyRoot
)))
{
lRet
=
RegOpenKeyEx
(
hKeyRoot
,
keyPath
,
0
,
KEY_ALL_ACCESS
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
hKey
=
0
;
}
keyPath
=
GetItemPath
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
hKeyRoot
);
valueName
=
GetValueName
(
g_pChildWnd
->
hListWnd
);
switch
(
LOWORD
(
wParam
))
{
...
...
@@ -463,18 +458,18 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
PrintRegistryHive
(
hWnd
,
_T
(
""
));
break
;
case
ID_EDIT_DELETE
:
if
(
DeleteValue
(
hWnd
,
hKey
,
valueName
))
if
(
DeleteValue
(
hWnd
,
hKey
Root
,
keyPath
,
valueName
))
RefreshListView
(
g_pChildWnd
->
hListWnd
,
hKeyRoot
,
keyPath
);
break
;
case
ID_EDIT_MODIFY
:
if
(
ModifyValue
(
hWnd
,
hKey
,
valueName
))
if
(
ModifyValue
(
hWnd
,
hKey
Root
,
keyPath
,
valueName
))
RefreshListView
(
g_pChildWnd
->
hListWnd
,
hKeyRoot
,
keyPath
);
break
;
case
ID_EDIT_COPYKEYNAME
:
CopyKeyName
(
hWnd
,
_T
(
""
));
break
;
case
ID_EDIT_NEW_KEY
:
CreateKey
(
h
Key
);
CreateKey
(
h
Wnd
,
hKeyRoot
,
keyPath
);
break
;
case
ID_EDIT_NEW_STRINGVALUE
:
valueType
=
REG_SZ
;
...
...
@@ -486,7 +481,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
valueType
=
REG_DWORD
;
/* fall through */
create_value:
if
(
CreateValue
(
hWnd
,
hKey
,
valueType
))
if
(
CreateValue
(
hWnd
,
hKey
Root
,
keyPath
,
valueType
))
RefreshListView
(
g_pChildWnd
->
hListWnd
,
hKeyRoot
,
keyPath
);
case
ID_EDIT_RENAME
:
StartValueRename
(
g_pChildWnd
->
hListWnd
,
hKeyRoot
,
keyPath
);
...
...
@@ -533,11 +528,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return
TRUE
;
}
default:
re
sult
=
FALSE
;
re
turn
FALSE
;
}
RegCloseKey
(
hKey
);
return
result
;
return
TRUE
;
}
/********************************************************************************
...
...
programs/regedit/main.h
View file @
7a6d6aab
...
...
@@ -98,10 +98,10 @@ extern BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);
extern
LPCTSTR
GetItemPath
(
HWND
hwndTV
,
HTREEITEM
hItem
,
HKEY
*
phRootKey
);
/* edit.c */
extern
BOOL
CreateKey
(
H
KEY
hKey
);
extern
BOOL
CreateValue
(
HWND
hwnd
,
HKEY
hKey
,
DWORD
valueType
);
extern
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKey
,
LPCTSTR
valueName
);
extern
BOOL
DeleteValue
(
HWND
hwnd
,
HKEY
hKey
,
LPCTSTR
valueName
);
extern
BOOL
CreateKey
(
H
WND
hwnd
,
HKEY
hKeyRoot
,
LPCTSTR
keyPath
);
extern
BOOL
CreateValue
(
HWND
hwnd
,
HKEY
hKey
Root
,
LPCTSTR
keyPath
,
DWORD
valueType
);
extern
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKey
Root
,
LPCTSTR
keyPath
,
LPCTSTR
valueName
);
extern
BOOL
DeleteValue
(
HWND
hwnd
,
HKEY
hKey
Root
,
LPCTSTR
keyPath
,
LPCTSTR
valueName
);
extern
BOOL
RenameValue
(
HWND
hwnd
,
HKEY
hRootKey
,
LPCTSTR
keyPath
,
LPCTSTR
oldName
,
LPCTSTR
newName
);
#endif
/* __MAIN_H__ */
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