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
16614538
Commit
16614538
authored
Dec 12, 2003
by
Dimitrie O. Paun
Committed by
Alexandre Julliard
Dec 12, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove most string size limitations.
Better error handling. Less listview flicker. A bunch of style fixes and improvements.
parent
bd13ab8d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
261 additions
and
253 deletions
+261
-253
about.c
programs/regedit/about.c
+2
-6
childwnd.c
programs/regedit/childwnd.c
+30
-34
edit.c
programs/regedit/edit.c
+2
-2
framewnd.c
programs/regedit/framewnd.c
+19
-39
listview.c
programs/regedit/listview.c
+96
-78
main.c
programs/regedit/main.c
+1
-0
main.h
programs/regedit/main.h
+7
-6
treeview.c
programs/regedit/treeview.c
+104
-88
No files found.
programs/regedit/about.c
View file @
16614538
...
@@ -28,18 +28,14 @@
...
@@ -28,18 +28,14 @@
#include "main.h"
#include "main.h"
extern
HINSTANCE
hInst
;
static
INT_PTR
CALLBACK
AboutDialogWndProc
(
HWND
hDlg
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
static
INT_PTR
CALLBACK
AboutDialogWndProc
(
HWND
hDlg
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
{
HWND
hLicenseEditWnd
;
TCHAR
strLicense
[
0x1000
];
TCHAR
strLicense
[
0x1000
];
switch
(
message
)
{
switch
(
message
)
{
case
WM_INITDIALOG
:
case
WM_INITDIALOG
:
hLicenseEditWnd
=
GetDlgItem
(
hDlg
,
IDC_LICENSE_EDIT
);
LoadString
(
hInst
,
IDS_LICENSE
,
strLicense
,
COUNT_OF
(
strLicense
));
LoadString
(
hInst
,
IDS_LICENSE
,
strLicense
,
0x1000
);
SetDlgItemText
(
hDlg
,
IDC_LICENSE_EDIT
,
strLicense
);
SetWindowText
(
hLicenseEditWnd
,
strLicense
);
return
TRUE
;
return
TRUE
;
case
WM_COMMAND
:
case
WM_COMMAND
:
if
((
LOWORD
(
wParam
)
==
IDOK
)
||
(
LOWORD
(
wParam
)
==
IDCANCEL
))
{
if
((
LOWORD
(
wParam
)
==
IDOK
)
||
(
LOWORD
(
wParam
)
==
IDCANCEL
))
{
...
...
programs/regedit/childwnd.c
View file @
16614538
...
@@ -20,38 +20,26 @@
...
@@ -20,38 +20,26 @@
#define WIN32_LEAN_AND_MEAN
/* Exclude rarely-used stuff from Windows headers */
#define WIN32_LEAN_AND_MEAN
/* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <windows.h>
#include <tchar.h>
#include <commctrl.h>
#include <commctrl.h>
#include <tchar.h>
#include <stdio.h>
#include "main.h"
#include "main.h"
ChildWnd
*
pChildWnd
;
ChildWnd
*
g_
pChildWnd
;
/*******************************************************************************
/*******************************************************************************
* Local module support methods
* Local module support methods
*/
*/
/*FIXME: why do we need this, we should remove it, we have already FindRegRoot */
static
LPCTSTR
get_root_key_name
(
HKEY
hRootKey
)
static
void
MakeFullRegPath
(
HWND
hwndTV
,
HTREEITEM
hItem
,
LPTSTR
keyPath
,
int
*
pPathLen
,
int
max
)
{
{
TVITEM
item
;
if
(
hRootKey
==
HKEY_CLASSES_ROOT
)
return
_T
(
"HKEY_CLASSES_ROOT"
);
item
.
mask
=
TVIF_PARAM
;
if
(
hRootKey
==
HKEY_CURRENT_USER
)
return
_T
(
"HKEY_CURRENT_USER"
);
item
.
hItem
=
hItem
;
if
(
hRootKey
==
HKEY_LOCAL_MACHINE
)
return
_T
(
"HKEY_LOCAL_MACHINE"
);
if
(
TreeView_GetItem
(
hwndTV
,
&
item
))
{
if
(
hRootKey
==
HKEY_USERS
)
return
_T
(
"HKEY_USERS"
);
if
(
item
.
hItem
!=
TreeView_GetRoot
(
hwndTV
))
{
if
(
hRootKey
==
HKEY_CURRENT_CONFIG
)
return
_T
(
"HKEY_CURRENT_CONFIG"
);
/* recurse */
return
_T
(
"UKNOWN HKEY, PLEASE REPORT"
);
MakeFullRegPath
(
hwndTV
,
TreeView_GetParent
(
hwndTV
,
hItem
),
keyPath
,
pPathLen
,
max
);
keyPath
[
*
pPathLen
]
=
_T
(
'\\'
);
++
(
*
pPathLen
);
}
item
.
mask
=
TVIF_TEXT
;
item
.
hItem
=
hItem
;
item
.
pszText
=
&
keyPath
[
*
pPathLen
];
item
.
cchTextMax
=
max
-
*
pPathLen
;
if
(
TreeView_GetItem
(
hwndTV
,
&
item
))
{
*
pPathLen
+=
_tcslen
(
item
.
pszText
);
}
}
}
}
static
void
draw_splitbar
(
HWND
hWnd
,
int
x
)
static
void
draw_splitbar
(
HWND
hWnd
,
int
x
)
...
@@ -127,13 +115,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
...
@@ -127,13 +115,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT
CALLBACK
ChildWndProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
LRESULT
CALLBACK
ChildWndProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
{
static
int
last_split
;
static
int
last_split
;
/* ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA); */
ChildWnd
*
pChildWnd
=
g_pChildWnd
;
switch
(
message
)
{
switch
(
message
)
{
case
WM_CREATE
:
case
WM_CREATE
:
pChildWnd
=
(
ChildWnd
*
)((
LPCREATESTRUCT
)
lParam
)
->
lpCreateParams
;
g_pChildWnd
=
pChildWnd
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
ChildWnd
))
;
if
(
!
pChildWnd
)
return
0
;
if
(
!
pChildWnd
)
return
0
;
_tcsncpy
(
pChildWnd
->
szPath
,
_T
(
"My Computer"
),
MAX_PATH
);
pChildWnd
->
nSplitPos
=
250
;
pChildWnd
->
nSplitPos
=
250
;
pChildWnd
->
hWnd
=
hWnd
;
pChildWnd
->
hTreeWnd
=
CreateTreeView
(
hWnd
,
pChildWnd
->
szPath
,
TREE_WINDOW
);
pChildWnd
->
hTreeWnd
=
CreateTreeView
(
hWnd
,
pChildWnd
->
szPath
,
TREE_WINDOW
);
pChildWnd
->
hListWnd
=
CreateListView
(
hWnd
,
LIST_WINDOW
/*, pChildWnd->szPath*/
);
pChildWnd
->
hListWnd
=
CreateListView
(
hWnd
,
LIST_WINDOW
/*, pChildWnd->szPath*/
);
break
;
break
;
...
@@ -157,6 +147,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
...
@@ -157,6 +147,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
}
}
goto
def
;
goto
def
;
case
WM_DESTROY
:
case
WM_DESTROY
:
HeapFree
(
GetProcessHeap
(),
0
,
pChildWnd
);
pChildWnd
=
NULL
;
PostQuitMessage
(
0
);
PostQuitMessage
(
0
);
break
;
break
;
case
WM_LBUTTONDOWN
:
{
case
WM_LBUTTONDOWN
:
{
...
@@ -234,17 +226,21 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
...
@@ -234,17 +226,21 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
case
TVN_ITEMEXPANDING
:
case
TVN_ITEMEXPANDING
:
return
!
OnTreeExpanding
(
pChildWnd
->
hTreeWnd
,
(
NMTREEVIEW
*
)
lParam
);
return
!
OnTreeExpanding
(
pChildWnd
->
hTreeWnd
,
(
NMTREEVIEW
*
)
lParam
);
case
TVN_SELCHANGED
:
{
case
TVN_SELCHANGED
:
{
HKEY
hKey
;
LPCTSTR
keyPath
,
rootName
;
TCHAR
keyPath
[
1000
];
LPTSTR
fullPath
;
int
keyPathLen
=
0
;
HKEY
hRootKey
;
keyPath
[
0
]
=
_T
(
'\0'
);
hKey
=
FindRegRoot
(
pChildWnd
->
hTreeWnd
,
((
NMTREEVIEW
*
)
lParam
)
->
itemNew
.
hItem
,
keyPath
,
&
keyPathLen
,
sizeof
(
keyPath
)
/
sizeof
(
TCHAR
));
RefreshListView
(
pChildWnd
->
hListWnd
,
hKey
,
keyPath
);
keyPathLen
=
0
;
keyPath
=
GetItemPath
(
pChildWnd
->
hTreeWnd
,
((
NMTREEVIEW
*
)
lParam
)
->
itemNew
.
hItem
,
&
hRootKey
);
keyPath
[
0
]
=
_T
(
'\0'
);
if
(
keyPath
)
{
MakeFullRegPath
(
pChildWnd
->
hTreeWnd
,
((
NMTREEVIEW
*
)
lParam
)
->
itemNew
.
hItem
,
keyPath
,
&
keyPathLen
,
sizeof
(
keyPath
)
/
sizeof
(
TCHAR
));
RefreshListView
(
pChildWnd
->
hListWnd
,
hRootKey
,
keyPath
);
SendMessage
(
hStatusBar
,
SB_SETTEXT
,
0
,
(
LPARAM
)
keyPath
);
rootName
=
get_root_key_name
(
hRootKey
);
fullPath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlen
(
rootName
)
+
1
+
lstrlen
(
keyPath
)
+
1
)
*
sizeof
(
TCHAR
));
if
(
fullPath
)
{
_stprintf
(
fullPath
,
"%s
\\
%s"
,
rootName
,
keyPath
);
SendMessage
(
hStatusBar
,
SB_SETTEXT
,
0
,
(
LPARAM
)
fullPath
);
HeapFree
(
GetProcessHeap
(),
0
,
fullPath
);
}
}
}
}
break
;
break
;
default:
default:
...
...
programs/regedit/edit.c
View file @
16614538
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include "regproc.h"
#include "regproc.h"
#include "resource.h"
#include "resource.h"
static
TCHAR
*
editValueName
;
static
const
TCHAR
*
editValueName
;
static
TCHAR
*
stringValueData
;
static
TCHAR
*
stringValueData
;
void
error
(
HWND
hwnd
,
INT
resId
,
...)
void
error
(
HWND
hwnd
,
INT
resId
,
...)
...
@@ -91,7 +91,7 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
...
@@ -91,7 +91,7 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
return
FALSE
;
return
FALSE
;
}
}
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKey
,
LPTSTR
valueName
)
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKey
,
LP
C
TSTR
valueName
)
{
{
DWORD
valueDataLen
;
DWORD
valueDataLen
;
DWORD
type
;
DWORD
type
;
...
...
programs/regedit/framewnd.c
View file @
16614538
...
@@ -38,8 +38,6 @@
...
@@ -38,8 +38,6 @@
static
BOOL
bInMenuLoop
=
FALSE
;
/* Tells us if we are in the menu loop */
static
BOOL
bInMenuLoop
=
FALSE
;
/* Tells us if we are in the menu loop */
static
HWND
hChildWnd
;
/*******************************************************************************
/*******************************************************************************
* Local module support methods
* Local module support methods
*/
*/
...
@@ -60,7 +58,7 @@ static void resize_frame_rect(HWND hWnd, PRECT prect)
...
@@ -60,7 +58,7 @@ static void resize_frame_rect(HWND hWnd, PRECT prect)
GetClientRect
(
hStatusBar
,
&
rt
);
GetClientRect
(
hStatusBar
,
&
rt
);
prect
->
bottom
-=
rt
.
bottom
;
prect
->
bottom
-=
rt
.
bottom
;
}
}
MoveWindow
(
hChild
Wnd
,
prect
->
left
,
prect
->
top
,
prect
->
right
,
prect
->
bottom
,
TRUE
);
MoveWindow
(
g_pChildWnd
->
h
Wnd
,
prect
->
left
,
prect
->
top
,
prect
->
right
,
prect
->
bottom
,
TRUE
);
}
}
void
resize_frame_client
(
HWND
hWnd
)
void
resize_frame_client
(
HWND
hWnd
)
...
@@ -437,21 +435,20 @@ BOOL RefreshView(HWND hWnd)
...
@@ -437,21 +435,20 @@ BOOL RefreshView(HWND hWnd)
*/
*/
static
BOOL
_CmdWndProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
static
BOOL
_CmdWndProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
{
HKEY
hKeyRoot
,
hKey
;
HKEY
hKeyRoot
=
0
,
hKey
=
0
;
TCHAR
keyPath
[
1000
]
=
{
0
};
LPCTSTR
keyPath
;
TCHAR
valueName
[
255
]
=
{
0
};
LPCTSTR
valueName
;
int
keyPathLen
=
0
,
item
;
BOOL
result
=
TRUE
;
BOOL
result
=
TRUE
;
LONG
lRet
;
LONG
lRet
;
hKeyRoot
=
FindRegRoot
(
pChildWnd
->
hTreeWnd
,
0
,
keyPath
,
&
keyPathLen
,
sizeof
(
keyPath
)
/
sizeof
(
TCHAR
));
keyPath
=
GetItemPath
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
hKeyRoot
);
lRet
=
RegOpenKeyEx
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
,
&
hKey
);
valueName
=
GetValueName
(
g_pChildWnd
->
hListWnd
);
if
(
lRet
!=
ERROR_SUCCESS
)
hKey
=
0
;
if
(
keyPath
)
{
item
=
ListView_GetNextItem
(
pChildWnd
->
hListWnd
,
-
1
,
LVNI_FOCUSED
);
lRet
=
RegOpenKeyEx
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
,
&
hKey
);
if
(
item
!=
-
1
)
ListView_GetItemText
(
pChildWnd
->
hListWnd
,
item
,
0
,
valueName
,
sizeof
(
valueName
)
/
sizeof
(
TCHAR
));
if
(
lRet
!=
ERROR_SUCCESS
)
hKey
=
0
;
}
switch
(
LOWORD
(
wParam
))
{
switch
(
LOWORD
(
wParam
))
{
/* Parse the menu selections:*/
case
ID_REGISTRY_IMPORTREGISTRYFILE
:
case
ID_REGISTRY_IMPORTREGISTRYFILE
:
ImportRegistryFile
(
hWnd
);
ImportRegistryFile
(
hWnd
);
break
;
break
;
...
@@ -467,7 +464,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
...
@@ -467,7 +464,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break
;
break
;
case
ID_EDIT_MODIFY
:
case
ID_EDIT_MODIFY
:
if
(
ModifyValue
(
hWnd
,
hKey
,
valueName
))
if
(
ModifyValue
(
hWnd
,
hKey
,
valueName
))
RefreshListView
(
pChildWnd
->
hListWnd
,
hKeyRoot
,
keyPath
);
RefreshListView
(
g_
pChildWnd
->
hListWnd
,
hKeyRoot
,
keyPath
);
break
;
break
;
case
ID_EDIT_COPYKEYNAME
:
case
ID_EDIT_COPYKEYNAME
:
CopyKeyName
(
hWnd
,
_T
(
""
));
CopyKeyName
(
hWnd
,
_T
(
""
));
...
@@ -486,22 +483,17 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
...
@@ -486,22 +483,17 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case
ID_VIEW_REFRESH
:
case
ID_VIEW_REFRESH
:
RefreshView
(
hWnd
);
RefreshView
(
hWnd
);
break
;
break
;
/*
case ID_OPTIONS_TOOLBAR:*/
/*
case ID_OPTIONS_TOOLBAR:*/
/*
toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
/*
toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
/*
break;*/
/*
break;*/
case
ID_VIEW_STATUSBAR
:
case
ID_VIEW_STATUSBAR
:
toggle_child
(
hWnd
,
LOWORD
(
wParam
),
hStatusBar
);
toggle_child
(
hWnd
,
LOWORD
(
wParam
),
hStatusBar
);
break
;
break
;
case
ID_HELP_HELPTOPICS
:
case
ID_HELP_HELPTOPICS
:
/* WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);*/
WinHelp
(
hWnd
,
_T
(
"regedit"
),
HELP_FINDER
,
0
);
WinHelp
(
hWnd
,
_T
(
"regedit"
),
HELP_FINDER
,
0
);
break
;
break
;
case
ID_HELP_ABOUT
:
case
ID_HELP_ABOUT
:
#ifdef WINSHELLAPI
/* ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));*/
#else
ShowAboutBox
(
hWnd
);
ShowAboutBox
(
hWnd
);
#endif
break
;
break
;
default:
default:
result
=
FALSE
;
result
=
FALSE
;
...
@@ -524,23 +516,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
...
@@ -524,23 +516,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT
CALLBACK
FrameWndProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
LRESULT
CALLBACK
FrameWndProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
{
static
ChildWnd
*
pChildWnd
=
NULL
;
switch
(
message
)
{
switch
(
message
)
{
case
WM_CREATE
:
{
case
WM_CREATE
:
pChildWnd
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
ChildWnd
));
CreateWindowEx
(
0
,
szChildClass
,
_T
(
"regedit child window"
),
WS_CHILD
|
WS_VISIBLE
,
_tcsncpy
(
pChildWnd
->
szPath
,
_T
(
"My Computer"
),
MAX_PATH
);
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
hChildWnd
=
CreateWindowEx
(
0
,
szChildClass
,
_T
(
"regedit child window"
),
hWnd
,
(
HMENU
)
0
,
hInst
,
0
);
/* WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,*/
WS_CHILD
|
WS_VISIBLE
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
hWnd
,
(
HMENU
)
0
,
hInst
,
pChildWnd
);
}
break
;
break
;
case
WM_COMMAND
:
case
WM_COMMAND
:
if
(
!
_CmdWndProc
(
hWnd
,
message
,
wParam
,
lParam
))
{
if
(
!
_CmdWndProc
(
hWnd
,
message
,
wParam
,
lParam
))
return
DefWindowProc
(
hWnd
,
message
,
wParam
,
lParam
);
return
DefWindowProc
(
hWnd
,
message
,
wParam
,
lParam
);
}
break
;
break
;
case
WM_SIZE
:
case
WM_SIZE
:
resize_frame_client
(
hWnd
);
resize_frame_client
(
hWnd
);
...
@@ -557,10 +541,6 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
...
@@ -557,10 +541,6 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
OnMenuSelect
(
hWnd
,
LOWORD
(
wParam
),
HIWORD
(
wParam
),
(
HMENU
)
lParam
);
OnMenuSelect
(
hWnd
,
LOWORD
(
wParam
),
HIWORD
(
wParam
),
(
HMENU
)
lParam
);
break
;
break
;
case
WM_DESTROY
:
case
WM_DESTROY
:
if
(
pChildWnd
)
{
HeapFree
(
GetProcessHeap
(),
0
,
pChildWnd
);
pChildWnd
=
NULL
;
}
WinHelp
(
hWnd
,
_T
(
"regedit"
),
HELP_QUIT
,
0
);
WinHelp
(
hWnd
,
_T
(
"regedit"
),
HELP_QUIT
,
0
);
PostQuitMessage
(
0
);
PostQuitMessage
(
0
);
default:
default:
...
...
programs/regedit/listview.c
View file @
16614538
...
@@ -19,15 +19,13 @@
...
@@ -19,15 +19,13 @@
*/
*/
#include <windows.h>
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commctrl.h>
#include <stdlib.h>
#include <stdlib.h>
#include <tchar.h>
#include <tchar.h>
#include <process.h>
#include <process.h>
#include <stdio.h>
#include <stdio.h>
#include "commctrl.h"
#include <windowsx.h>
#include "main.h"
#include "main.h"
typedef
struct
tagLINE_INFO
typedef
struct
tagLINE_INFO
...
@@ -45,11 +43,37 @@ typedef struct tagLINE_INFO
...
@@ -45,11 +43,37 @@ typedef struct tagLINE_INFO
static
WNDPROC
g_orgListWndProc
;
static
WNDPROC
g_orgListWndProc
;
static
DWORD
g_columnToSort
=
~
0UL
;
static
DWORD
g_columnToSort
=
~
0UL
;
static
BOOL
g_invertSort
=
FALSE
;
static
BOOL
g_invertSort
=
FALSE
;
static
LPTSTR
g_valueName
;
#define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
#define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
static
int
default_column_widths
[
MAX_LIST_COLUMNS
]
=
{
200
,
175
,
400
};
static
int
default_column_widths
[
MAX_LIST_COLUMNS
]
=
{
200
,
175
,
400
};
static
int
column_alignment
[
MAX_LIST_COLUMNS
]
=
{
LVCFMT_LEFT
,
LVCFMT_LEFT
,
LVCFMT_LEFT
};
static
int
column_alignment
[
MAX_LIST_COLUMNS
]
=
{
LVCFMT_LEFT
,
LVCFMT_LEFT
,
LVCFMT_LEFT
};
LPCTSTR
GetValueName
(
HWND
hwndLV
)
{
int
item
,
len
,
maxLen
;
LPTSTR
newStr
;
if
(
!
g_valueName
)
g_valueName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
1024
);
if
(
!
g_valueName
)
return
NULL
;
*
g_valueName
=
0
;
maxLen
=
HeapSize
(
GetProcessHeap
(),
0
,
g_valueName
);
if
(
maxLen
==
(
SIZE_T
)
-
1
)
return
NULL
;
item
=
ListView_GetNextItem
(
hwndLV
,
-
1
,
LVNI_FOCUSED
);
if
(
item
==
-
1
)
return
NULL
;
do
{
ListView_GetItemText
(
hwndLV
,
item
,
0
,
g_valueName
,
maxLen
);
len
=
_tcslen
(
g_valueName
);
if
(
len
<
maxLen
-
1
)
break
;
newStr
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
g_valueName
,
maxLen
*
2
);
if
(
!
newStr
)
return
NULL
;
g_valueName
=
newStr
;
maxLen
*=
2
;
}
while
(
TRUE
);
return
g_valueName
;
}
/*******************************************************************************
/*******************************************************************************
* Local module support methods
* Local module support methods
...
@@ -118,7 +142,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
...
@@ -118,7 +142,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
}
}
}
}
static
void
CreateListColumns
(
HWND
hWndListView
)
static
BOOL
CreateListColumns
(
HWND
hWndListView
)
{
{
TCHAR
szText
[
50
];
TCHAR
szText
[
50
];
int
index
;
int
index
;
...
@@ -134,11 +158,9 @@ static void CreateListColumns(HWND hWndListView)
...
@@ -134,11 +158,9 @@ static void CreateListColumns(HWND hWndListView)
lvC
.
cx
=
default_column_widths
[
index
];
lvC
.
cx
=
default_column_widths
[
index
];
lvC
.
fmt
=
column_alignment
[
index
];
lvC
.
fmt
=
column_alignment
[
index
];
LoadString
(
hInst
,
IDS_LIST_COLUMN_FIRST
+
index
,
szText
,
sizeof
(
szText
)
/
sizeof
(
TCHAR
));
LoadString
(
hInst
,
IDS_LIST_COLUMN_FIRST
+
index
,
szText
,
sizeof
(
szText
)
/
sizeof
(
TCHAR
));
if
(
ListView_InsertColumn
(
hWndListView
,
index
,
&
lvC
)
==
-
1
)
{
if
(
ListView_InsertColumn
(
hWndListView
,
index
,
&
lvC
)
==
-
1
)
return
FALSE
;
/* TODO: handle failure condition... */
break
;
}
}
}
return
TRUE
;
}
}
/* OnGetDispInfo - processes the LVN_GETDISPINFO notification message. */
/* OnGetDispInfo - processes the LVN_GETDISPINFO notification message. */
...
@@ -168,9 +190,6 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
...
@@ -168,9 +190,6 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
case
REG_DWORD
:
case
REG_DWORD
:
plvdi
->
item
.
pszText
=
_T
(
"REG_DWORD"
);
plvdi
->
item
.
pszText
=
_T
(
"REG_DWORD"
);
break
;
break
;
/* case REG_DWORD_LITTLE_ENDIAN: */
/* plvdi->item.pszText = _T("REG_DWORD_LITTLE_ENDIAN"); */
/* break; */
case
REG_DWORD_BIG_ENDIAN
:
case
REG_DWORD_BIG_ENDIAN
:
plvdi
->
item
.
pszText
=
_T
(
"REG_DWORD_BIG_ENDIAN"
);
plvdi
->
item
.
pszText
=
_T
(
"REG_DWORD_BIG_ENDIAN"
);
break
;
break
;
...
@@ -212,8 +231,7 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor
...
@@ -212,8 +231,7 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor
if
(
g_columnToSort
==
1
&&
l
->
dwValType
!=
r
->
dwValType
)
if
(
g_columnToSort
==
1
&&
l
->
dwValType
!=
r
->
dwValType
)
return
g_invertSort
?
(
int
)
r
->
dwValType
-
(
int
)
l
->
dwValType
:
(
int
)
l
->
dwValType
-
(
int
)
r
->
dwValType
;
return
g_invertSort
?
(
int
)
r
->
dwValType
-
(
int
)
l
->
dwValType
:
(
int
)
l
->
dwValType
-
(
int
)
r
->
dwValType
;
if
(
g_columnToSort
==
2
)
if
(
g_columnToSort
==
2
)
{
{
/* FIXME: Sort on value */
/* FIXME: Sort on value */
}
}
return
g_invertSort
?
_tcscmp
(
r
->
name
,
l
->
name
)
:
_tcscmp
(
l
->
name
,
r
->
name
);
return
g_invertSort
?
_tcscmp
(
r
->
name
,
l
->
name
)
:
_tcscmp
(
l
->
name
,
r
->
name
);
...
@@ -249,8 +267,7 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
...
@@ -249,8 +267,7 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
case
LVN_COLUMNCLICK
:
case
LVN_COLUMNCLICK
:
if
(
g_columnToSort
==
((
LPNMLISTVIEW
)
lParam
)
->
iSubItem
)
if
(
g_columnToSort
==
((
LPNMLISTVIEW
)
lParam
)
->
iSubItem
)
g_invertSort
=
!
g_invertSort
;
g_invertSort
=
!
g_invertSort
;
else
else
{
{
g_columnToSort
=
((
LPNMLISTVIEW
)
lParam
)
->
iSubItem
;
g_columnToSort
=
((
LPNMLISTVIEW
)
lParam
)
->
iSubItem
;
g_invertSort
=
FALSE
;
g_invertSort
=
FALSE
;
}
}
...
@@ -332,80 +349,81 @@ HWND CreateListView(HWND hwndParent, int id)
...
@@ -332,80 +349,81 @@ HWND CreateListView(HWND hwndParent, int id)
WS_VISIBLE
|
WS_CHILD
|
LVS_REPORT
,
WS_VISIBLE
|
WS_CHILD
|
LVS_REPORT
,
0
,
0
,
rcClient
.
right
,
rcClient
.
bottom
,
0
,
0
,
rcClient
.
right
,
rcClient
.
bottom
,
hwndParent
,
(
HMENU
)
id
,
hInst
,
NULL
);
hwndParent
,
(
HMENU
)
id
,
hInst
,
NULL
);
if
(
!
hwndLV
)
return
NULL
;
ListView_SetExtendedListViewStyle
(
hwndLV
,
LVS_EX_FULLROWSELECT
);
ListView_SetExtendedListViewStyle
(
hwndLV
,
LVS_EX_FULLROWSELECT
);
/* Initialize the image list, and add items to the control. */
/* Initialize the image list, and add items to the control. */
/*
/*
if (!InitListViewImageLists(hwndLV) ||
if (!InitListViewImageLists(hwndLV)) goto fail;
!InitListViewItems(hwndLV, szName)) {
if (!InitListViewItems(hwndLV, szName)) goto fail;
DestroyWindow(hwndLV);
*/
return FALSE;
if
(
!
CreateListColumns
(
hwndLV
))
goto
fail
;
}
*/
CreateListColumns
(
hwndLV
);
g_orgListWndProc
=
SubclassWindow
(
hwndLV
,
ListWndProc
);
g_orgListWndProc
=
SubclassWindow
(
hwndLV
,
ListWndProc
);
return
hwndLV
;
return
hwndLV
;
fail:
DestroyWindow
(
hwndLV
);
return
NULL
;
}
}
BOOL
RefreshListView
(
HWND
hwndLV
,
HKEY
hKey
,
LPTSTR
keyPath
)
BOOL
RefreshListView
(
HWND
hwndLV
,
HKEY
hKey
,
LP
C
TSTR
keyPath
)
{
{
if
(
hwndLV
!=
NULL
)
{
DWORD
max_sub_key_len
;
INT
count
,
i
;
DWORD
max_val_name_len
;
count
=
ListView_GetItemCount
(
hwndLV
);
DWORD
max_val_size
;
for
(
i
=
0
;
i
<
count
;
i
++
)
DWORD
val_count
;
{
HKEY
hNewKey
;
LVITEM
item
;
LONG
errCode
;
item
.
mask
=
LVIF_PARAM
;
INT
count
,
i
;
item
.
iItem
=
i
;
LVITEM
item
;
ListView_GetItem
(
hwndLV
,
&
item
);
free
(((
LINE_INFO
*
)
item
.
lParam
)
->
name
);
HeapFree
(
GetProcessHeap
(),
0
,
(
void
*
)
item
.
lParam
);
}
g_columnToSort
=
~
0UL
;
ListView_DeleteAllItems
(
hwndLV
);
}
if
(
hKey
!=
NULL
)
{
if
(
!
hwndLV
)
return
FALSE
;
HKEY
hNewKey
;
LONG
errCode
=
RegOpenKeyEx
(
hKey
,
keyPath
,
0
,
KEY_READ
,
&
hNewKey
);
SendMessage
(
hwndLV
,
WM_SETREDRAW
,
FALSE
,
0
);
if
(
errCode
==
ERROR_SUCCESS
)
{
count
=
ListView_GetItemCount
(
hwndLV
);
DWORD
max_sub_key_len
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
DWORD
max_val_name_len
;
item
.
mask
=
LVIF_PARAM
;
DWORD
max_val_size
;
item
.
iItem
=
i
;
DWORD
val_count
;
ListView_GetItem
(
hwndLV
,
&
item
);
ShowWindow
(
hwndLV
,
SW_HIDE
);
free
(((
LINE_INFO
*
)
item
.
lParam
)
->
name
);
/* get size information and resize the buffers if necessary */
HeapFree
(
GetProcessHeap
(),
0
,
(
void
*
)
item
.
lParam
);
errCode
=
RegQueryInfoKey
(
hNewKey
,
NULL
,
NULL
,
NULL
,
NULL
,
}
&
max_sub_key_len
,
NULL
,
&
val_count
,
&
max_val_name_len
,
&
max_val_size
,
NULL
,
NULL
);
g_columnToSort
=
~
0UL
;
ListView_DeleteAllItems
(
hwndLV
);
#define BUF_HEAD_SPACE 2
/* TODO: check why this is required with ROS ??? */
errCode
=
RegOpenKeyEx
(
hKey
,
keyPath
,
0
,
KEY_READ
,
&
hNewKey
);
if
(
errCode
==
ERROR_SUCCESS
)
{
if
(
errCode
!=
ERROR_SUCCESS
)
return
FALSE
;
TCHAR
*
ValName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
++
max_val_name_len
*
sizeof
(
TCHAR
)
+
BUF_HEAD_SPACE
);
DWORD
dwValNameLen
=
max_val_name_len
;
/* get size information and resize the buffers if necessary */
BYTE
*
ValBuf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
++
max_val_size
/* + BUF_HEAD_SPACE*/
);
errCode
=
RegQueryInfoKey
(
hNewKey
,
NULL
,
NULL
,
NULL
,
NULL
,
&
max_sub_key_len
,
NULL
,
DWORD
dwValSize
=
max_val_size
;
&
val_count
,
&
max_val_name_len
,
&
max_val_size
,
NULL
,
NULL
);
DWORD
dwIndex
=
0L
;
DWORD
dwValType
;
#define BUF_HEAD_SPACE 2
/* FIXME: check why this is required with ROS ??? */
/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */
if
(
errCode
==
ERROR_SUCCESS
)
{
/* } */
TCHAR
*
ValName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
++
max_val_name_len
*
sizeof
(
TCHAR
)
+
BUF_HEAD_SPACE
);
/* dwValSize = max_val_size; */
DWORD
dwValNameLen
=
max_val_name_len
;
while
(
RegEnumValue
(
hNewKey
,
dwIndex
,
ValName
,
&
dwValNameLen
,
NULL
,
&
dwValType
,
ValBuf
,
&
dwValSize
)
==
ERROR_SUCCESS
)
{
BYTE
*
ValBuf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
++
max_val_size
/* + BUF_HEAD_SPACE*/
);
ValBuf
[
dwValSize
]
=
0
;
DWORD
dwValSize
=
max_val_size
;
AddEntryToList
(
hwndLV
,
ValName
,
dwValType
,
ValBuf
,
dwValSize
);
DWORD
dwIndex
=
0L
;
dwValNameLen
=
max_val_name_len
;
DWORD
dwValType
;
dwValSize
=
max_val_size
;
/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
dwValType
=
0L
;
/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */
++
dwIndex
;
/* } */
}
/* dwValSize = max_val_size; */
HeapFree
(
GetProcessHeap
(),
0
,
ValBuf
);
while
(
RegEnumValue
(
hNewKey
,
dwIndex
,
ValName
,
&
dwValNameLen
,
NULL
,
&
dwValType
,
ValBuf
,
&
dwValSize
)
==
ERROR_SUCCESS
)
{
HeapFree
(
GetProcessHeap
(),
0
,
ValName
);
ValBuf
[
dwValSize
]
=
0
;
}
AddEntryToList
(
hwndLV
,
ValName
,
dwValType
,
ValBuf
,
dwValSize
);
ListView_SortItems
(
hwndLV
,
CompareFunc
,
hwndLV
);
dwValNameLen
=
max_val_name_len
;
ShowWindow
(
hwndLV
,
SW_SHOW
);
dwValSize
=
max_val_size
;
RegCloseKey
(
hNewKey
);
dwValType
=
0L
;
++
dwIndex
;
}
}
HeapFree
(
GetProcessHeap
(),
0
,
ValBuf
);
HeapFree
(
GetProcessHeap
(),
0
,
ValName
);
}
}
ListView_SortItems
(
hwndLV
,
CompareFunc
,
hwndLV
);
RegCloseKey
(
hNewKey
);
SendMessage
(
hwndLV
,
WM_SETREDRAW
,
TRUE
,
0
);
return
TRUE
;
return
TRUE
;
}
}
programs/regedit/main.c
View file @
16614538
...
@@ -46,6 +46,7 @@ UINT nClipboardFormat;
...
@@ -46,6 +46,7 @@ UINT nClipboardFormat;
LPCTSTR
strClipboardFormat
=
_T
(
"TODO: SET CORRECT FORMAT"
);
LPCTSTR
strClipboardFormat
=
_T
(
"TODO: SET CORRECT FORMAT"
);
#define MAX_LOADSTRING 100
TCHAR
szTitle
[
MAX_LOADSTRING
];
TCHAR
szTitle
[
MAX_LOADSTRING
];
TCHAR
szFrameClass
[
MAX_LOADSTRING
];
TCHAR
szFrameClass
[
MAX_LOADSTRING
];
TCHAR
szChildClass
[
MAX_LOADSTRING
];
TCHAR
szChildClass
[
MAX_LOADSTRING
];
...
...
programs/regedit/main.h
View file @
16614538
...
@@ -28,12 +28,12 @@
...
@@ -28,12 +28,12 @@
#define TREE_WINDOW 2002
#define TREE_WINDOW 2002
#define LIST_WINDOW 2003
#define LIST_WINDOW 2003
#define MAX_LOADSTRING 100
#define SPLIT_WIDTH 5
#define SPLIT_WIDTH 5
#define MAX_NAME_LEN 500
#define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
#define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
extern
HINSTANCE
hInst
;
/******************************************************************************/
/******************************************************************************/
enum
OPTION_FLAGS
{
enum
OPTION_FLAGS
{
...
@@ -55,7 +55,7 @@ typedef struct {
...
@@ -55,7 +55,7 @@ typedef struct {
WINDOWPLACEMENT
pos
;
WINDOWPLACEMENT
pos
;
TCHAR
szPath
[
MAX_PATH
];
TCHAR
szPath
[
MAX_PATH
];
}
ChildWnd
;
}
ChildWnd
;
extern
ChildWnd
*
pChildWnd
;
extern
ChildWnd
*
g_
pChildWnd
;
/*******************************************************************************
/*******************************************************************************
* Global Variables:
* Global Variables:
...
@@ -84,14 +84,15 @@ extern void UpdateStatusBar(void);
...
@@ -84,14 +84,15 @@ extern void UpdateStatusBar(void);
/* listview.c */
/* listview.c */
extern
HWND
CreateListView
(
HWND
hwndParent
,
int
id
);
extern
HWND
CreateListView
(
HWND
hwndParent
,
int
id
);
extern
BOOL
RefreshListView
(
HWND
hwndTV
,
HKEY
hKey
,
LPTSTR
keyPath
);
extern
BOOL
RefreshListView
(
HWND
hwndLV
,
HKEY
hKey
,
LPCTSTR
keyPath
);
extern
LPCTSTR
GetValueName
(
HWND
hwndLV
);
/* treeview.c */
/* treeview.c */
extern
HWND
CreateTreeView
(
HWND
hwndParent
,
LPTSTR
pHostName
,
int
id
);
extern
HWND
CreateTreeView
(
HWND
hwndParent
,
LPTSTR
pHostName
,
int
id
);
extern
BOOL
OnTreeExpanding
(
HWND
hWnd
,
NMTREEVIEW
*
pnmtv
);
extern
BOOL
OnTreeExpanding
(
HWND
hWnd
,
NMTREEVIEW
*
pnmtv
);
extern
HKEY
FindRegRoot
(
HWND
hwndTV
,
HTREEITEM
hItem
,
LPTSTR
keyPath
,
int
*
pPathLen
,
int
max
);
extern
LPCTSTR
GetItemPath
(
HWND
hwndTV
,
HTREEITEM
hItem
,
HKEY
*
phRootKey
);
/* edit.c */
/* edit.c */
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKey
,
LPTSTR
valueName
);
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKey
,
LP
C
TSTR
valueName
);
#endif
/* __MAIN_H__ */
#endif
/* __MAIN_H__ */
programs/regedit/treeview.c
View file @
16614538
...
@@ -39,53 +39,72 @@ int Image_Open;
...
@@ -39,53 +39,72 @@ int Image_Open;
int
Image_Closed
;
int
Image_Closed
;
int
Image_Root
;
int
Image_Root
;
static
LPTSTR
pathBuffer
;
#define CX_BITMAP 16
#define CX_BITMAP 16
#define CY_BITMAP 16
#define CY_BITMAP 16
#define NUM_BITMAPS 3
#define NUM_BITMAPS 3
static
BOOL
get_item_path
(
HWND
hwndTV
,
HTREEITEM
hItem
,
HKEY
*
phKey
,
LPTSTR
*
pKeyPath
,
int
*
pPathLen
,
int
*
pMaxLen
)
HKEY
FindRegRoot
(
HWND
hwndTV
,
HTREEITEM
hItem
,
LPTSTR
keyPath
,
int
*
pPathLen
,
int
max
)
{
{
HKEY
hKey
=
NULL
;
TVITEM
item
;
TVITEM
item
;
int
maxLen
,
len
;
if
(
!
hItem
)
hItem
=
TreeView_GetSelection
(
hwndTV
)
;
LPTSTR
newStr
;
item
.
mask
=
TVIF_PARAM
;
item
.
mask
=
TVIF_PARAM
;
item
.
hItem
=
TreeView_GetParent
(
hwndTV
,
hItem
);
item
.
hItem
=
hItem
;
if
(
!
TreeView_GetItem
(
hwndTV
,
&
item
))
return
FALSE
;
if
(
TreeView_GetItem
(
hwndTV
,
&
item
))
{
if
(
item
.
lParam
==
0
)
{
if
(
item
.
lParam
)
{
/* recurse */
/* found root key with valid key value */
hKey
=
FindRegRoot
(
hwndTV
,
item
.
hItem
,
keyPath
,
pPathLen
,
max
);
*
phKey
=
(
HKEY
)
item
.
lParam
;
keyPath
[
*
pPathLen
]
=
_T
(
'\\'
);
return
TRUE
;
++
(
*
pPathLen
);
}
item
.
mask
=
TVIF_TEXT
;
item
.
hItem
=
hItem
;
if
(
!
get_item_path
(
hwndTV
,
TreeView_GetParent
(
hwndTV
,
hItem
),
phKey
,
pKeyPath
,
pPathLen
,
pMaxLen
))
return
FALSE
;
item
.
pszText
=
&
keyPath
[
*
pPathLen
];
if
(
*
pPathLen
)
{
item
.
cchTextMax
=
max
-
*
pPathLen
;
(
*
pKeyPath
)[
*
pPathLen
]
=
_T
(
'\\'
);
if
(
TreeView_GetItem
(
hwndTV
,
&
item
))
{
++
(
*
pPathLen
);
*
pPathLen
+=
_tcslen
(
item
.
pszText
);
}
}
else
{
/* found root key with valid key value */
hKey
=
(
HKEY
)
item
.
lParam
;
item
.
mask
=
TVIF_TEXT
;
item
.
hItem
=
hItem
;
/* item.pszText = &keyPath[*pPathLen]; */
item
.
pszText
=
keyPath
;
item
.
cchTextMax
=
max
;
if
(
TreeView_GetItem
(
hwndTV
,
&
item
))
{
*
pPathLen
+=
_tcslen
(
item
.
pszText
);
}
}
}
}
return
hKey
;
do
{
item
.
mask
=
TVIF_TEXT
;
item
.
hItem
=
hItem
;
item
.
pszText
=
*
pKeyPath
+
*
pPathLen
;
item
.
cchTextMax
=
maxLen
=
*
pMaxLen
-
*
pPathLen
;
if
(
!
TreeView_GetItem
(
hwndTV
,
&
item
))
return
FALSE
;
len
=
_tcslen
(
item
.
pszText
);
if
(
len
<
maxLen
-
1
)
{
*
pPathLen
+=
len
;
break
;
}
newStr
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
*
pKeyPath
,
*
pMaxLen
*
2
);
if
(
!
newStr
)
return
FALSE
;
*
pKeyPath
=
newStr
;
*
pMaxLen
*=
2
;
}
while
(
TRUE
);
return
TRUE
;
}
LPCTSTR
GetItemPath
(
HWND
hwndTV
,
HTREEITEM
hItem
,
HKEY
*
phRootKey
)
{
int
pathLen
=
0
,
maxLen
;
if
(
!
pathBuffer
)
pathBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
1024
);
if
(
!
pathBuffer
)
return
NULL
;
*
pathBuffer
=
0
;
maxLen
=
HeapSize
(
GetProcessHeap
(),
0
,
pathBuffer
);
if
(
maxLen
==
(
SIZE_T
)
-
1
)
return
NULL
;
if
(
!
hItem
)
hItem
=
TreeView_GetSelection
(
hwndTV
);
if
(
!
hItem
)
return
NULL
;
if
(
!
get_item_path
(
hwndTV
,
hItem
,
phRootKey
,
&
pathBuffer
,
&
pathLen
,
&
maxLen
))
return
NULL
;
printf
(
"hRoot=%p, keyPath='%s'
\n
"
,
*
phRootKey
,
pathBuffer
);
return
pathBuffer
;
}
}
static
HTREEITEM
AddEntryToTree
(
HWND
hwndTV
,
HTREEITEM
hParent
,
LPTSTR
label
,
HKEY
hKey
,
DWORD
dwChildren
)
static
HTREEITEM
AddEntryToTree
(
HWND
hwndTV
,
HTREEITEM
hParent
,
LPTSTR
label
,
HKEY
hKey
,
DWORD
dwChildren
)
{
{
HTREEITEM
hItem
=
0
;
TVITEM
tvi
;
TVITEM
tvi
;
TVINSERTSTRUCT
tvins
;
TVINSERTSTRUCT
tvins
;
...
@@ -97,11 +116,9 @@ static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HK
...
@@ -97,11 +116,9 @@ static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HK
tvi
.
cChildren
=
dwChildren
;
tvi
.
cChildren
=
dwChildren
;
tvi
.
lParam
=
(
LPARAM
)
hKey
;
tvi
.
lParam
=
(
LPARAM
)
hKey
;
tvins
.
u
.
item
=
tvi
;
tvins
.
u
.
item
=
tvi
;
if
(
hKey
)
tvins
.
hInsertAfter
=
(
HTREEITEM
)
TVI_LAST
;
tvins
.
hInsertAfter
=
(
HTREEITEM
)(
hKey
?
TVI_LAST
:
TVI_SORT
);
else
tvins
.
hInsertAfter
=
(
HTREEITEM
)
TVI_SORT
;
tvins
.
hParent
=
hParent
;
tvins
.
hParent
=
hParent
;
hItem
=
(
HTREEITEM
)
SendMessage
(
hwndTV
,
TVM_INSERTITEM
,
0
,
(
LPARAM
)(
LPTVINSERTSTRUCT
)
&
tvins
);
return
TreeView_InsertItem
(
hwndTV
,
&
tvins
);
return
hItem
;
}
}
...
@@ -125,24 +142,24 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName)
...
@@ -125,24 +142,24 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName)
tvins
.
hInsertAfter
=
(
HTREEITEM
)
TVI_FIRST
;
tvins
.
hInsertAfter
=
(
HTREEITEM
)
TVI_FIRST
;
tvins
.
hParent
=
TVI_ROOT
;
tvins
.
hParent
=
TVI_ROOT
;
/* Add the item to the tree view control. */
/* Add the item to the tree view control. */
hRoot
=
(
HTREEITEM
)
SendMessage
(
hwndTV
,
TVM_INSERTITEM
,
0
,
(
LPARAM
)(
LPTVINSERTSTRUCT
)
&
tvins
)
;
if
(
!
(
hRoot
=
TreeView_InsertItem
(
hwndTV
,
&
tvins
)))
return
FALSE
;
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_CLASSES_ROOT"
),
HKEY_CLASSES_ROOT
,
1
)
;
if
(
!
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_CLASSES_ROOT"
),
HKEY_CLASSES_ROOT
,
1
))
return
FALSE
;
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_CURRENT_USER"
),
HKEY_CURRENT_USER
,
1
)
;
if
(
!
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_CURRENT_USER"
),
HKEY_CURRENT_USER
,
1
))
return
FALSE
;
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_LOCAL_MACHINE"
),
HKEY_LOCAL_MACHINE
,
1
)
;
if
(
!
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_LOCAL_MACHINE"
),
HKEY_LOCAL_MACHINE
,
1
))
return
FALSE
;
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_USERS"
),
HKEY_USERS
,
1
)
;
if
(
!
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_USERS"
),
HKEY_USERS
,
1
))
return
FALSE
;
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_CURRENT_CONFIG"
),
HKEY_CURRENT_CONFIG
,
1
)
;
if
(
!
AddEntryToTree
(
hwndTV
,
hRoot
,
_T
(
"HKEY_CURRENT_CONFIG"
),
HKEY_CURRENT_CONFIG
,
1
))
return
FALSE
;
return
TRUE
;
return
TRUE
;
}
}
/*
/*
* InitTreeViewImageLists - creates an image list, adds three bitmaps
* InitTreeViewImageLists - creates an image list, adds three bitmaps
* to it, and associates the image list with a tree view control.
* to it, and associates the image list with a tree view control.
* Returns TRUE if successful, or FALSE otherwise.
* Returns TRUE if successful, or FALSE otherwise.
* hwndTV - handle to the tree view control.
* hwndTV - handle to the tree view control.
*/
*/
static
BOOL
InitTreeViewImageLists
(
HWND
hwndTV
)
static
BOOL
InitTreeViewImageLists
(
HWND
hwndTV
)
{
{
HIMAGELIST
himl
;
/* handle to image list */
HIMAGELIST
himl
;
/* handle to image list */
...
@@ -155,20 +172,19 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
...
@@ -155,20 +172,19 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
/* Add the open file, closed file, and document bitmaps. */
/* Add the open file, closed file, and document bitmaps. */
hbmp
=
LoadBitmap
(
hInst
,
MAKEINTRESOURCE
(
IDB_OPEN_FILE
));
hbmp
=
LoadBitmap
(
hInst
,
MAKEINTRESOURCE
(
IDB_OPEN_FILE
));
Image_Open
=
ImageList_Add
(
himl
,
hbmp
,
(
HBITMAP
)
NULL
);
Image_Open
=
ImageList_Add
(
himl
,
hbmp
,
NULL
);
DeleteObject
(
hbmp
);
DeleteObject
(
hbmp
);
hbmp
=
LoadBitmap
(
hInst
,
MAKEINTRESOURCE
(
IDB_CLOSED_FILE
));
hbmp
=
LoadBitmap
(
hInst
,
MAKEINTRESOURCE
(
IDB_CLOSED_FILE
));
Image_Closed
=
ImageList_Add
(
himl
,
hbmp
,
(
HBITMAP
)
NULL
);
Image_Closed
=
ImageList_Add
(
himl
,
hbmp
,
NULL
);
DeleteObject
(
hbmp
);
DeleteObject
(
hbmp
);
hbmp
=
LoadBitmap
(
hInst
,
MAKEINTRESOURCE
(
IDB_ROOT
));
hbmp
=
LoadBitmap
(
hInst
,
MAKEINTRESOURCE
(
IDB_ROOT
));
Image_Root
=
ImageList_Add
(
himl
,
hbmp
,
(
HBITMAP
)
NULL
);
Image_Root
=
ImageList_Add
(
himl
,
hbmp
,
NULL
);
DeleteObject
(
hbmp
);
DeleteObject
(
hbmp
);
/* Fail if not all of the images were added. */
/* Fail if not all of the images were added. */
if
(
ImageList_GetImageCount
(
himl
)
<
3
)
if
(
ImageList_GetImageCount
(
himl
)
<
3
)
return
FALSE
;
return
FALSE
;
/* Associate the image list with the tree view control. */
/* Associate the image list with the tree view control. */
TreeView_SetImageList
(
hwndTV
,
himl
,
TVSIL_NORMAL
);
TreeView_SetImageList
(
hwndTV
,
himl
,
TVSIL_NORMAL
);
...
@@ -178,9 +194,11 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
...
@@ -178,9 +194,11 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
BOOL
OnTreeExpanding
(
HWND
hwndTV
,
NMTREEVIEW
*
pnmtv
)
BOOL
OnTreeExpanding
(
HWND
hwndTV
,
NMTREEVIEW
*
pnmtv
)
{
{
HKEY
hKey
;
DWORD
dwCount
,
dwIndex
,
dwMaxSubKeyLen
;
TCHAR
keyPath
[
1000
];
HKEY
hRoot
,
hNewKey
,
hKey
;
int
keyPathLen
=
0
;
LPCTSTR
keyPath
;
LPTSTR
Name
;
LONG
errCode
;
static
int
expanding
;
static
int
expanding
;
if
(
expanding
)
return
FALSE
;
if
(
expanding
)
return
FALSE
;
...
@@ -189,54 +207,52 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
...
@@ -189,54 +207,52 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
}
}
expanding
=
TRUE
;
expanding
=
TRUE
;
/* check if this is either the root or a subkey item... */
keyPath
=
GetItemPath
(
hwndTV
,
pnmtv
->
itemNew
.
hItem
,
&
hRoot
);
if
((
HKEY
)
pnmtv
->
itemNew
.
lParam
==
NULL
)
{
if
(
!
keyPath
)
goto
done
;
keyPath
[
0
]
=
_T
(
'\0'
);
hKey
=
FindRegRoot
(
hwndTV
,
pnmtv
->
itemNew
.
hItem
,
keyPath
,
&
keyPathLen
,
sizeof
(
keyPath
)
/
sizeof
(
TCHAR
));
if
(
*
keyPath
)
{
errCode
=
RegOpenKeyEx
(
hRoot
,
keyPath
,
0
,
KEY_READ
,
&
hNewKey
);
if
(
errCode
!=
ERROR_SUCCESS
)
goto
done
;
}
else
{
}
else
{
hKey
=
(
HKEY
)
pnmtv
->
itemNew
.
lParam
;
hNewKey
=
hRoot
;
keyPath
[
0
]
=
_T
(
'\0'
);
}
}
if
(
hKey
!=
NULL
)
{
errCode
=
RegQueryInfoKey
(
hNewKey
,
0
,
0
,
0
,
&
dwCount
,
&
dwMaxSubKeyLen
,
0
,
0
,
0
,
0
,
0
,
0
);
HKEY
hNewKey
;
if
(
errCode
!=
ERROR_SUCCESS
)
goto
done
;
LONG
errCode
=
RegOpenKeyEx
(
hKey
,
keyPath
,
0
,
KEY_READ
,
&
hNewKey
);
dwMaxSubKeyLen
++
;
/* account for the \0 terminator */
if
(
errCode
==
ERROR_SUCCESS
)
{
Name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwMaxSubKeyLen
*
sizeof
(
TCHAR
));
TCHAR
Name
[
MAX_NAME_LEN
];
if
(
!
Name
)
goto
done
;
DWORD
cName
=
MAX_NAME_LEN
;
FILETIME
LastWriteTime
;
for
(
dwIndex
=
0
;
dwIndex
<
dwCount
;
dwIndex
++
)
{
DWORD
dwIndex
=
0L
;
DWORD
cName
=
dwMaxSubKeyLen
,
dwSubCount
;
/*ShowWindow(hwndTV, SW_HIDE); */
FILETIME
LastWriteTime
;
while
(
RegEnumKeyEx
(
hNewKey
,
dwIndex
,
Name
,
&
cName
,
NULL
,
NULL
,
NULL
,
&
LastWriteTime
)
==
ERROR_SUCCESS
)
{
DWORD
dwCount
=
0L
;
errCode
=
RegEnumKeyEx
(
hNewKey
,
dwIndex
,
Name
,
&
cName
,
0
,
0
,
0
,
&
LastWriteTime
);
errCode
=
RegOpenKeyEx
(
hNewKey
,
Name
,
0
,
KEY_READ
,
&
hKey
);
if
(
errCode
!=
ERROR_SUCCESS
)
continue
;
if
(
errCode
==
ERROR_SUCCESS
)
{
errCode
=
RegOpenKeyEx
(
hNewKey
,
Name
,
0
,
KEY_QUERY_VALUE
,
&
hKey
);
TCHAR
SubName
[
MAX_NAME_LEN
];
if
(
errCode
==
ERROR_SUCCESS
)
{
DWORD
cSubName
=
MAX_NAME_LEN
;
errCode
=
RegQueryInfoKey
(
hKey
,
0
,
0
,
0
,
&
dwSubCount
,
0
,
0
,
0
,
0
,
0
,
0
,
0
);
/* if (RegEnumKeyEx(hKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { */
RegCloseKey
(
hKey
);
while
(
RegEnumKeyEx
(
hKey
,
dwCount
,
SubName
,
&
cSubName
,
NULL
,
NULL
,
NULL
,
NULL
)
==
ERROR_SUCCESS
)
{
}
++
dwCount
;
if
(
errCode
!=
ERROR_SUCCESS
)
dwSubCount
=
0
;
}
printf
(
"dwSubCount=%ld, Name=%s
\n
"
,
dwSubCount
,
Name
);
}
AddEntryToTree
(
hwndTV
,
pnmtv
->
itemNew
.
hItem
,
Name
,
NULL
,
dwSubCount
);
RegCloseKey
(
hKey
);
AddEntryToTree
(
hwndTV
,
pnmtv
->
itemNew
.
hItem
,
Name
,
NULL
,
dwCount
);
cName
=
MAX_NAME_LEN
;
++
dwIndex
;
}
/*ShowWindow(hwndTV, SW_SHOWNOACTIVATE); */
RegCloseKey
(
hNewKey
);
}
}
}
RegCloseKey
(
hNewKey
);
HeapFree
(
GetProcessHeap
(),
0
,
Name
);
done:
expanding
=
FALSE
;
expanding
=
FALSE
;
return
TRUE
;
return
TRUE
;
}
}
/*
/*
* CreateTreeView - creates a tree view control.
* CreateTreeView - creates a tree view control.
* Returns the handle to the new control if successful, or NULL otherwise.
* Returns the handle to the new control if successful, or NULL otherwise.
* hwndParent - handle to the control's parent window.
* hwndParent - handle to the control's parent window.
*/
*/
HWND
CreateTreeView
(
HWND
hwndParent
,
LPTSTR
pHostName
,
int
id
)
HWND
CreateTreeView
(
HWND
hwndParent
,
LPTSTR
pHostName
,
int
id
)
{
{
RECT
rcClient
;
RECT
rcClient
;
...
...
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