Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
6168a7c6
Commit
6168a7c6
authored
Aug 10, 2008
by
Alexander Nicolaysen Sørnes
Committed by
Alexandre Julliard
Aug 20, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Convert clipboard handling to unicode.
parent
5cb8bccf
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
168 additions
and
18 deletions
+168
-18
childwnd.c
programs/regedit/childwnd.c
+78
-0
framewnd.c
programs/regedit/framewnd.c
+5
-5
main.c
programs/regedit/main.c
+11
-0
main.h
programs/regedit/main.h
+13
-0
regproc.c
programs/regedit/regproc.c
+2
-13
treeview.c
programs/regedit/treeview.c
+59
-0
No files found.
programs/regedit/childwnd.c
View file @
6168a7c6
...
...
@@ -49,6 +49,28 @@ LPCTSTR GetRootKeyName(HKEY hRootKey)
return
_T
(
"UNKNOWN HKEY, PLEASE REPORT"
);
}
LPCWSTR
GetRootKeyNameW
(
HKEY
hRootKey
)
{
if
(
hRootKey
==
HKEY_CLASSES_ROOT
)
return
reg_class_namesW
[
INDEX_HKEY_CLASSES_ROOT
];
if
(
hRootKey
==
HKEY_CURRENT_USER
)
return
reg_class_namesW
[
INDEX_HKEY_CURRENT_USER
];
if
(
hRootKey
==
HKEY_LOCAL_MACHINE
)
return
reg_class_namesW
[
INDEX_HKEY_LOCAL_MACHINE
];
if
(
hRootKey
==
HKEY_USERS
)
return
reg_class_namesW
[
INDEX_HKEY_USERS
];
if
(
hRootKey
==
HKEY_CURRENT_CONFIG
)
return
reg_class_namesW
[
INDEX_HKEY_CURRENT_CONFIG
];
if
(
hRootKey
==
HKEY_DYN_DATA
)
return
reg_class_namesW
[
INDEX_HKEY_DYN_DATA
];
else
{
static
const
WCHAR
unknown_key
[]
=
{
'U'
,
'N'
,
'K'
,
'N'
,
'O'
,
'W'
,
'N'
,
' '
,
'H'
,
'K'
,
'E'
,
'Y'
,
','
,
' '
,
'P'
,
'L'
,
'E'
,
'A'
,
'S'
,
'E'
,
' '
,
'R'
,
'E'
,
'P'
,
'O'
,
'R'
,
'T'
,
0
};
return
unknown_key
;
}
}
static
void
draw_splitbar
(
HWND
hWnd
,
int
x
)
{
RECT
rt
;
...
...
@@ -109,6 +131,31 @@ static LPTSTR CombinePaths(LPCTSTR pPaths[], int nPaths) {
return
combined
;
}
static
LPWSTR
CombinePathsW
(
LPCWSTR
pPaths
[],
int
nPaths
)
{
int
i
,
len
,
pos
;
LPWSTR
combined
;
for
(
i
=
0
,
len
=
0
;
i
<
nPaths
;
i
++
)
{
if
(
pPaths
[
i
]
&&
*
pPaths
[
i
])
{
len
+=
lstrlenW
(
pPaths
[
i
])
+
1
;
}
}
combined
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
*
combined
=
'\0'
;
for
(
i
=
0
,
pos
=
0
;
i
<
nPaths
;
i
++
)
{
if
(
pPaths
[
i
]
&&
*
pPaths
[
i
])
{
int
llen
=
lstrlenW
(
pPaths
[
i
]);
if
(
!*
combined
)
lstrcpyW
(
combined
,
pPaths
[
i
]);
else
{
combined
[
pos
++
]
=
(
TCHAR
)
'\\'
;
lstrcpyW
(
combined
+
pos
,
pPaths
[
i
]);
}
pos
+=
llen
;
}
}
return
combined
;
}
static
LPTSTR
GetPathRoot
(
HWND
hwndTV
,
HTREEITEM
hItem
,
BOOL
bFull
)
{
LPCTSTR
parts
[
2
]
=
{
_T
(
""
),
_T
(
""
)};
TCHAR
text
[
260
];
...
...
@@ -128,6 +175,25 @@ static LPTSTR GetPathRoot(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
return
CombinePaths
(
parts
,
2
);
}
static
LPWSTR
GetPathRootW
(
HWND
hwndTV
,
HTREEITEM
hItem
,
BOOL
bFull
)
{
LPCWSTR
parts
[
2
]
=
{
0
,
0
};
WCHAR
text
[
260
];
HKEY
hRootKey
=
NULL
;
if
(
!
hItem
)
hItem
=
TreeView_GetSelection
(
hwndTV
);
GetItemPathW
(
hwndTV
,
hItem
,
&
hRootKey
);
if
(
!
bFull
&&
!
hRootKey
)
return
NULL
;
if
(
hRootKey
)
parts
[
1
]
=
GetRootKeyNameW
(
hRootKey
);
if
(
bFull
)
{
DWORD
dwSize
=
sizeof
(
text
)
/
sizeof
(
TCHAR
);
GetComputerNameW
(
text
,
&
dwSize
);
parts
[
0
]
=
text
;
}
return
CombinePathsW
(
parts
,
2
);
}
LPTSTR
GetItemFullPath
(
HWND
hwndTV
,
HTREEITEM
hItem
,
BOOL
bFull
)
{
LPTSTR
parts
[
2
];
LPTSTR
ret
;
...
...
@@ -140,6 +206,18 @@ LPTSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
return
ret
;
}
LPWSTR
GetItemFullPathW
(
HWND
hwndTV
,
HTREEITEM
hItem
,
BOOL
bFull
)
{
LPWSTR
parts
[
2
];
LPWSTR
ret
;
HKEY
hRootKey
=
NULL
;
parts
[
0
]
=
GetPathRootW
(
hwndTV
,
hItem
,
bFull
);
parts
[
1
]
=
GetItemPathW
(
hwndTV
,
hItem
,
&
hRootKey
);
ret
=
CombinePathsW
((
LPCWSTR
*
)
parts
,
2
);
HeapFree
(
GetProcessHeap
(),
0
,
parts
[
0
]);
return
ret
;
}
static
LPTSTR
GetPathFullPath
(
HWND
hwndTV
,
LPTSTR
path
)
{
LPTSTR
parts
[
2
];
LPTSTR
ret
;
...
...
programs/regedit/framewnd.c
View file @
6168a7c6
...
...
@@ -440,7 +440,7 @@ static BOOL PrintRegistryHive(HWND hWnd, LPCWSTR path)
return
TRUE
;
}
static
BOOL
CopyKeyName
(
HWND
hWnd
,
LPC
T
STR
keyName
)
static
BOOL
CopyKeyName
(
HWND
hWnd
,
LPC
W
STR
keyName
)
{
BOOL
result
;
...
...
@@ -448,12 +448,12 @@ static BOOL CopyKeyName(HWND hWnd, LPCTSTR keyName)
if
(
result
)
{
result
=
EmptyClipboard
();
if
(
result
)
{
int
len
=
(
_tcslen
(
keyName
)
+
1
)
*
sizeof
(
T
CHAR
);
int
len
=
(
lstrlenW
(
keyName
)
+
1
)
*
sizeof
(
W
CHAR
);
HANDLE
hClipData
=
GlobalAlloc
(
GHND
,
len
);
LPVOID
pLoc
=
GlobalLock
(
hClipData
);
_tcscpy
(
pLoc
,
keyName
);
lstrcpyW
(
pLoc
,
keyName
);
GlobalUnlock
(
hClipData
);
hClipData
=
SetClipboardData
(
CF_TEXT
,
hClipData
);
hClipData
=
SetClipboardData
(
CF_
UNICODE
TEXT
,
hClipData
);
}
else
{
/* error emptying clipboard*/
...
...
@@ -753,7 +753,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
case
ID_EDIT_COPYKEYNAME
:
{
LP
TSTR
fullPath
=
GetItemFullPath
(
g_pChildWnd
->
hTreeWnd
,
NULL
,
FALSE
);
LP
WSTR
fullPath
=
GetItemFullPathW
(
g_pChildWnd
->
hTreeWnd
,
NULL
,
FALSE
);
if
(
fullPath
)
{
CopyKeyName
(
hWnd
,
fullPath
);
HeapFree
(
GetProcessHeap
(),
0
,
fullPath
);
...
...
programs/regedit/main.c
View file @
6168a7c6
...
...
@@ -34,6 +34,17 @@ WCHAR g_pszDefaultValueNameW[64];
BOOL
ProcessCmdLine
(
LPSTR
lpCmdLine
);
static
const
WCHAR
hkey_local_machine
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'L'
,
'O'
,
'C'
,
'A'
,
'L'
,
'_'
,
'M'
,
'A'
,
'C'
,
'H'
,
'I'
,
'N'
,
'E'
,
0
};
static
const
WCHAR
hkey_users
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'U'
,
'S'
,
'E'
,
'R'
,
'S'
,
0
};
static
const
WCHAR
hkey_classes_root
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'L'
,
'A'
,
'S'
,
'S'
,
'E'
,
'S'
,
'_'
,
'R'
,
'O'
,
'O'
,
'T'
,
0
};
static
const
WCHAR
hkey_current_config
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'U'
,
'R'
,
'R'
,
'E'
,
'N'
,
'T'
,
'_'
,
'C'
,
'O'
,
'N'
,
'F'
,
'I'
,
'G'
,
0
};
static
const
WCHAR
hkey_current_user
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'U'
,
'R'
,
'R'
,
'E'
,
'N'
,
'T'
,
'_'
,
'U'
,
'S'
,
'E'
,
'R'
,
0
};
static
const
WCHAR
hkey_dyn_data
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'D'
,
'Y'
,
'N'
,
'_'
,
'D'
,
'A'
,
'T'
,
'A'
,
0
};
const
WCHAR
*
reg_class_namesW
[]
=
{
hkey_local_machine
,
hkey_users
,
hkey_classes_root
,
hkey_current_config
,
hkey_current_user
,
hkey_dyn_data
};
/*******************************************************************************
* Global Variables:
...
...
programs/regedit/main.h
View file @
6168a7c6
...
...
@@ -93,12 +93,24 @@ extern const TCHAR szChildClass[];
extern
TCHAR
g_pszDefaultValueName
[];
extern
WCHAR
g_pszDefaultValueNameW
[];
/* Registry class names and their indexes */
extern
const
WCHAR
*
reg_class_namesW
[];
#define INDEX_HKEY_LOCAL_MACHINE 0
#define INDEX_HKEY_USERS 1
#define INDEX_HKEY_CLASSES_ROOT 2
#define INDEX_HKEY_CURRENT_CONFIG 3
#define INDEX_HKEY_CURRENT_USER 4
#define INDEX_HKEY_DYN_DATA 5
/* about.c */
extern
void
ShowAboutBox
(
HWND
hWnd
);
/* childwnd.c */
extern
LPCTSTR
GetRootKeyName
(
HKEY
hRootKey
);
extern
LPTSTR
GetItemFullPath
(
HWND
hwndTV
,
HTREEITEM
hItem
,
BOOL
bFull
);
extern
LPWSTR
GetItemFullPathW
(
HWND
hwndTV
,
HTREEITEM
hItem
,
BOOL
bFull
);
extern
LRESULT
CALLBACK
ChildWndProc
(
HWND
,
UINT
,
WPARAM
,
LPARAM
);
/* framewnd.c */
...
...
@@ -120,6 +132,7 @@ extern HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, UINT id);
extern
BOOL
RefreshTreeView
(
HWND
hWndTV
);
extern
BOOL
OnTreeExpanding
(
HWND
hWnd
,
NMTREEVIEW
*
pnmtv
);
extern
LPTSTR
GetItemPath
(
HWND
hwndTV
,
HTREEITEM
hItem
,
HKEY
*
phRootKey
);
extern
LPWSTR
GetItemPathW
(
HWND
hwndTV
,
HTREEITEM
hItem
,
HKEY
*
phRootKey
);
extern
BOOL
DeleteNode
(
HWND
hwndTV
,
HTREEITEM
hItem
);
extern
HTREEITEM
InsertNode
(
HWND
hwndTV
,
HTREEITEM
hItem
,
LPTSTR
name
);
extern
HWND
StartKeyRename
(
HWND
hwndTV
);
...
...
programs/regedit/regproc.c
View file @
6168a7c6
...
...
@@ -40,21 +40,10 @@ static const CHAR *reg_class_names[] = {
"HKEY_CURRENT_CONFIG"
,
"HKEY_CURRENT_USER"
,
"HKEY_DYN_DATA"
};
static
const
WCHAR
hkey_local_machine
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'L'
,
'O'
,
'C'
,
'A'
,
'L'
,
'_'
,
'M'
,
'A'
,
'C'
,
'H'
,
'I'
,
'N'
,
'E'
,
0
};
static
const
WCHAR
hkey_users
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'U'
,
'S'
,
'E'
,
'R'
,
'S'
,
0
};
static
const
WCHAR
hkey_classes_root
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'L'
,
'A'
,
'S'
,
'S'
,
'E'
,
'S'
,
'_'
,
'R'
,
'O'
,
'O'
,
'T'
,
0
};
static
const
WCHAR
hkey_current_config
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'U'
,
'R'
,
'R'
,
'E'
,
'N'
,
'T'
,
'_'
,
'C'
,
'O'
,
'N'
,
'F'
,
'I'
,
'G'
,
0
};
static
const
WCHAR
hkey_current_user
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'U'
,
'R'
,
'R'
,
'E'
,
'N'
,
'T'
,
'_'
,
'U'
,
'S'
,
'E'
,
'R'
,
0
};
static
const
WCHAR
hkey_dyn_data
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'D'
,
'Y'
,
'N'
,
'_'
,
'D'
,
'A'
,
'T'
,
'A'
,
0
};
static
const
WCHAR
*
reg_class_namesW
[]
=
{
hkey_local_machine
,
hkey_users
,
hkey_classes_root
,
hkey_current_config
,
hkey_current_user
,
hkey_dyn_data
};
#define REG_CLASS_NUMBER (sizeof(reg_class_names) / sizeof(reg_class_names[0]))
extern
const
WCHAR
*
reg_class_namesW
[];
static
HKEY
reg_class_keys
[
REG_CLASS_NUMBER
]
=
{
HKEY_LOCAL_MACHINE
,
HKEY_USERS
,
HKEY_CLASSES_ROOT
,
HKEY_CURRENT_CONFIG
,
HKEY_CURRENT_USER
,
HKEY_DYN_DATA
...
...
programs/regedit/treeview.c
View file @
6168a7c6
...
...
@@ -91,6 +91,48 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe
return
TRUE
;
}
static
BOOL
get_item_pathW
(
HWND
hwndTV
,
HTREEITEM
hItem
,
HKEY
*
phKey
,
LPWSTR
*
pKeyPath
,
int
*
pPathLen
,
int
*
pMaxChars
)
{
TVITEMW
item
;
int
maxChars
,
chars
;
LPWSTR
newStr
;
item
.
mask
=
TVIF_PARAM
;
item
.
hItem
=
hItem
;
if
(
!
TreeView_GetItem
(
hwndTV
,
&
item
))
return
FALSE
;
if
(
item
.
lParam
)
{
/* found root key with valid key value */
*
phKey
=
(
HKEY
)
item
.
lParam
;
return
TRUE
;
}
if
(
!
get_item_pathW
(
hwndTV
,
TreeView_GetParent
(
hwndTV
,
hItem
),
phKey
,
pKeyPath
,
pPathLen
,
pMaxChars
))
return
FALSE
;
if
(
*
pPathLen
)
{
(
*
pKeyPath
)[
*
pPathLen
]
=
'\\'
;
++
(
*
pPathLen
);
}
do
{
item
.
mask
=
TVIF_TEXT
;
item
.
hItem
=
hItem
;
item
.
pszText
=
*
pKeyPath
+
*
pPathLen
;
item
.
cchTextMax
=
maxChars
=
*
pMaxChars
-
*
pPathLen
;
if
(
!
TreeView_GetItemW
(
hwndTV
,
&
item
))
return
FALSE
;
chars
=
lstrlenW
(
item
.
pszText
);
if
(
chars
<
maxChars
-
1
)
{
*
pPathLen
+=
chars
;
break
;
}
newStr
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
*
pKeyPath
,
*
pMaxChars
*
2
);
if
(
!
newStr
)
return
FALSE
;
*
pKeyPath
=
newStr
;
*
pMaxChars
*=
2
;
}
while
(
TRUE
);
return
TRUE
;
}
LPTSTR
GetItemPath
(
HWND
hwndTV
,
HTREEITEM
hItem
,
HKEY
*
phRootKey
)
{
int
pathLen
=
0
,
maxLen
;
...
...
@@ -107,6 +149,23 @@ LPTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
return
pathBuffer
;
}
LPWSTR
GetItemPathW
(
HWND
hwndTV
,
HTREEITEM
hItem
,
HKEY
*
phRootKey
)
{
int
pathLen
=
0
,
maxLen
;
WCHAR
*
pathBuffer
;
pathBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
1024
*
sizeof
(
WCHAR
));
if
(
!
pathBuffer
)
return
NULL
;
*
pathBuffer
=
0
;
maxLen
=
HeapSize
(
GetProcessHeap
(),
0
,
pathBuffer
);
if
(
maxLen
==
(
SIZE_T
)
-
1
)
return
NULL
;
maxLen
=
maxLen
/
sizeof
(
WCHAR
);
if
(
!
hItem
)
hItem
=
TreeView_GetSelection
(
hwndTV
);
if
(
!
hItem
)
return
NULL
;
if
(
!
get_item_pathW
(
hwndTV
,
hItem
,
phRootKey
,
&
pathBuffer
,
&
pathLen
,
&
maxLen
))
return
NULL
;
return
pathBuffer
;
}
static
LPTSTR
get_path_component
(
LPCTSTR
*
lplpKeyName
)
{
LPCTSTR
lpPos
=
*
lplpKeyName
;
LPTSTR
lpResult
=
NULL
;
...
...
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