mirror of
https://github.com/reactos/reactos.git
synced 2025-05-13 22:30:21 +00:00
[REGEDIT]
- Adam Kachwalla: Fix inconsistent formatting. - Me: to anyone who's gonna try syncing the code with Wine's regedit: Have fun! See issue #5716 for more details. svn path=/trunk/; revision=49980
This commit is contained in:
parent
65081666b5
commit
ffe49df99a
13 changed files with 2665 additions and 2402 deletions
|
@ -49,12 +49,12 @@ static void draw_splitbar(HWND hWnd, int x)
|
||||||
|
|
||||||
if(!SizingPattern)
|
if(!SizingPattern)
|
||||||
{
|
{
|
||||||
const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
|
const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
|
||||||
SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
|
SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
|
||||||
}
|
}
|
||||||
if(!SizingBrush)
|
if(!SizingBrush)
|
||||||
{
|
{
|
||||||
SizingBrush = CreatePatternBrush(SizingPattern);
|
SizingBrush = CreatePatternBrush(SizingPattern);
|
||||||
}
|
}
|
||||||
GetClientRect(hWnd, &rt);
|
GetClientRect(hWnd, &rt);
|
||||||
rt.left = x - SPLIT_WIDTH/2;
|
rt.left = x - SPLIT_WIDTH/2;
|
||||||
|
@ -72,7 +72,8 @@ static void ResizeWnd(ChildWnd* pChildWnd, int cx, int cy)
|
||||||
const int tHeight = 18;
|
const int tHeight = 18;
|
||||||
SetRect(&rt, 0, 0, cx, cy);
|
SetRect(&rt, 0, 0, cx, cy);
|
||||||
cy = 0;
|
cy = 0;
|
||||||
if (hStatusBar != NULL) {
|
if (hStatusBar != NULL)
|
||||||
|
{
|
||||||
GetWindowRect(hStatusBar, &rs);
|
GetWindowRect(hStatusBar, &rs);
|
||||||
cy = rs.bottom - rs.top;
|
cy = rs.bottom - rs.top;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +133,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(message);
|
UNREFERENCED_PARAMETER(message);
|
||||||
|
|
||||||
switch (wID) {
|
switch (wID)
|
||||||
|
{
|
||||||
/* Parse the menu selections: */
|
/* Parse the menu selections: */
|
||||||
case ID_REGISTRY_EXIT:
|
case ID_REGISTRY_EXIT:
|
||||||
DestroyWindow(hWnd);
|
DestroyWindow(hWnd);
|
||||||
|
@ -156,15 +158,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
if (keyPath == 0 || *keyPath == 0)
|
if (keyPath == 0 || *keyPath == 0)
|
||||||
{
|
{
|
||||||
MessageBeep(MB_ICONHAND);
|
MessageBeep(MB_ICONHAND);
|
||||||
} else
|
}
|
||||||
if (DeleteKey(hWnd, hRootKey, keyPath))
|
else if (DeleteKey(hWnd, hRootKey, keyPath))
|
||||||
DeleteNode(g_pChildWnd->hTreeWnd, 0);
|
DeleteNode(g_pChildWnd->hTreeWnd, 0);
|
||||||
break;
|
break;
|
||||||
case ID_TREE_EXPORT:
|
case ID_TREE_EXPORT:
|
||||||
ExportRegistryFile(pChildWnd->hTreeWnd);
|
ExportRegistryFile(pChildWnd->hTreeWnd);
|
||||||
break;
|
break;
|
||||||
case ID_EDIT_FIND:
|
case ID_EDIT_FIND:
|
||||||
FindDialog(hWnd);
|
FindDialog(hWnd);
|
||||||
break;
|
break;
|
||||||
case ID_EDIT_COPYKEYNAME:
|
case ID_EDIT_COPYKEYNAME:
|
||||||
|
@ -186,13 +188,13 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ((wID >= ID_TREE_SUGGESTION_MIN) && (wID <= ID_TREE_SUGGESTION_MAX))
|
if ((wID >= ID_TREE_SUGGESTION_MIN) && (wID <= ID_TREE_SUGGESTION_MAX))
|
||||||
{
|
{
|
||||||
s = Suggestions;
|
s = Suggestions;
|
||||||
while(wID > ID_TREE_SUGGESTION_MIN)
|
while(wID > ID_TREE_SUGGESTION_MIN)
|
||||||
{
|
{
|
||||||
if (*s)
|
if (*s)
|
||||||
s += _tcslen(s) + 1;
|
s += _tcslen(s) + 1;
|
||||||
wID--;
|
wID--;
|
||||||
}
|
}
|
||||||
SelectNode(pChildWnd->hTreeWnd, s);
|
SelectNode(pChildWnd->hTreeWnd, s);
|
||||||
break;
|
break;
|
||||||
|
@ -210,95 +212,95 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
#define MIN(a,b) ((a < b) ? (a) : (b))
|
#define MIN(a,b) ((a < b) ? (a) : (b))
|
||||||
|
|
||||||
static void SuggestKeys(HKEY hRootKey, LPCTSTR pszKeyPath, LPTSTR pszSuggestions,
|
static void SuggestKeys(HKEY hRootKey, LPCTSTR pszKeyPath, LPTSTR pszSuggestions,
|
||||||
size_t iSuggestionsLength)
|
size_t iSuggestionsLength)
|
||||||
{
|
{
|
||||||
TCHAR szBuffer[256];
|
TCHAR szBuffer[256];
|
||||||
TCHAR szLastFound[256];
|
TCHAR szLastFound[256];
|
||||||
size_t i;
|
size_t i;
|
||||||
HKEY hOtherKey, hSubKey;
|
HKEY hOtherKey, hSubKey;
|
||||||
BOOL bFound;
|
BOOL bFound;
|
||||||
|
|
||||||
memset(pszSuggestions, 0, iSuggestionsLength * sizeof(*pszSuggestions));
|
memset(pszSuggestions, 0, iSuggestionsLength * sizeof(*pszSuggestions));
|
||||||
iSuggestionsLength--;
|
iSuggestionsLength--;
|
||||||
|
|
||||||
/* Are we a root key in HKEY_CLASSES_ROOT? */
|
/* Are we a root key in HKEY_CLASSES_ROOT? */
|
||||||
if ((hRootKey == HKEY_CLASSES_ROOT) && pszKeyPath[0] && !_tcschr(pszKeyPath, TEXT('\\')))
|
if ((hRootKey == HKEY_CLASSES_ROOT) && pszKeyPath[0] && !_tcschr(pszKeyPath, TEXT('\\')))
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bFound = FALSE;
|
bFound = FALSE;
|
||||||
|
|
||||||
/* Check default key */
|
/* Check default key */
|
||||||
if (QueryStringValue(hRootKey, pszKeyPath, NULL,
|
if (QueryStringValue(hRootKey, pszKeyPath, NULL,
|
||||||
szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS)
|
szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Sanity check this key; it cannot be empty, nor can it be a
|
/* Sanity check this key; it cannot be empty, nor can it be a
|
||||||
* loop back */
|
* loop back */
|
||||||
if ((szBuffer[0] != '\0') && _tcsicmp(szBuffer, pszKeyPath))
|
if ((szBuffer[0] != '\0') && _tcsicmp(szBuffer, pszKeyPath))
|
||||||
{
|
{
|
||||||
if (RegOpenKey(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS)
|
if (RegOpenKey(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
lstrcpyn(pszSuggestions, TEXT("HKCR\\"), (int) iSuggestionsLength);
|
lstrcpyn(pszSuggestions, TEXT("HKCR\\"), (int) iSuggestionsLength);
|
||||||
i = _tcslen(pszSuggestions);
|
i = _tcslen(pszSuggestions);
|
||||||
pszSuggestions += i;
|
pszSuggestions += i;
|
||||||
iSuggestionsLength -= i;
|
iSuggestionsLength -= i;
|
||||||
|
|
||||||
lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength);
|
lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength);
|
||||||
i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength);
|
i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength);
|
||||||
pszSuggestions += i;
|
pszSuggestions += i;
|
||||||
iSuggestionsLength -= i;
|
iSuggestionsLength -= i;
|
||||||
RegCloseKey(hOtherKey);
|
RegCloseKey(hOtherKey);
|
||||||
|
|
||||||
bFound = TRUE;
|
bFound = TRUE;
|
||||||
_tcscpy(szLastFound, szBuffer);
|
_tcscpy(szLastFound, szBuffer);
|
||||||
pszKeyPath = szLastFound;
|
pszKeyPath = szLastFound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(bFound && (iSuggestionsLength > 0));
|
while(bFound && (iSuggestionsLength > 0));
|
||||||
|
|
||||||
/* Check CLSID key */
|
/* Check CLSID key */
|
||||||
if (RegOpenKey(hRootKey, pszKeyPath, &hSubKey) == ERROR_SUCCESS)
|
if (RegOpenKey(hRootKey, pszKeyPath, &hSubKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (QueryStringValue(hSubKey, TEXT("CLSID"), NULL, szBuffer,
|
if (QueryStringValue(hSubKey, TEXT("CLSID"), NULL, szBuffer,
|
||||||
COUNT_OF(szBuffer)) == ERROR_SUCCESS)
|
COUNT_OF(szBuffer)) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
lstrcpyn(pszSuggestions, TEXT("HKCR\\CLSID\\"), (int) iSuggestionsLength);
|
lstrcpyn(pszSuggestions, TEXT("HKCR\\CLSID\\"), (int) iSuggestionsLength);
|
||||||
i = _tcslen(pszSuggestions);
|
i = _tcslen(pszSuggestions);
|
||||||
pszSuggestions += i;
|
pszSuggestions += i;
|
||||||
iSuggestionsLength -= i;
|
iSuggestionsLength -= i;
|
||||||
|
|
||||||
lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength);
|
lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength);
|
||||||
i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength);
|
i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength);
|
||||||
pszSuggestions += i;
|
pszSuggestions += i;
|
||||||
iSuggestionsLength -= i;
|
iSuggestionsLength -= i;
|
||||||
}
|
}
|
||||||
RegCloseKey(hSubKey);
|
RegCloseKey(hSubKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
WNDPROC oldwndproc;
|
WNDPROC oldwndproc;
|
||||||
static TCHAR s_szNode[256];
|
static TCHAR s_szNode[256];
|
||||||
oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWL_USERDATA);
|
oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWL_USERDATA);
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
if (wParam == VK_RETURN)
|
if (wParam == VK_RETURN)
|
||||||
{
|
{
|
||||||
GetWindowText(hwnd, s_szNode, sizeof(s_szNode) / sizeof(s_szNode[0]));
|
GetWindowText(hwnd, s_szNode, sizeof(s_szNode) / sizeof(s_szNode[0]));
|
||||||
SelectNode(g_pChildWnd->hTreeWnd, s_szNode);
|
SelectNode(g_pChildWnd->hTreeWnd, s_szNode);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam);
|
return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -317,10 +319,11 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
BOOL Result;
|
BOOL Result;
|
||||||
ChildWnd* pChildWnd = g_pChildWnd;
|
ChildWnd* pChildWnd = g_pChildWnd;
|
||||||
|
|
||||||
switch (message) {
|
switch (message)
|
||||||
|
{
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
{
|
{
|
||||||
WNDPROC oldproc;
|
WNDPROC oldproc;
|
||||||
HFONT hFont;
|
HFONT hFont;
|
||||||
TCHAR buffer[MAX_PATH];
|
TCHAR buffer[MAX_PATH];
|
||||||
/* load "My Computer" string */
|
/* load "My Computer" string */
|
||||||
|
@ -333,12 +336,12 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
pChildWnd->nSplitPos = 250;
|
pChildWnd->nSplitPos = 250;
|
||||||
pChildWnd->hWnd = hWnd;
|
pChildWnd->hWnd = hWnd;
|
||||||
pChildWnd->hAddressBarWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP,
|
pChildWnd->hAddressBarWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
hWnd, (HMENU)0, hInst, 0);
|
hWnd, (HMENU)0, hInst, 0);
|
||||||
pChildWnd->hAddressBtnWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Button"), _T("»"), WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP | BS_DEFPUSHBUTTON,
|
pChildWnd->hAddressBtnWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Button"), _T("»"), WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP | BS_DEFPUSHBUTTON,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
hWnd, (HMENU)0, hInst, 0);
|
hWnd, (HMENU)0, hInst, 0);
|
||||||
pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, (HMENU) TREE_WINDOW);
|
pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, (HMENU) TREE_WINDOW);
|
||||||
pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW/*, pChildWnd->szPath*/);
|
pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW/*, pChildWnd->szPath*/);
|
||||||
SetFocus(pChildWnd->hTreeWnd);
|
SetFocus(pChildWnd->hTreeWnd);
|
||||||
|
|
||||||
|
@ -355,17 +358,19 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
(WPARAM)hFont,
|
(WPARAM)hFont,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
/* Subclass the AddressBar */
|
/* Subclass the AddressBar */
|
||||||
oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_WNDPROC);
|
oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_WNDPROC);
|
||||||
SetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_USERDATA, (DWORD_PTR)oldproc);
|
SetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_USERDATA, (DWORD_PTR)oldproc);
|
||||||
SetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_WNDPROC, (DWORD_PTR)AddressBarProc);
|
SetWindowLongPtr(pChildWnd->hAddressBarWnd, GWL_WNDPROC, (DWORD_PTR)AddressBarProc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
if(HIWORD(wParam) == BN_CLICKED){
|
if(HIWORD(wParam) == BN_CLICKED)
|
||||||
|
{
|
||||||
PostMessage(pChildWnd->hAddressBarWnd, WM_KEYUP, VK_RETURN, 0);
|
PostMessage(pChildWnd->hAddressBarWnd, WM_KEYUP, VK_RETURN, 0);
|
||||||
}
|
}
|
||||||
else if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
|
else if (!_CmdWndProc(hWnd, message, wParam, lParam))
|
||||||
|
{
|
||||||
goto def;
|
goto def;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -373,39 +378,44 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
OnPaint(hWnd);
|
OnPaint(hWnd);
|
||||||
return 0;
|
return 0;
|
||||||
case WM_SETCURSOR:
|
case WM_SETCURSOR:
|
||||||
if (LOWORD(lParam) == HTCLIENT) {
|
if (LOWORD(lParam) == HTCLIENT)
|
||||||
|
{
|
||||||
POINT pt;
|
POINT pt;
|
||||||
GetCursorPos(&pt);
|
GetCursorPos(&pt);
|
||||||
ScreenToClient(hWnd, &pt);
|
ScreenToClient(hWnd, &pt);
|
||||||
if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1)
|
||||||
|
{
|
||||||
SetCursor(LoadCursor(0, IDC_SIZEWE));
|
SetCursor(LoadCursor(0, IDC_SIZEWE));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto def;
|
goto def;
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
DestroyTreeView();
|
DestroyTreeView();
|
||||||
DestroyListView(pChildWnd->hListWnd);
|
DestroyListView(pChildWnd->hListWnd);
|
||||||
DestroyMainMenu();
|
DestroyMainMenu();
|
||||||
HeapFree(GetProcessHeap(), 0, pChildWnd);
|
HeapFree(GetProcessHeap(), 0, pChildWnd);
|
||||||
pChildWnd = NULL;
|
pChildWnd = NULL;
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDOWN: {
|
case WM_LBUTTONDOWN:
|
||||||
RECT rt;
|
{
|
||||||
int x = (short)LOWORD(lParam);
|
RECT rt;
|
||||||
GetClientRect(hWnd, &rt);
|
int x = (short)LOWORD(lParam);
|
||||||
if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
GetClientRect(hWnd, &rt);
|
||||||
last_split = pChildWnd->nSplitPos;
|
if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1)
|
||||||
draw_splitbar(hWnd, last_split);
|
{
|
||||||
SetCapture(hWnd);
|
last_split = pChildWnd->nSplitPos;
|
||||||
}
|
draw_splitbar(hWnd, last_split);
|
||||||
break;
|
SetCapture(hWnd);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
if (GetCapture() == hWnd) {
|
if (GetCapture() == hWnd)
|
||||||
|
{
|
||||||
finish_splitbar(hWnd, LOWORD(lParam));
|
finish_splitbar(hWnd, LOWORD(lParam));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -417,7 +427,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
if (wParam == VK_ESCAPE)
|
if (wParam == VK_ESCAPE)
|
||||||
if (GetCapture() == hWnd) {
|
if (GetCapture() == hWnd)
|
||||||
|
{
|
||||||
RECT rt;
|
RECT rt;
|
||||||
draw_splitbar(hWnd, last_split);
|
draw_splitbar(hWnd, last_split);
|
||||||
GetClientRect(hWnd, &rt);
|
GetClientRect(hWnd, &rt);
|
||||||
|
@ -429,42 +440,44 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
if (GetCapture() == hWnd) {
|
if (GetCapture() == hWnd)
|
||||||
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
RECT rt;
|
RECT rt;
|
||||||
HGDIOBJ OldObj;
|
HGDIOBJ OldObj;
|
||||||
int x = LOWORD(lParam);
|
int x = LOWORD(lParam);
|
||||||
if(!SizingPattern)
|
if(!SizingPattern)
|
||||||
{
|
{
|
||||||
const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
|
const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
|
||||||
SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
|
SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
|
||||||
}
|
}
|
||||||
if(!SizingBrush)
|
if(!SizingBrush)
|
||||||
{
|
{
|
||||||
SizingBrush = CreatePatternBrush(SizingPattern);
|
SizingBrush = CreatePatternBrush(SizingPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetClientRect(hWnd, &rt);
|
GetClientRect(hWnd, &rt);
|
||||||
x = (SHORT) min(max(x, SPLIT_MIN), rt.right - SPLIT_MIN);
|
x = (SHORT) min(max(x, SPLIT_MIN), rt.right - SPLIT_MIN);
|
||||||
if(last_split != x)
|
if(last_split != x)
|
||||||
{
|
{
|
||||||
rt.left = last_split-SPLIT_WIDTH/2;
|
rt.left = last_split-SPLIT_WIDTH/2;
|
||||||
rt.right = last_split+SPLIT_WIDTH/2+1;
|
rt.right = last_split+SPLIT_WIDTH/2+1;
|
||||||
hdc = GetDC(hWnd);
|
hdc = GetDC(hWnd);
|
||||||
OldObj = SelectObject(hdc, SizingBrush);
|
OldObj = SelectObject(hdc, SizingBrush);
|
||||||
PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
|
PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
|
||||||
last_split = x;
|
last_split = x;
|
||||||
rt.left = x-SPLIT_WIDTH/2;
|
rt.left = x-SPLIT_WIDTH/2;
|
||||||
rt.right = x+SPLIT_WIDTH/2+1;
|
rt.right = x+SPLIT_WIDTH/2+1;
|
||||||
PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
|
PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
|
||||||
SelectObject(hdc, OldObj);
|
SelectObject(hdc, OldObj);
|
||||||
ReleaseDC(hWnd, hdc);
|
ReleaseDC(hWnd, hdc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
if (pChildWnd != NULL) {
|
if (pChildWnd != NULL)
|
||||||
|
{
|
||||||
SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd);
|
SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -473,283 +486,292 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
if ((int)wParam == TREE_WINDOW) {
|
if ((int)wParam == TREE_WINDOW)
|
||||||
switch (((LPNMHDR)lParam)->code) {
|
{
|
||||||
|
switch (((LPNMHDR)lParam)->code)
|
||||||
|
{
|
||||||
case TVN_ITEMEXPANDING:
|
case TVN_ITEMEXPANDING:
|
||||||
return !OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
|
return !OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
|
||||||
case TVN_SELCHANGED: {
|
case TVN_SELCHANGED:
|
||||||
LPCTSTR keyPath, rootName;
|
{
|
||||||
LPTSTR fullPath;
|
LPCTSTR keyPath, rootName;
|
||||||
HKEY hRootKey;
|
LPTSTR fullPath;
|
||||||
|
HKEY hRootKey;
|
||||||
|
|
||||||
keyPath = GetItemPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey);
|
keyPath = GetItemPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey);
|
||||||
if (keyPath) {
|
if (keyPath)
|
||||||
RefreshListView(pChildWnd->hListWnd, hRootKey, keyPath);
|
|
||||||
rootName = get_root_key_name(hRootKey);
|
|
||||||
fullPath = HeapAlloc(GetProcessHeap(), 0, (_tcslen(rootName) + 1 + _tcslen(keyPath) + 1) * sizeof(TCHAR));
|
|
||||||
if (fullPath) {
|
|
||||||
/* set (correct) the address bar text */
|
|
||||||
if(keyPath[0] != '\0')
|
|
||||||
_stprintf(fullPath, _T("%s\\%s"), rootName, keyPath);
|
|
||||||
else
|
|
||||||
fullPath = _tcscpy(fullPath, rootName);
|
|
||||||
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
|
|
||||||
SendMessage(pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath);
|
|
||||||
HeapFree(GetProcessHeap(), 0, fullPath);
|
|
||||||
/* disable hive manipulation items temporarily (enable only if necessary) */
|
|
||||||
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED);
|
|
||||||
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED);
|
|
||||||
/* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */
|
|
||||||
if (!(_tcsicmp(rootName, TEXT("HKEY_LOCAL_MACHINE")) &&
|
|
||||||
_tcsicmp(rootName, TEXT("HKEY_USERS"))))
|
|
||||||
{
|
{
|
||||||
// enable the unload menu item if at the root
|
RefreshListView(pChildWnd->hListWnd, hRootKey, keyPath);
|
||||||
// otherwise enable the load menu item if there is no slash in keyPath (ie. immediate child selected)
|
rootName = get_root_key_name(hRootKey);
|
||||||
if(keyPath[0] == '\0')
|
fullPath = HeapAlloc(GetProcessHeap(), 0, (_tcslen(rootName) + 1 + _tcslen(keyPath) + 1) * sizeof(TCHAR));
|
||||||
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED);
|
if (fullPath)
|
||||||
else if(!_tcschr(keyPath, _T('\\')))
|
{
|
||||||
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED);
|
/* set (correct) the address bar text */
|
||||||
}
|
if(keyPath[0] != '\0')
|
||||||
|
_stprintf(fullPath, _T("%s\\%s"), rootName, keyPath);
|
||||||
|
else
|
||||||
|
fullPath = _tcscpy(fullPath, rootName);
|
||||||
|
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
|
||||||
|
SendMessage(pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath);
|
||||||
|
HeapFree(GetProcessHeap(), 0, fullPath);
|
||||||
|
/* disable hive manipulation items temporarily (enable only if necessary) */
|
||||||
|
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
/* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */
|
||||||
|
if (!(_tcsicmp(rootName, TEXT("HKEY_LOCAL_MACHINE")) &&
|
||||||
|
_tcsicmp(rootName, TEXT("HKEY_USERS"))))
|
||||||
|
{
|
||||||
|
// enable the unload menu item if at the root
|
||||||
|
// otherwise enable the load menu item if there is no slash in keyPath (ie. immediate child selected)
|
||||||
|
if(keyPath[0] == '\0')
|
||||||
|
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
else if(!_tcschr(keyPath, _T('\\')))
|
||||||
|
EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
TCHAR szBuffer[MAX_PATH];
|
TCHAR szBuffer[MAX_PATH];
|
||||||
_sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("My Computer\\%s\\%s"), rootName, keyPath);
|
_sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("My Computer\\%s\\%s"), rootName, keyPath);
|
||||||
|
|
||||||
if (RegCreateKey(HKEY_CURRENT_USER,
|
if (RegCreateKey(HKEY_CURRENT_USER,
|
||||||
g_szGeneralRegKey,
|
g_szGeneralRegKey,
|
||||||
&hKey) == ERROR_SUCCESS)
|
&hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
RegSetValueEx(hKey, _T("LastKey"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) _tcslen(szBuffer) * sizeof(szBuffer[0]));
|
RegSetValueEx(hKey, _T("LastKey"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) _tcslen(szBuffer) * sizeof(szBuffer[0]));
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NM_SETFOCUS:
|
||||||
|
pChildWnd->nFocusPanel = 0;
|
||||||
break;
|
break;
|
||||||
case NM_SETFOCUS:
|
|
||||||
pChildWnd->nFocusPanel = 0;
|
|
||||||
break;
|
|
||||||
case TVN_BEGINLABELEDIT:
|
case TVN_BEGINLABELEDIT:
|
||||||
{
|
{
|
||||||
LPNMTVDISPINFO ptvdi;
|
LPNMTVDISPINFO ptvdi;
|
||||||
/* cancel label edit for rootkeys */
|
/* cancel label edit for rootkeys */
|
||||||
ptvdi = (LPNMTVDISPINFO) lParam;
|
ptvdi = (LPNMTVDISPINFO) lParam;
|
||||||
if (!TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem) ||
|
if (!TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem) ||
|
||||||
!TreeView_GetParent(pChildWnd->hTreeWnd, TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem)))
|
!TreeView_GetParent(pChildWnd->hTreeWnd, TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TVN_ENDLABELEDIT:
|
case TVN_ENDLABELEDIT:
|
||||||
{
|
{
|
||||||
LPCTSTR keyPath;
|
LPCTSTR keyPath;
|
||||||
HKEY hRootKey;
|
HKEY hRootKey;
|
||||||
HKEY hKey = NULL;
|
HKEY hKey = NULL;
|
||||||
LPNMTVDISPINFO ptvdi;
|
LPNMTVDISPINFO ptvdi;
|
||||||
LONG lResult = TRUE;
|
LONG lResult = TRUE;
|
||||||
TCHAR szBuffer[MAX_PATH];
|
TCHAR szBuffer[MAX_PATH];
|
||||||
|
|
||||||
ptvdi = (LPNMTVDISPINFO) lParam;
|
ptvdi = (LPNMTVDISPINFO) lParam;
|
||||||
if (ptvdi->item.pszText)
|
if (ptvdi->item.pszText)
|
||||||
{
|
{
|
||||||
keyPath = GetItemPath(pChildWnd->hTreeWnd, TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey);
|
keyPath = GetItemPath(pChildWnd->hTreeWnd, TreeView_GetParent(pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey);
|
||||||
_sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("%s\\%s"), keyPath, ptvdi->item.pszText);
|
_sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("%s\\%s"), keyPath, ptvdi->item.pszText);
|
||||||
keyPath = GetItemPath(pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey);
|
keyPath = GetItemPath(pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey);
|
||||||
if (RegOpenKeyEx(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
if (RegOpenKeyEx(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
lResult = FALSE;
|
lResult = FALSE;
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
(void)TreeView_EditLabel(pChildWnd->hTreeWnd, ptvdi->item.hItem);
|
(void)TreeView_EditLabel(pChildWnd->hTreeWnd, ptvdi->item.hItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS)
|
if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS)
|
||||||
lResult = FALSE;
|
lResult = FALSE;
|
||||||
}
|
}
|
||||||
return lResult;
|
return lResult;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if ((int)wParam == LIST_WINDOW)
|
if ((int)wParam == LIST_WINDOW)
|
||||||
{
|
{
|
||||||
switch (((LPNMHDR)lParam)->code) {
|
switch (((LPNMHDR)lParam)->code)
|
||||||
case NM_SETFOCUS:
|
{
|
||||||
pChildWnd->nFocusPanel = 1;
|
case NM_SETFOCUS:
|
||||||
break;
|
pChildWnd->nFocusPanel = 1;
|
||||||
default:
|
break;
|
||||||
if(!ListWndNotifyProc(pChildWnd->hListWnd, wParam, lParam, &Result))
|
default:
|
||||||
{
|
if(!ListWndNotifyProc(pChildWnd->hListWnd, wParam, lParam, &Result))
|
||||||
goto def;
|
{
|
||||||
}
|
goto def;
|
||||||
return Result;
|
}
|
||||||
break;
|
return Result;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CONTEXTMENU:
|
case WM_CONTEXTMENU:
|
||||||
{
|
{
|
||||||
POINT pt;
|
POINT pt;
|
||||||
if((HWND)wParam == pChildWnd->hListWnd)
|
if((HWND)wParam == pChildWnd->hListWnd)
|
||||||
{
|
|
||||||
int i, cnt;
|
|
||||||
BOOL IsDefault;
|
|
||||||
pt.x = (short) LOWORD(lParam);
|
|
||||||
pt.y = (short) HIWORD(lParam);
|
|
||||||
cnt = ListView_GetSelectedCount(pChildWnd->hListWnd);
|
|
||||||
i = ListView_GetNextItem(pChildWnd->hListWnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
|
|
||||||
if (pt.x == -1 && pt.y == -1)
|
|
||||||
{
|
{
|
||||||
RECT rc;
|
int i, cnt;
|
||||||
if (i != -1)
|
BOOL IsDefault;
|
||||||
|
pt.x = (short) LOWORD(lParam);
|
||||||
|
pt.y = (short) HIWORD(lParam);
|
||||||
|
cnt = ListView_GetSelectedCount(pChildWnd->hListWnd);
|
||||||
|
i = ListView_GetNextItem(pChildWnd->hListWnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
|
||||||
|
if (pt.x == -1 && pt.y == -1)
|
||||||
{
|
{
|
||||||
rc.left = LVIR_BOUNDS;
|
RECT rc;
|
||||||
SendMessage(pChildWnd->hListWnd, LVM_GETITEMRECT, i, (LPARAM) &rc);
|
if (i != -1)
|
||||||
pt.x = rc.left + 8;
|
{
|
||||||
pt.y = rc.top + 8;
|
rc.left = LVIR_BOUNDS;
|
||||||
|
SendMessage(pChildWnd->hListWnd, LVM_GETITEMRECT, i, (LPARAM) &rc);
|
||||||
|
pt.x = rc.left + 8;
|
||||||
|
pt.y = rc.top + 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pt.x = pt.y = 0;
|
||||||
|
ClientToScreen(pChildWnd->hListWnd, &pt);
|
||||||
|
}
|
||||||
|
if(i == -1)
|
||||||
|
{
|
||||||
|
TrackPopupMenu(GetSubMenu(hPopupMenus, PM_NEW), TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pt.x = pt.y = 0;
|
|
||||||
ClientToScreen(pChildWnd->hListWnd, &pt);
|
|
||||||
}
|
|
||||||
if(i == -1)
|
|
||||||
{
|
|
||||||
TrackPopupMenu(GetSubMenu(hPopupMenus, PM_NEW), TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HMENU mnu = GetSubMenu(hPopupMenus, PM_MODIFYVALUE);
|
|
||||||
SetMenuDefaultItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND);
|
|
||||||
IsDefault = IsDefaultValue(pChildWnd->hListWnd, i);
|
|
||||||
if(cnt == 1)
|
|
||||||
EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | (IsDefault ? MF_DISABLED | MF_GRAYED : MF_ENABLED));
|
|
||||||
else
|
|
||||||
EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
|
||||||
EnableMenuItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED));
|
|
||||||
EnableMenuItem(mnu, ID_EDIT_MODIFY_BIN, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED));
|
|
||||||
|
|
||||||
TrackPopupMenu(mnu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((HWND)wParam == pChildWnd->hTreeWnd)
|
|
||||||
{
|
|
||||||
TVHITTESTINFO hti;
|
|
||||||
HMENU hContextMenu;
|
|
||||||
TVITEM item;
|
|
||||||
MENUITEMINFO mii;
|
|
||||||
TCHAR resource[256];
|
|
||||||
TCHAR buffer[256];
|
|
||||||
LPTSTR s;
|
|
||||||
LPCTSTR keyPath;
|
|
||||||
HKEY hRootKey;
|
|
||||||
int iLastPos;
|
|
||||||
WORD wID;
|
|
||||||
|
|
||||||
pt.x = (short) LOWORD(lParam);
|
|
||||||
pt.y = (short) HIWORD(lParam);
|
|
||||||
|
|
||||||
if (pt.x == -1 && pt.y == -1)
|
|
||||||
{
|
|
||||||
RECT rc;
|
|
||||||
hti.hItem = TreeView_GetSelection(pChildWnd->hTreeWnd);
|
|
||||||
if (hti.hItem != NULL)
|
|
||||||
{
|
{
|
||||||
TreeView_GetItemRect(pChildWnd->hTreeWnd, hti.hItem, &rc, TRUE);
|
HMENU mnu = GetSubMenu(hPopupMenus, PM_MODIFYVALUE);
|
||||||
pt.x = rc.left + 8;
|
SetMenuDefaultItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND);
|
||||||
pt.y = rc.top + 8;
|
IsDefault = IsDefaultValue(pChildWnd->hListWnd, i);
|
||||||
ClientToScreen(pChildWnd->hTreeWnd, &pt);
|
if(cnt == 1)
|
||||||
hti.flags = TVHT_ONITEM;
|
EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | (IsDefault ? MF_DISABLED | MF_GRAYED : MF_ENABLED));
|
||||||
|
else
|
||||||
|
EnableMenuItem(mnu, ID_EDIT_RENAME, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
||||||
|
EnableMenuItem(mnu, ID_EDIT_MODIFY, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED));
|
||||||
|
EnableMenuItem(mnu, ID_EDIT_MODIFY_BIN, MF_BYCOMMAND | (cnt == 1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED));
|
||||||
|
|
||||||
|
TrackPopupMenu(mnu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((HWND)wParam == pChildWnd->hTreeWnd)
|
||||||
|
{
|
||||||
|
TVHITTESTINFO hti;
|
||||||
|
HMENU hContextMenu;
|
||||||
|
TVITEM item;
|
||||||
|
MENUITEMINFO mii;
|
||||||
|
TCHAR resource[256];
|
||||||
|
TCHAR buffer[256];
|
||||||
|
LPTSTR s;
|
||||||
|
LPCTSTR keyPath;
|
||||||
|
HKEY hRootKey;
|
||||||
|
int iLastPos;
|
||||||
|
WORD wID;
|
||||||
|
|
||||||
|
pt.x = (short) LOWORD(lParam);
|
||||||
|
pt.y = (short) HIWORD(lParam);
|
||||||
|
|
||||||
|
if (pt.x == -1 && pt.y == -1)
|
||||||
|
{
|
||||||
|
RECT rc;
|
||||||
|
hti.hItem = TreeView_GetSelection(pChildWnd->hTreeWnd);
|
||||||
|
if (hti.hItem != NULL)
|
||||||
|
{
|
||||||
|
TreeView_GetItemRect(pChildWnd->hTreeWnd, hti.hItem, &rc, TRUE);
|
||||||
|
pt.x = rc.left + 8;
|
||||||
|
pt.y = rc.top + 8;
|
||||||
|
ClientToScreen(pChildWnd->hTreeWnd, &pt);
|
||||||
|
hti.flags = TVHT_ONITEM;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
hti.flags = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
hti.flags = 0;
|
{
|
||||||
|
hti.pt.x = pt.x;
|
||||||
|
hti.pt.y = pt.y;
|
||||||
|
ScreenToClient(pChildWnd->hTreeWnd, &hti.pt);
|
||||||
|
(void)TreeView_HitTest(pChildWnd->hTreeWnd, &hti);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hti.flags & TVHT_ONITEM)
|
||||||
|
{
|
||||||
|
hContextMenu = GetSubMenu(hPopupMenus, PM_TREECONTEXT);
|
||||||
|
(void)TreeView_SelectItem(pChildWnd->hTreeWnd, hti.hItem);
|
||||||
|
|
||||||
|
memset(&item, 0, sizeof(item));
|
||||||
|
item.mask = TVIF_STATE | TVIF_CHILDREN;
|
||||||
|
item.hItem = hti.hItem;
|
||||||
|
(void)TreeView_GetItem(pChildWnd->hTreeWnd, &item);
|
||||||
|
|
||||||
|
/* Set the Expand/Collapse menu item appropriately */
|
||||||
|
LoadString(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, sizeof(buffer) / sizeof(buffer[0]));
|
||||||
|
memset(&mii, 0, sizeof(mii));
|
||||||
|
mii.cbSize = sizeof(mii);
|
||||||
|
mii.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID;
|
||||||
|
mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED;
|
||||||
|
mii.wID = (item.state & TVIS_EXPANDED) ? ID_TREE_COLLAPSEBRANCH : ID_TREE_EXPANDBRANCH;
|
||||||
|
mii.dwTypeData = (LPTSTR) buffer;
|
||||||
|
SetMenuItemInfo(hContextMenu, 0, TRUE, &mii);
|
||||||
|
|
||||||
|
/* Remove any existing suggestions */
|
||||||
|
memset(&mii, 0, sizeof(mii));
|
||||||
|
mii.cbSize = sizeof(mii);
|
||||||
|
mii.fMask = MIIM_ID;
|
||||||
|
GetMenuItemInfo(hContextMenu, GetMenuItemCount(hContextMenu) - 1, TRUE, &mii);
|
||||||
|
if ((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX))
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
iLastPos = GetMenuItemCount(hContextMenu) - 1;
|
||||||
|
GetMenuItemInfo(hContextMenu, iLastPos, TRUE, &mii);
|
||||||
|
RemoveMenu(hContextMenu, iLastPos, MF_BYPOSITION);
|
||||||
|
}
|
||||||
|
while((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Come up with suggestions */
|
||||||
|
keyPath = GetItemPath(pChildWnd->hTreeWnd, NULL, &hRootKey);
|
||||||
|
SuggestKeys(hRootKey, keyPath, Suggestions, sizeof(Suggestions) / sizeof(Suggestions[0]));
|
||||||
|
if (Suggestions[0])
|
||||||
|
{
|
||||||
|
AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL);
|
||||||
|
|
||||||
|
LoadString(hInst, IDS_GOTO_SUGGESTED_KEY, resource, sizeof(resource) / sizeof(resource[0]));
|
||||||
|
|
||||||
|
s = Suggestions;
|
||||||
|
wID = ID_TREE_SUGGESTION_MIN;
|
||||||
|
while(*s && (wID <= ID_TREE_SUGGESTION_MAX))
|
||||||
|
{
|
||||||
|
_sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), resource, s);
|
||||||
|
|
||||||
|
memset(&mii, 0, sizeof(mii));
|
||||||
|
mii.cbSize = sizeof(mii);
|
||||||
|
mii.fMask = MIIM_STRING | MIIM_ID;
|
||||||
|
mii.wID = wID++;
|
||||||
|
mii.dwTypeData = buffer;
|
||||||
|
InsertMenuItem(hContextMenu, GetMenuItemCount(hContextMenu), TRUE, &mii);
|
||||||
|
|
||||||
|
s += _tcslen(s) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, pChildWnd->hWnd, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
{
|
|
||||||
hti.pt.x = pt.x;
|
|
||||||
hti.pt.y = pt.y;
|
|
||||||
ScreenToClient(pChildWnd->hTreeWnd, &hti.pt);
|
|
||||||
(void)TreeView_HitTest(pChildWnd->hTreeWnd, &hti);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hti.flags & TVHT_ONITEM)
|
|
||||||
{
|
|
||||||
hContextMenu = GetSubMenu(hPopupMenus, PM_TREECONTEXT);
|
|
||||||
(void)TreeView_SelectItem(pChildWnd->hTreeWnd, hti.hItem);
|
|
||||||
|
|
||||||
memset(&item, 0, sizeof(item));
|
|
||||||
item.mask = TVIF_STATE | TVIF_CHILDREN;
|
|
||||||
item.hItem = hti.hItem;
|
|
||||||
(void)TreeView_GetItem(pChildWnd->hTreeWnd, &item);
|
|
||||||
|
|
||||||
/* Set the Expand/Collapse menu item appropriately */
|
|
||||||
LoadString(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, sizeof(buffer) / sizeof(buffer[0]));
|
|
||||||
memset(&mii, 0, sizeof(mii));
|
|
||||||
mii.cbSize = sizeof(mii);
|
|
||||||
mii.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID;
|
|
||||||
mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED;
|
|
||||||
mii.wID = (item.state & TVIS_EXPANDED) ? ID_TREE_COLLAPSEBRANCH : ID_TREE_EXPANDBRANCH;
|
|
||||||
mii.dwTypeData = (LPTSTR) buffer;
|
|
||||||
SetMenuItemInfo(hContextMenu, 0, TRUE, &mii);
|
|
||||||
|
|
||||||
/* Remove any existing suggestions */
|
|
||||||
memset(&mii, 0, sizeof(mii));
|
|
||||||
mii.cbSize = sizeof(mii);
|
|
||||||
mii.fMask = MIIM_ID;
|
|
||||||
GetMenuItemInfo(hContextMenu, GetMenuItemCount(hContextMenu) - 1, TRUE, &mii);
|
|
||||||
if ((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX))
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
iLastPos = GetMenuItemCount(hContextMenu) - 1;
|
|
||||||
GetMenuItemInfo(hContextMenu, iLastPos, TRUE, &mii);
|
|
||||||
RemoveMenu(hContextMenu, iLastPos, MF_BYPOSITION);
|
|
||||||
}
|
|
||||||
while((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Come up with suggestions */
|
|
||||||
keyPath = GetItemPath(pChildWnd->hTreeWnd, NULL, &hRootKey);
|
|
||||||
SuggestKeys(hRootKey, keyPath, Suggestions, sizeof(Suggestions) / sizeof(Suggestions[0]));
|
|
||||||
if (Suggestions[0])
|
|
||||||
{
|
|
||||||
AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL);
|
|
||||||
|
|
||||||
LoadString(hInst, IDS_GOTO_SUGGESTED_KEY, resource, sizeof(resource) / sizeof(resource[0]));
|
|
||||||
|
|
||||||
s = Suggestions;
|
|
||||||
wID = ID_TREE_SUGGESTION_MIN;
|
|
||||||
while(*s && (wID <= ID_TREE_SUGGESTION_MAX))
|
|
||||||
{
|
|
||||||
_sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), resource, s);
|
|
||||||
|
|
||||||
memset(&mii, 0, sizeof(mii));
|
|
||||||
mii.cbSize = sizeof(mii);
|
|
||||||
mii.fMask = MIIM_STRING | MIIM_ID;
|
|
||||||
mii.wID = wID++;
|
|
||||||
mii.dwTypeData = buffer;
|
|
||||||
InsertMenuItem(hContextMenu, GetMenuItemCount(hContextMenu), TRUE, &mii);
|
|
||||||
|
|
||||||
s += _tcslen(s) + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, pChildWnd->hWnd, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
if (wParam != SIZE_MINIMIZED && pChildWnd != NULL) {
|
if (wParam != SIZE_MINIMIZED && pChildWnd != NULL)
|
||||||
|
{
|
||||||
ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam));
|
ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam));
|
||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default: def:
|
default:
|
||||||
|
def:
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -123,41 +123,41 @@ ClbWndProc(IN HWND hwnd,
|
||||||
LRESULT Ret = 0;
|
LRESULT Ret = 0;
|
||||||
|
|
||||||
DPRINT1("ClbWndProc(0x%p, 0x%x, 0x%p, 0x%p)\n", hwnd, uMsg, wParam, lParam);
|
DPRINT1("ClbWndProc(0x%p, 0x%x, 0x%p, 0x%p)\n", hwnd, uMsg, wParam, lParam);
|
||||||
|
|
||||||
PrivData = (PCLB_PRIVATEDATA)GetWindowLongPtr(hwnd,
|
PrivData = (PCLB_PRIVATEDATA)GetWindowLongPtr(hwnd,
|
||||||
0);
|
0);
|
||||||
if (PrivData == NULL && uMsg != WM_CREATE)
|
if (PrivData == NULL && uMsg != WM_CREATE)
|
||||||
{
|
{
|
||||||
goto HandleDefMsg;
|
goto HandleDefMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
PrivData = HeapAlloc(GetProcessHeap(),
|
PrivData = HeapAlloc(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
sizeof(CLB_PRIVATEDATA));
|
sizeof(CLB_PRIVATEDATA));
|
||||||
if (PrivData == NULL)
|
if (PrivData == NULL)
|
||||||
{
|
{
|
||||||
Ret = (LRESULT)-1;
|
Ret = (LRESULT)-1;
|
||||||
break;
|
|
||||||
}
|
|
||||||
PrivData->hwnd = hwnd;
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
PrivData->hwnd = hwnd;
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
HeapFree(GetProcessHeap(),
|
HeapFree(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
PrivData);
|
PrivData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HandleDefMsg:
|
HandleDefMsg:
|
||||||
Ret = DefWindowProc(hwnd,
|
Ret = DefWindowProc(hwnd,
|
||||||
uMsg,
|
uMsg,
|
||||||
wParam,
|
wParam,
|
||||||
lParam);
|
lParam);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
|
@ -171,32 +171,32 @@ ClbpStyleDlgProc(IN HWND hwndDlg,
|
||||||
IN LPARAM lParam)
|
IN LPARAM lParam)
|
||||||
{
|
{
|
||||||
INT_PTR Ret = FALSE;
|
INT_PTR Ret = FALSE;
|
||||||
|
|
||||||
DPRINT1("ClbpStyleDlgProc(0x%p, 0x%x, 0x%p, 0x%p)\n", hwndDlg, uMsg, wParam, lParam);
|
DPRINT1("ClbpStyleDlgProc(0x%p, 0x%x, 0x%p, 0x%p)\n", hwndDlg, uMsg, wParam, lParam);
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case IDOK:
|
case IDOK:
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
EndDialog(hwndDlg,
|
|
||||||
(INT_PTR)LOWORD(wParam));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_CLOSE:
|
|
||||||
EndDialog(hwndDlg,
|
EndDialog(hwndDlg,
|
||||||
IDCANCEL);
|
(INT_PTR)LOWORD(wParam));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_INITDIALOG:
|
case WM_CLOSE:
|
||||||
Ret = TRUE;
|
EndDialog(hwndDlg,
|
||||||
break;
|
IDCANCEL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
Ret = TRUE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ CustomControlInfoW(OUT LPCUSTOM_CONTROL_INFO CustomControlInfo OPTIONAL)
|
||||||
ClbClassName);
|
ClbClassName);
|
||||||
|
|
||||||
CustomControlInfo->Zero1 = 0;
|
CustomControlInfo->Zero1 = 0;
|
||||||
|
|
||||||
wcscpy(CustomControlInfo->ClassName2,
|
wcscpy(CustomControlInfo->ClassName2,
|
||||||
ClbClassName);
|
ClbClassName);
|
||||||
|
|
||||||
|
@ -240,15 +240,15 @@ CustomControlInfoW(OUT LPCUSTOM_CONTROL_INFO CustomControlInfo OPTIONAL)
|
||||||
|
|
||||||
CustomControlInfo->Zero2 = 0;
|
CustomControlInfo->Zero2 = 0;
|
||||||
CustomControlInfo->Zero3 = 0;
|
CustomControlInfo->Zero3 = 0;
|
||||||
|
|
||||||
CustomControlInfo->StylesCount = sizeof(ClbsSupportedStyles) / sizeof(ClbsSupportedStyles[0]);
|
CustomControlInfo->StylesCount = sizeof(ClbsSupportedStyles) / sizeof(ClbsSupportedStyles[0]);
|
||||||
CustomControlInfo->SupportedStyles = ClbsSupportedStyles;
|
CustomControlInfo->SupportedStyles = ClbsSupportedStyles;
|
||||||
|
|
||||||
wcscpy(CustomControlInfo->Columns,
|
wcscpy(CustomControlInfo->Columns,
|
||||||
ClbColumns);
|
ClbColumns);
|
||||||
|
|
||||||
CustomControlInfo->ClbStyleW = ClbStyleW;
|
CustomControlInfo->ClbStyleW = ClbStyleW;
|
||||||
|
|
||||||
CustomControlInfo->Zero4 = 0;
|
CustomControlInfo->Zero4 = 0;
|
||||||
CustomControlInfo->Zero5 = 0;
|
CustomControlInfo->Zero5 = 0;
|
||||||
CustomControlInfo->Zero6 = 0;
|
CustomControlInfo->Zero6 = 0;
|
||||||
|
@ -267,43 +267,43 @@ DllMain(IN HINSTANCE hinstDLL,
|
||||||
|
|
||||||
switch (dwReason)
|
switch (dwReason)
|
||||||
{
|
{
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
{
|
{
|
||||||
WNDCLASS ClbWndClass;
|
WNDCLASS ClbWndClass;
|
||||||
|
|
||||||
hDllInstance = hinstDLL;
|
hDllInstance = hinstDLL;
|
||||||
|
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
|
||||||
/* register the control's window class */
|
/* register the control's window class */
|
||||||
ClbWndClass.style = CS_GLOBALCLASS | CS_OWNDC;
|
ClbWndClass.style = CS_GLOBALCLASS | CS_OWNDC;
|
||||||
ClbWndClass.lpfnWndProc = ClbWndProc;
|
ClbWndClass.lpfnWndProc = ClbWndProc;
|
||||||
ClbWndClass.cbClsExtra = 0;
|
ClbWndClass.cbClsExtra = 0;
|
||||||
ClbWndClass.cbWndExtra = sizeof(PCLB_PRIVATEDATA);
|
ClbWndClass.cbWndExtra = sizeof(PCLB_PRIVATEDATA);
|
||||||
ClbWndClass.hInstance = hinstDLL,
|
ClbWndClass.hInstance = hinstDLL,
|
||||||
ClbWndClass.hIcon = NULL;
|
ClbWndClass.hIcon = NULL;
|
||||||
ClbWndClass.hCursor = LoadCursor(NULL,
|
ClbWndClass.hCursor = LoadCursor(NULL,
|
||||||
(LPWSTR)IDC_ARROW);
|
(LPWSTR)IDC_ARROW);
|
||||||
ClbWndClass.hbrBackground = NULL;
|
ClbWndClass.hbrBackground = NULL;
|
||||||
ClbWndClass.lpszMenuName = NULL;
|
ClbWndClass.lpszMenuName = NULL;
|
||||||
ClbWndClass.lpszClassName = ClbClassName;
|
ClbWndClass.lpszClassName = ClbClassName;
|
||||||
|
|
||||||
if (!RegisterClass(&ClbWndClass))
|
if (!RegisterClass(&ClbWndClass))
|
||||||
{
|
{
|
||||||
Ret = FALSE;
|
Ret = FALSE;
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
case DLL_THREAD_DETACH:
|
case DLL_THREAD_DETACH:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
UnregisterClass(ClbClassName,
|
UnregisterClass(ClbClassName,
|
||||||
hinstDLL);
|
hinstDLL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
typedef enum _EDIT_MODE
|
typedef enum _EDIT_MODE
|
||||||
{
|
{
|
||||||
EDIT_MODE_DEC,
|
EDIT_MODE_DEC,
|
||||||
EDIT_MODE_HEX
|
EDIT_MODE_HEX
|
||||||
} EDIT_MODE;
|
} EDIT_MODE;
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,17 +96,18 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
UNREFERENCED_PARAMETER(lParam);
|
||||||
|
|
||||||
switch(uMsg) {
|
switch(uMsg)
|
||||||
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
if(editValueName && _tcscmp(editValueName, _T("")))
|
if(editValueName && _tcscmp(editValueName, _T("")))
|
||||||
{
|
{
|
||||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
|
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TCHAR buffer[255];
|
TCHAR buffer[255];
|
||||||
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
||||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
|
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
|
||||||
}
|
}
|
||||||
SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
|
SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
|
||||||
SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA));
|
SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA));
|
||||||
|
@ -140,8 +141,8 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (stringValueData)
|
if (stringValueData)
|
||||||
*stringValueData = 0;
|
*stringValueData = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndDialog(hwndDlg, IDOK);
|
EndDialog(hwndDlg, IDOK);
|
||||||
|
@ -163,17 +164,18 @@ INT_PTR CALLBACK modify_multi_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPa
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
UNREFERENCED_PARAMETER(lParam);
|
||||||
|
|
||||||
switch(uMsg) {
|
switch(uMsg)
|
||||||
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
if(editValueName && _tcscmp(editValueName, _T("")))
|
if(editValueName && _tcscmp(editValueName, _T("")))
|
||||||
{
|
{
|
||||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
|
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TCHAR buffer[255];
|
TCHAR buffer[255];
|
||||||
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
||||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
|
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
|
||||||
}
|
}
|
||||||
SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
|
SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
|
||||||
SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA));
|
SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA));
|
||||||
|
@ -207,8 +209,8 @@ INT_PTR CALLBACK modify_multi_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPa
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (stringValueData)
|
if (stringValueData)
|
||||||
*stringValueData = 0;
|
*stringValueData = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndDialog(hwndDlg, IDOK);
|
EndDialog(hwndDlg, IDOK);
|
||||||
|
@ -274,7 +276,8 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
UNREFERENCED_PARAMETER(lParam);
|
||||||
|
|
||||||
switch(uMsg) {
|
switch(uMsg)
|
||||||
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
dwordEditMode = EDIT_MODE_HEX;
|
dwordEditMode = EDIT_MODE_HEX;
|
||||||
|
|
||||||
|
@ -290,9 +293,9 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TCHAR buffer[255];
|
TCHAR buffer[255];
|
||||||
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
||||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
|
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
|
||||||
}
|
}
|
||||||
CheckRadioButton (hwndDlg, IDC_FORMAT_HEX, IDC_FORMAT_DEC, IDC_FORMAT_HEX);
|
CheckRadioButton (hwndDlg, IDC_FORMAT_HEX, IDC_FORMAT_DEC, IDC_FORMAT_HEX);
|
||||||
_stprintf (ValueString, _T("%lx"), dwordValueData);
|
_stprintf (ValueString, _T("%lx"), dwordValueData);
|
||||||
|
@ -359,8 +362,8 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EndDialog(hwndDlg, IDCANCEL);
|
EndDialog(hwndDlg, IDCANCEL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndDialog(hwndDlg, IDOK);
|
EndDialog(hwndDlg, IDOK);
|
||||||
|
@ -382,17 +385,18 @@ INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
UNREFERENCED_PARAMETER(lParam);
|
||||||
|
|
||||||
switch(uMsg) {
|
switch(uMsg)
|
||||||
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
if(editValueName && _tcscmp(editValueName, _T("")))
|
if(editValueName && _tcscmp(editValueName, _T("")))
|
||||||
{
|
{
|
||||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
|
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TCHAR buffer[255];
|
TCHAR buffer[255];
|
||||||
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
||||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
|
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
|
||||||
}
|
}
|
||||||
hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA);
|
hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA);
|
||||||
HexEdit_LoadBuffer(hwndValue, binValueData, valueDataLen);
|
HexEdit_LoadBuffer(hwndValue, binValueData, valueDataLen);
|
||||||
|
@ -408,9 +412,9 @@ INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
|
||||||
{
|
{
|
||||||
len = (UINT) HexEdit_GetBufferSize(hwndValue);
|
len = (UINT) HexEdit_GetBufferSize(hwndValue);
|
||||||
if (len > 0 && binValueData)
|
if (len > 0 && binValueData)
|
||||||
binValueData = HeapReAlloc(GetProcessHeap(), 0, binValueData, len);
|
binValueData = HeapReAlloc(GetProcessHeap(), 0, binValueData, len);
|
||||||
else
|
else
|
||||||
binValueData = HeapAlloc(GetProcessHeap(), 0, len + 1);
|
binValueData = HeapAlloc(GetProcessHeap(), 0, len + 1);
|
||||||
HexEdit_CopyBuffer(hwndValue, binValueData, len);
|
HexEdit_CopyBuffer(hwndValue, binValueData, len);
|
||||||
valueDataLen = len;
|
valueDataLen = len;
|
||||||
}
|
}
|
||||||
|
@ -439,11 +443,11 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
|
||||||
lRet = RegQueryValueEx(hKey, valueName, 0, &type, 0, &valueDataLen);
|
lRet = RegQueryValueEx(hKey, valueName, 0, &type, 0, &valueDataLen);
|
||||||
if (lRet != ERROR_SUCCESS && (!_tcscmp(valueName, _T("")) || valueName == NULL))
|
if (lRet != ERROR_SUCCESS && (!_tcscmp(valueName, _T("")) || valueName == NULL))
|
||||||
{
|
{
|
||||||
lRet = ERROR_SUCCESS; /* Allow editing of (Default) values which don't exist */
|
lRet = ERROR_SUCCESS; /* Allow editing of (Default) values which don't exist */
|
||||||
type = REG_SZ;
|
type = REG_SZ;
|
||||||
valueDataLen = 0;
|
valueDataLen = 0;
|
||||||
stringValueData = NULL;
|
stringValueData = NULL;
|
||||||
binValueData = NULL;
|
binValueData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lRet != ERROR_SUCCESS)
|
if (lRet != ERROR_SUCCESS)
|
||||||
|
@ -494,7 +498,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
|
||||||
size_t llen, listlen, nl_len;
|
size_t llen, listlen, nl_len;
|
||||||
LPTSTR src, lines = NULL;
|
LPTSTR src, lines = NULL;
|
||||||
|
|
||||||
if (!(stringValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen)))
|
if (!(stringValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen)))
|
||||||
{
|
{
|
||||||
error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen);
|
error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen);
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -506,7 +510,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert \0 to \r\n */
|
/* convert \0 to \r\n */
|
||||||
src = stringValueData;
|
src = stringValueData;
|
||||||
nl_len = _tcslen(_T("\r\n")) * sizeof(TCHAR);
|
nl_len = _tcslen(_T("\r\n")) * sizeof(TCHAR);
|
||||||
listlen = sizeof(TCHAR);
|
listlen = sizeof(TCHAR);
|
||||||
|
@ -515,12 +519,12 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
|
||||||
{
|
{
|
||||||
llen = _tcslen(src);
|
llen = _tcslen(src);
|
||||||
if(llen == 0)
|
if(llen == 0)
|
||||||
break;
|
break;
|
||||||
listlen += (llen * sizeof(TCHAR)) + nl_len;
|
listlen += (llen * sizeof(TCHAR)) + nl_len;
|
||||||
lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, listlen);
|
lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, listlen);
|
||||||
_tcscat(lines, src);
|
_tcscat(lines, src);
|
||||||
_tcscat(lines, _T("\r\n"));
|
_tcscat(lines, _T("\r\n"));
|
||||||
src += llen + 1;
|
src += llen + 1;
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, stringValueData);
|
HeapFree(GetProcessHeap(), 0, stringValueData);
|
||||||
stringValueData = lines;
|
stringValueData = lines;
|
||||||
|
@ -552,7 +556,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
|
||||||
if(nl == src)
|
if(nl == src)
|
||||||
{
|
{
|
||||||
EmptyLines = TRUE;
|
EmptyLines = TRUE;
|
||||||
src = nl + c_nl;
|
src = nl + c_nl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -562,7 +566,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
|
||||||
}
|
}
|
||||||
if(linechars > 0)
|
if(linechars > 0)
|
||||||
{
|
{
|
||||||
buflen += ((linechars + 1) * sizeof(TCHAR));
|
buflen += ((linechars + 1) * sizeof(TCHAR));
|
||||||
lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, buflen);
|
lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, buflen);
|
||||||
memcpy((lines + dest), src, linechars * sizeof(TCHAR));
|
memcpy((lines + dest), src, linechars * sizeof(TCHAR));
|
||||||
dest += linechars;
|
dest += linechars;
|
||||||
|
@ -581,8 +585,8 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
|
||||||
warning(hwnd, IDS_MULTI_SZ_EMPTY_STRING);
|
warning(hwnd, IDS_MULTI_SZ_EMPTY_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
lRet = RegSetValueEx(hKey, valueName, 0, type, (LPBYTE)lines, (DWORD) buflen);
|
lRet = RegSetValueEx(hKey, valueName, 0, type, (LPBYTE)lines, (DWORD) buflen);
|
||||||
HeapFree(GetProcessHeap(), 0, lines);
|
HeapFree(GetProcessHeap(), 0, lines);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -614,44 +618,44 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
|
||||||
LPWSTR u_valuename;
|
LPWSTR u_valuename;
|
||||||
int len_vname = lstrlen(valueName);
|
int len_vname = lstrlen(valueName);
|
||||||
|
|
||||||
if(len_vname > 0)
|
if(len_vname > 0)
|
||||||
{
|
{
|
||||||
if(!(u_valuename = HeapAlloc(GetProcessHeap(), 0, (len_vname + 1) * sizeof(WCHAR))))
|
if(!(u_valuename = HeapAlloc(GetProcessHeap(), 0, (len_vname + 1) * sizeof(WCHAR))))
|
||||||
{
|
{
|
||||||
error(hwnd, IDS_TOO_BIG_VALUE, len_vname);
|
error(hwnd, IDS_TOO_BIG_VALUE, len_vname);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* convert the ansi value name to an unicode string */
|
/* convert the ansi value name to an unicode string */
|
||||||
MultiByteToWideChar(CP_ACP, 0, valueName, -1, u_valuename, len_vname + 1);
|
MultiByteToWideChar(CP_ACP, 0, valueName, -1, u_valuename, len_vname + 1);
|
||||||
valueDataLen *= sizeof(WCHAR);
|
valueDataLen *= sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
u_valuename = L"";
|
u_valuename = L"";
|
||||||
#endif
|
#endif
|
||||||
if(valueDataLen > 0)
|
if(valueDataLen > 0)
|
||||||
{
|
{
|
||||||
if(!(binValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen + 1)))
|
if(!(binValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen + 1)))
|
||||||
{
|
{
|
||||||
error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen);
|
error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force to use the unicode version, so editing strings in binary mode is correct */
|
/* force to use the unicode version, so editing strings in binary mode is correct */
|
||||||
lRet = RegQueryValueExW(hKey,
|
lRet = RegQueryValueExW(hKey,
|
||||||
#ifndef UNICODE
|
#ifndef UNICODE
|
||||||
u_valuename,
|
u_valuename,
|
||||||
#else
|
#else
|
||||||
valueName,
|
valueName,
|
||||||
#endif
|
#endif
|
||||||
0, 0, (LPBYTE)binValueData, &valueDataLen);
|
0, 0, (LPBYTE)binValueData, &valueDataLen);
|
||||||
if (lRet != ERROR_SUCCESS)
|
if (lRet != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, binValueData);
|
HeapFree(GetProcessHeap(), 0, binValueData);
|
||||||
#ifndef UNICODE
|
#ifndef UNICODE
|
||||||
if(len_vname > 0)
|
if(len_vname > 0)
|
||||||
HeapFree(GetProcessHeap(), 0, u_valuename);
|
HeapFree(GetProcessHeap(), 0, u_valuename);
|
||||||
#endif
|
#endif
|
||||||
error(hwnd, IDS_BAD_VALUE, valueName);
|
error(hwnd, IDS_BAD_VALUE, valueName);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,22 +666,22 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
|
||||||
|
|
||||||
if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_BIN_DATA), hwnd, modify_binary_dlgproc) == IDOK)
|
if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_BIN_DATA), hwnd, modify_binary_dlgproc) == IDOK)
|
||||||
{
|
{
|
||||||
/* force to use the unicode version, so editing strings in binary mode is correct */
|
/* force to use the unicode version, so editing strings in binary mode is correct */
|
||||||
lRet = RegSetValueExW(hKey,
|
lRet = RegSetValueExW(hKey,
|
||||||
#ifndef UNICODE
|
#ifndef UNICODE
|
||||||
u_valuename,
|
u_valuename,
|
||||||
#else
|
#else
|
||||||
valueName,
|
valueName,
|
||||||
#endif
|
#endif
|
||||||
0, type, (LPBYTE)binValueData, valueDataLen);
|
0, type, (LPBYTE)binValueData, valueDataLen);
|
||||||
if (lRet == ERROR_SUCCESS)
|
if (lRet == ERROR_SUCCESS)
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
if(binValueData != NULL)
|
if(binValueData != NULL)
|
||||||
HeapFree(GetProcessHeap(), 0, binValueData);
|
HeapFree(GetProcessHeap(), 0, binValueData);
|
||||||
#ifndef UNICODE
|
#ifndef UNICODE
|
||||||
if(len_vname > 0)
|
if(len_vname > 0)
|
||||||
HeapFree(GetProcessHeap(), 0, u_valuename);
|
HeapFree(GetProcessHeap(), 0, u_valuename);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -717,7 +721,7 @@ static LONG CopyKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR l
|
||||||
|
|
||||||
/* create the destination subkey */
|
/* create the destination subkey */
|
||||||
lResult = RegCreateKeyEx(hDestKey, lpDestSubKey, 0, NULL, 0, KEY_WRITE, NULL,
|
lResult = RegCreateKeyEx(hDestKey, lpDestSubKey, 0, NULL, 0, KEY_WRITE, NULL,
|
||||||
&hDestSubKey, &dwDisposition);
|
&hDestSubKey, &dwDisposition);
|
||||||
if (lResult)
|
if (lResult)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
@ -786,9 +790,10 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath)
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
|
||||||
lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_READ|KEY_SET_VALUE, &hKey);
|
lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_READ|KEY_SET_VALUE, &hKey);
|
||||||
if (lRet != ERROR_SUCCESS) {
|
if (lRet != ERROR_SUCCESS)
|
||||||
error_code_messagebox(hwnd, lRet);
|
{
|
||||||
return FALSE;
|
error_code_messagebox(hwnd, lRet);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadString(hInst, IDS_QUERY_DELETE_KEY_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR));
|
LoadString(hInst, IDS_QUERY_DELETE_KEY_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR));
|
||||||
|
@ -798,9 +803,10 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
lRet = SHDeleteKey(hKeyRoot, keyPath);
|
lRet = SHDeleteKey(hKeyRoot, keyPath);
|
||||||
if (lRet != ERROR_SUCCESS) {
|
if (lRet != ERROR_SUCCESS)
|
||||||
error(hwnd, IDS_BAD_KEY, keyPath);
|
{
|
||||||
goto done;
|
error(hwnd, IDS_BAD_KEY, keyPath);
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -101,10 +101,10 @@ CompareData(
|
||||||
{
|
{
|
||||||
if (s_dwFlags & RSF_MATCHCASE)
|
if (s_dwFlags & RSF_MATCHCASE)
|
||||||
return 2 == CompareString(LOCALE_SYSTEM_DEFAULT, 0,
|
return 2 == CompareString(LOCALE_SYSTEM_DEFAULT, 0,
|
||||||
psz1, cch1, psz2, cch2);
|
psz1, cch1, psz2, cch2);
|
||||||
else
|
else
|
||||||
return 2 == CompareString(LOCALE_SYSTEM_DEFAULT,
|
return 2 == CompareString(LOCALE_SYSTEM_DEFAULT,
|
||||||
NORM_IGNORECASE, psz1, cch1, psz2, cch2);
|
NORM_IGNORECASE, psz1, cch1, psz2, cch2);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i <= cch1 - cch2; i++)
|
for(i = 0; i <= cch1 - cch2; i++)
|
||||||
|
@ -112,13 +112,13 @@ CompareData(
|
||||||
if (s_dwFlags & RSF_MATCHCASE)
|
if (s_dwFlags & RSF_MATCHCASE)
|
||||||
{
|
{
|
||||||
if (2 == CompareString(LOCALE_SYSTEM_DEFAULT, 0,
|
if (2 == CompareString(LOCALE_SYSTEM_DEFAULT, 0,
|
||||||
psz1 + i, cch2, psz2, cch2))
|
psz1 + i, cch2, psz2, cch2))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (2 == CompareString(LOCALE_SYSTEM_DEFAULT,
|
if (2 == CompareString(LOCALE_SYSTEM_DEFAULT,
|
||||||
NORM_IGNORECASE, psz1 + i, cch2, psz2, cch2))
|
NORM_IGNORECASE, psz1 + i, cch2, psz2, cch2))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ int compare(const void *x, const void *y)
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL RegFindRecurse(
|
BOOL RegFindRecurse(
|
||||||
HKEY hKey,
|
HKEY hKey,
|
||||||
LPCTSTR pszSubKey,
|
LPCTSTR pszSubKey,
|
||||||
LPCTSTR pszValueName,
|
LPCTSTR pszValueName,
|
||||||
LPTSTR *ppszFoundSubKey,
|
LPTSTR *ppszFoundSubKey,
|
||||||
|
@ -162,7 +162,7 @@ BOOL RegFindRecurse(
|
||||||
pszValueName = s_empty;
|
pszValueName = s_empty;
|
||||||
|
|
||||||
lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL,
|
lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
&c, NULL, NULL, NULL, NULL);
|
&c, NULL, NULL, NULL, NULL);
|
||||||
if (lResult != ERROR_SUCCESS)
|
if (lResult != ERROR_SUCCESS)
|
||||||
goto err;
|
goto err;
|
||||||
ppszNames = (LPTSTR *) malloc(c * sizeof(LPTSTR));
|
ppszNames = (LPTSTR *) malloc(c * sizeof(LPTSTR));
|
||||||
|
@ -176,7 +176,7 @@ BOOL RegFindRecurse(
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
s_cbName = MAX_PATH * sizeof(TCHAR);
|
s_cbName = MAX_PATH * sizeof(TCHAR);
|
||||||
lResult = RegEnumValue(hSubKey, i, s_szName, &s_cbName, NULL, NULL,
|
lResult = RegEnumValue(hSubKey, i, s_szName, &s_cbName, NULL, NULL,
|
||||||
NULL, &cb);
|
NULL, &cb);
|
||||||
if (lResult == ERROR_NO_MORE_ITEMS)
|
if (lResult == ERROR_NO_MORE_ITEMS)
|
||||||
{
|
{
|
||||||
|
@ -206,8 +206,8 @@ BOOL RegFindRecurse(
|
||||||
if (!fPast)
|
if (!fPast)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((s_dwFlags & RSF_LOOKATVALUES) &&
|
if ((s_dwFlags & RSF_LOOKATVALUES) &&
|
||||||
CompareName(ppszNames[i], s_szFindWhat))
|
CompareName(ppszNames[i], s_szFindWhat))
|
||||||
{
|
{
|
||||||
*ppszFoundSubKey = _tcsdup(szSubKey);
|
*ppszFoundSubKey = _tcsdup(szSubKey);
|
||||||
if (ppszNames[i][0] == 0)
|
if (ppszNames[i][0] == 0)
|
||||||
|
@ -218,19 +218,19 @@ BOOL RegFindRecurse(
|
||||||
}
|
}
|
||||||
|
|
||||||
lResult = RegQueryValueEx(hSubKey, ppszNames[i], NULL, &type,
|
lResult = RegQueryValueEx(hSubKey, ppszNames[i], NULL, &type,
|
||||||
NULL, &cb);
|
NULL, &cb);
|
||||||
if (lResult != ERROR_SUCCESS)
|
if (lResult != ERROR_SUCCESS)
|
||||||
goto err;
|
goto err;
|
||||||
pb = malloc(cb);
|
pb = malloc(cb);
|
||||||
if (pb == NULL)
|
if (pb == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
lResult = RegQueryValueEx(hSubKey, ppszNames[i], NULL, &type,
|
lResult = RegQueryValueEx(hSubKey, ppszNames[i], NULL, &type,
|
||||||
pb, &cb);
|
pb, &cb);
|
||||||
if (lResult != ERROR_SUCCESS)
|
if (lResult != ERROR_SUCCESS)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if ((s_dwFlags & RSF_LOOKATDATA) &&
|
if ((s_dwFlags & RSF_LOOKATDATA) &&
|
||||||
CompareData(type, (LPTSTR) pb, s_szFindWhat))
|
CompareData(type, (LPTSTR) pb, s_szFindWhat))
|
||||||
{
|
{
|
||||||
*ppszFoundSubKey = _tcsdup(szSubKey);
|
*ppszFoundSubKey = _tcsdup(szSubKey);
|
||||||
if (ppszNames[i][0] == 0)
|
if (ppszNames[i][0] == 0)
|
||||||
|
@ -252,7 +252,7 @@ BOOL RegFindRecurse(
|
||||||
ppszNames = NULL;
|
ppszNames = NULL;
|
||||||
|
|
||||||
lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
|
lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL);
|
||||||
if (lResult != ERROR_SUCCESS)
|
if (lResult != ERROR_SUCCESS)
|
||||||
goto err;
|
goto err;
|
||||||
ppszNames = (LPTSTR *) malloc(c * sizeof(LPTSTR));
|
ppszNames = (LPTSTR *) malloc(c * sizeof(LPTSTR));
|
||||||
|
@ -266,7 +266,7 @@ BOOL RegFindRecurse(
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
s_cbName = MAX_PATH * sizeof(TCHAR);
|
s_cbName = MAX_PATH * sizeof(TCHAR);
|
||||||
lResult = RegEnumKeyEx(hSubKey, i, s_szName, &s_cbName, NULL, NULL,
|
lResult = RegEnumKeyEx(hSubKey, i, s_szName, &s_cbName, NULL, NULL,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
if (lResult == ERROR_NO_MORE_ITEMS)
|
if (lResult == ERROR_NO_MORE_ITEMS)
|
||||||
{
|
{
|
||||||
|
@ -289,11 +289,11 @@ BOOL RegFindRecurse(
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if ((s_dwFlags & RSF_LOOKATKEYS) &&
|
if ((s_dwFlags & RSF_LOOKATKEYS) &&
|
||||||
CompareName(ppszNames[i], s_szFindWhat))
|
CompareName(ppszNames[i], s_szFindWhat))
|
||||||
{
|
{
|
||||||
*ppszFoundSubKey = malloc(
|
*ppszFoundSubKey = malloc(
|
||||||
(lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) *
|
(lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) *
|
||||||
sizeof(TCHAR));
|
sizeof(TCHAR));
|
||||||
if (*ppszFoundSubKey == NULL)
|
if (*ppszFoundSubKey == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
if (szSubKey[0])
|
if (szSubKey[0])
|
||||||
|
@ -313,7 +313,7 @@ BOOL RegFindRecurse(
|
||||||
{
|
{
|
||||||
LPTSTR psz = *ppszFoundSubKey;
|
LPTSTR psz = *ppszFoundSubKey;
|
||||||
*ppszFoundSubKey = malloc(
|
*ppszFoundSubKey = malloc(
|
||||||
(lstrlen(szSubKey) + lstrlen(psz) + 2) * sizeof(TCHAR));
|
(lstrlen(szSubKey) + lstrlen(psz) + 2) * sizeof(TCHAR));
|
||||||
if (*ppszFoundSubKey == NULL)
|
if (*ppszFoundSubKey == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
if (szSubKey[0])
|
if (szSubKey[0])
|
||||||
|
@ -352,7 +352,7 @@ success:
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL RegFindWalk(
|
BOOL RegFindWalk(
|
||||||
HKEY * phKey,
|
HKEY * phKey,
|
||||||
LPCTSTR pszSubKey,
|
LPCTSTR pszSubKey,
|
||||||
LPCTSTR pszValueName,
|
LPCTSTR pszValueName,
|
||||||
LPTSTR *ppszFoundSubKey,
|
LPTSTR *ppszFoundSubKey,
|
||||||
|
@ -393,13 +393,13 @@ BOOL RegFindWalk(
|
||||||
lstrcpyn(szKeyName, pch + 1, MAX_PATH);
|
lstrcpyn(szKeyName, pch + 1, MAX_PATH);
|
||||||
*pch = 0;
|
*pch = 0;
|
||||||
lResult = RegOpenKeyEx(hBaseKey, szSubKey, 0, KEY_ALL_ACCESS,
|
lResult = RegOpenKeyEx(hBaseKey, szSubKey, 0, KEY_ALL_ACCESS,
|
||||||
&hSubKey);
|
&hSubKey);
|
||||||
if (lResult != ERROR_SUCCESS)
|
if (lResult != ERROR_SUCCESS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
|
lResult = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL);
|
||||||
if (lResult != ERROR_SUCCESS)
|
if (lResult != ERROR_SUCCESS)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ BOOL RegFindWalk(
|
||||||
|
|
||||||
s_cbName = MAX_PATH * sizeof(TCHAR);
|
s_cbName = MAX_PATH * sizeof(TCHAR);
|
||||||
lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cbName,
|
lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cbName,
|
||||||
NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL);
|
||||||
if (lResult == ERROR_NO_MORE_ITEMS)
|
if (lResult == ERROR_NO_MORE_ITEMS)
|
||||||
{
|
{
|
||||||
c = i;
|
c = i;
|
||||||
|
@ -443,11 +443,11 @@ BOOL RegFindWalk(
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((s_dwFlags & RSF_LOOKATKEYS) &&
|
if ((s_dwFlags & RSF_LOOKATKEYS) &&
|
||||||
CompareName(ppszNames[i], s_szFindWhat))
|
CompareName(ppszNames[i], s_szFindWhat))
|
||||||
{
|
{
|
||||||
*ppszFoundSubKey = malloc(
|
*ppszFoundSubKey = malloc(
|
||||||
(lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) *
|
(lstrlen(szSubKey) + lstrlen(ppszNames[i]) + 2) *
|
||||||
sizeof(TCHAR));
|
sizeof(TCHAR));
|
||||||
if (*ppszFoundSubKey == NULL)
|
if (*ppszFoundSubKey == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
if (szSubKey[0])
|
if (szSubKey[0])
|
||||||
|
@ -462,13 +462,13 @@ BOOL RegFindWalk(
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RegFindRecurse(hSubKey, ppszNames[i], NULL,
|
if (RegFindRecurse(hSubKey, ppszNames[i], NULL,
|
||||||
ppszFoundSubKey, ppszFoundValueName))
|
ppszFoundSubKey, ppszFoundValueName))
|
||||||
{
|
{
|
||||||
LPTSTR psz = *ppszFoundSubKey;
|
LPTSTR psz = *ppszFoundSubKey;
|
||||||
*ppszFoundSubKey = malloc(
|
*ppszFoundSubKey = malloc(
|
||||||
(lstrlen(szSubKey) + lstrlen(psz) + 2) *
|
(lstrlen(szSubKey) + lstrlen(psz) + 2) *
|
||||||
sizeof(TCHAR));
|
sizeof(TCHAR));
|
||||||
if (*ppszFoundSubKey == NULL)
|
if (*ppszFoundSubKey == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
if (szSubKey[0])
|
if (szSubKey[0])
|
||||||
|
@ -605,23 +605,23 @@ static INT_PTR CALLBACK AbortFindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam,
|
||||||
|
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
{
|
{
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
s_bAbort = TRUE;
|
s_bAbort = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch(HIWORD(wParam))
|
switch(HIWORD(wParam))
|
||||||
|
{
|
||||||
|
case BN_CLICKED:
|
||||||
|
switch(LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case BN_CLICKED:
|
case IDCANCEL:
|
||||||
switch(LOWORD(wParam))
|
s_bAbort = TRUE;
|
||||||
{
|
break;
|
||||||
case IDCANCEL:
|
|
||||||
s_bAbort = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -652,7 +652,7 @@ BOOL FindNext(HWND hWnd)
|
||||||
|
|
||||||
/* Create abort find dialog */
|
/* Create abort find dialog */
|
||||||
s_hwndAbortDialog = CreateDialog(GetModuleHandle(NULL),
|
s_hwndAbortDialog = CreateDialog(GetModuleHandle(NULL),
|
||||||
MAKEINTRESOURCE(IDD_FINDING), hWnd, AbortFindDialogProc);
|
MAKEINTRESOURCE(IDD_FINDING), hWnd, AbortFindDialogProc);
|
||||||
if (s_hwndAbortDialog)
|
if (s_hwndAbortDialog)
|
||||||
{
|
{
|
||||||
ShowWindow(s_hwndAbortDialog, SW_SHOW);
|
ShowWindow(s_hwndAbortDialog, SW_SHOW);
|
||||||
|
@ -667,7 +667,7 @@ BOOL FindNext(HWND hWnd)
|
||||||
EnableWindow(g_pChildWnd->hListWnd, FALSE);
|
EnableWindow(g_pChildWnd->hListWnd, FALSE);
|
||||||
EnableWindow(g_pChildWnd->hAddressBarWnd, FALSE);
|
EnableWindow(g_pChildWnd->hAddressBarWnd, FALSE);
|
||||||
|
|
||||||
fSuccess = RegFindWalk(&hKeyRoot, pszKeyPath, pszValueName,
|
fSuccess = RegFindWalk(&hKeyRoot, pszKeyPath, pszValueName,
|
||||||
&pszFoundSubKey, &pszFoundValueName);
|
&pszFoundSubKey, &pszFoundValueName);
|
||||||
|
|
||||||
EnableWindow(hFrameWnd, TRUE);
|
EnableWindow(hFrameWnd, TRUE);
|
||||||
|
@ -703,107 +703,107 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
|
||||||
|
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
dwFlags = GetFindFlags();
|
dwFlags = GetFindFlags();
|
||||||
|
|
||||||
hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS);
|
hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS);
|
||||||
if (hControl)
|
if (hControl)
|
||||||
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATKEYS) ? TRUE : FALSE, 0);
|
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATKEYS) ? TRUE : FALSE, 0);
|
||||||
|
|
||||||
hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES);
|
hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES);
|
||||||
if (hControl)
|
if (hControl)
|
||||||
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATVALUES) ? TRUE : FALSE, 0);
|
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATVALUES) ? TRUE : FALSE, 0);
|
||||||
|
|
||||||
hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA);
|
hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA);
|
||||||
if (hControl)
|
if (hControl)
|
||||||
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATDATA) ? TRUE : FALSE, 0);
|
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_LOOKATDATA) ? TRUE : FALSE, 0);
|
||||||
|
|
||||||
/* Match whole string */
|
/* Match whole string */
|
||||||
hControl = GetDlgItem(hDlg, IDC_MATCHSTRING);
|
hControl = GetDlgItem(hDlg, IDC_MATCHSTRING);
|
||||||
if (hControl)
|
if (hControl)
|
||||||
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_WHOLESTRING) ? TRUE : FALSE, 0);
|
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_WHOLESTRING) ? TRUE : FALSE, 0);
|
||||||
|
|
||||||
/* Case sensitivity */
|
/* Case sensitivity */
|
||||||
hControl = GetDlgItem(hDlg, IDC_MATCHCASE);
|
hControl = GetDlgItem(hDlg, IDC_MATCHCASE);
|
||||||
if (hControl)
|
if (hControl)
|
||||||
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_MATCHCASE) ? TRUE : FALSE, 0);
|
SendMessage(hControl, BM_SETCHECK, (dwFlags & RSF_MATCHCASE) ? TRUE : FALSE, 0);
|
||||||
|
|
||||||
hControl = GetDlgItem(hDlg, IDC_FINDWHAT);
|
hControl = GetDlgItem(hDlg, IDC_FINDWHAT);
|
||||||
if (hControl)
|
if (hControl)
|
||||||
|
{
|
||||||
|
SetWindowText(hControl, s_szSavedFindValue);
|
||||||
|
SetFocus(hControl);
|
||||||
|
SendMessage(hControl, EM_SETSEL, 0, -1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_CLOSE:
|
||||||
|
EndDialog(hDlg, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
switch(HIWORD(wParam))
|
||||||
|
{
|
||||||
|
case BN_CLICKED:
|
||||||
|
switch(LOWORD(wParam))
|
||||||
{
|
{
|
||||||
SetWindowText(hControl, s_szSavedFindValue);
|
case IDOK:
|
||||||
SetFocus(hControl);
|
dwFlags = 0;
|
||||||
SendMessage(hControl, EM_SETSEL, 0, -1);
|
|
||||||
|
hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS);
|
||||||
|
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
||||||
|
dwFlags |= RSF_LOOKATKEYS;
|
||||||
|
|
||||||
|
hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES);
|
||||||
|
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
||||||
|
dwFlags |= RSF_LOOKATVALUES;
|
||||||
|
|
||||||
|
hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA);
|
||||||
|
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
||||||
|
dwFlags |= RSF_LOOKATDATA;
|
||||||
|
|
||||||
|
hControl = GetDlgItem(hDlg, IDC_MATCHSTRING);
|
||||||
|
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
||||||
|
dwFlags |= RSF_WHOLESTRING;
|
||||||
|
|
||||||
|
hControl = GetDlgItem(hDlg, IDC_MATCHCASE);
|
||||||
|
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
||||||
|
dwFlags |= RSF_MATCHCASE;
|
||||||
|
|
||||||
|
SetFindFlags(dwFlags);
|
||||||
|
|
||||||
|
hControl = GetDlgItem(hDlg, IDC_FINDWHAT);
|
||||||
|
if (hControl)
|
||||||
|
GetWindowText(hControl, s_szFindWhat, sizeof(s_szFindWhat) / sizeof(s_szFindWhat[0]));
|
||||||
|
EndDialog(hDlg, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDCANCEL:
|
||||||
|
EndDialog(hDlg, 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case EN_CHANGE:
|
||||||
EndDialog(hDlg, 0);
|
switch(LOWORD(wParam))
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
switch(HIWORD(wParam))
|
|
||||||
{
|
{
|
||||||
case BN_CLICKED:
|
case IDC_FINDWHAT:
|
||||||
switch(LOWORD(wParam))
|
GetWindowText((HWND) lParam, s_szSavedFindValue, sizeof(s_szSavedFindValue) / sizeof(s_szSavedFindValue[0]));
|
||||||
{
|
hControl = GetDlgItem(hDlg, IDOK);
|
||||||
case IDOK:
|
if (hControl)
|
||||||
dwFlags = 0;
|
{
|
||||||
|
lStyle = GetWindowLongPtr(hControl, GWL_STYLE);
|
||||||
hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS);
|
if (s_szSavedFindValue[0])
|
||||||
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
lStyle &= ~WS_DISABLED;
|
||||||
dwFlags |= RSF_LOOKATKEYS;
|
else
|
||||||
|
lStyle |= WS_DISABLED;
|
||||||
hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES);
|
SetWindowLongPtr(hControl, GWL_STYLE, lStyle);
|
||||||
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
RedrawWindow(hControl, NULL, NULL, RDW_INVALIDATE);
|
||||||
dwFlags |= RSF_LOOKATVALUES;
|
}
|
||||||
|
break;
|
||||||
hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA);
|
|
||||||
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
|
||||||
dwFlags |= RSF_LOOKATDATA;
|
|
||||||
|
|
||||||
hControl = GetDlgItem(hDlg, IDC_MATCHSTRING);
|
|
||||||
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
|
||||||
dwFlags |= RSF_WHOLESTRING;
|
|
||||||
|
|
||||||
hControl = GetDlgItem(hDlg, IDC_MATCHCASE);
|
|
||||||
if (hControl && (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
|
||||||
dwFlags |= RSF_MATCHCASE;
|
|
||||||
|
|
||||||
SetFindFlags(dwFlags);
|
|
||||||
|
|
||||||
hControl = GetDlgItem(hDlg, IDC_FINDWHAT);
|
|
||||||
if (hControl)
|
|
||||||
GetWindowText(hControl, s_szFindWhat, sizeof(s_szFindWhat) / sizeof(s_szFindWhat[0]));
|
|
||||||
EndDialog(hDlg, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IDCANCEL:
|
|
||||||
EndDialog(hDlg, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EN_CHANGE:
|
|
||||||
switch(LOWORD(wParam))
|
|
||||||
{
|
|
||||||
case IDC_FINDWHAT:
|
|
||||||
GetWindowText((HWND) lParam, s_szSavedFindValue, sizeof(s_szSavedFindValue) / sizeof(s_szSavedFindValue[0]));
|
|
||||||
hControl = GetDlgItem(hDlg, IDOK);
|
|
||||||
if (hControl)
|
|
||||||
{
|
|
||||||
lStyle = GetWindowLongPtr(hControl, GWL_STYLE);
|
|
||||||
if (s_szSavedFindValue[0])
|
|
||||||
lStyle &= ~WS_DISABLED;
|
|
||||||
else
|
|
||||||
lStyle |= WS_DISABLED;
|
|
||||||
SetWindowLongPtr(hControl, GWL_STYLE, lStyle);
|
|
||||||
RedrawWindow(hControl, NULL, NULL, RDW_INVALIDATE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return iResult;
|
return iResult;
|
||||||
}
|
}
|
||||||
|
@ -811,15 +811,15 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
|
||||||
void FindDialog(HWND hWnd)
|
void FindDialog(HWND hWnd)
|
||||||
{
|
{
|
||||||
if (DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_FIND),
|
if (DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_FIND),
|
||||||
hWnd, FindDialogProc, 0) != 0)
|
hWnd, FindDialogProc, 0) != 0)
|
||||||
{
|
{
|
||||||
if (!FindNext(hWnd))
|
if (!FindNext(hWnd))
|
||||||
{
|
{
|
||||||
TCHAR msg[128], caption[128];
|
TCHAR msg[128], caption[128];
|
||||||
|
|
||||||
LoadString(hInst, IDS_FINISHEDFIND, msg, sizeof(msg)/sizeof(TCHAR));
|
LoadString(hInst, IDS_FINISHEDFIND, msg, sizeof(msg)/sizeof(TCHAR));
|
||||||
LoadString(hInst, IDS_APP_TITLE, caption, sizeof(caption)/sizeof(TCHAR));
|
LoadString(hInst, IDS_APP_TITLE, caption, sizeof(caption)/sizeof(TCHAR));
|
||||||
MessageBox(0, msg, caption, MB_ICONINFORMATION);
|
MessageBox(0, msg, caption, MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,8 @@ static void resize_frame_rect(HWND hWnd, PRECT prect)
|
||||||
prect->bottom -= rt.bottom+3;
|
prect->bottom -= rt.bottom+3;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (IsWindowVisible(hStatusBar)) {
|
if (IsWindowVisible(hStatusBar))
|
||||||
|
{
|
||||||
SetupStatusBar(hWnd, TRUE);
|
SetupStatusBar(hWnd, TRUE);
|
||||||
GetClientRect(hStatusBar, &rt);
|
GetClientRect(hStatusBar, &rt);
|
||||||
prect->bottom -= rt.bottom;
|
prect->bottom -= rt.bottom;
|
||||||
|
@ -141,12 +142,15 @@ static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
|
||||||
TCHAR str[100];
|
TCHAR str[100];
|
||||||
|
|
||||||
_tcscpy(str, _T(""));
|
_tcscpy(str, _T(""));
|
||||||
if (nFlags & MF_POPUP) {
|
if (nFlags & MF_POPUP)
|
||||||
if (hSysMenu != GetMenu(hWnd)) {
|
{
|
||||||
|
if (hSysMenu != GetMenu(hWnd))
|
||||||
|
{
|
||||||
if (nItemID == 2) nItemID = 5;
|
if (nItemID == 2) nItemID = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (LoadString(hInst, nItemID, str, 100)) {
|
if (LoadString(hInst, nItemID, str, 100))
|
||||||
|
{
|
||||||
/* load appropriate string*/
|
/* load appropriate string*/
|
||||||
LPTSTR lpsz = str;
|
LPTSTR lpsz = str;
|
||||||
/* first newline terminates actual string*/
|
/* first newline terminates actual string*/
|
||||||
|
@ -171,8 +175,8 @@ void SetupStatusBar(HWND hWnd, BOOL bResize)
|
||||||
|
|
||||||
void UpdateStatusBar(void)
|
void UpdateStatusBar(void)
|
||||||
{
|
{
|
||||||
NMHDR nmhdr;
|
NMHDR nmhdr;
|
||||||
ZeroMemory(&nmhdr, sizeof(NMHDR));
|
ZeroMemory(&nmhdr, sizeof(NMHDR));
|
||||||
nmhdr.code = TVN_SELCHANGED;
|
nmhdr.code = TVN_SELCHANGED;
|
||||||
SendMessage(g_pChildWnd->hWnd, WM_NOTIFY, (WPARAM)TREE_WINDOW, (LPARAM)&nmhdr);
|
SendMessage(g_pChildWnd->hWnd, WM_NOTIFY, (WPARAM)TREE_WINDOW, (LPARAM)&nmhdr);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +195,8 @@ static BOOL CheckCommDlgError(HWND hWnd)
|
||||||
{
|
{
|
||||||
DWORD dwErrorCode = CommDlgExtendedError();
|
DWORD dwErrorCode = CommDlgExtendedError();
|
||||||
UNREFERENCED_PARAMETER(hWnd);
|
UNREFERENCED_PARAMETER(hWnd);
|
||||||
switch (dwErrorCode) {
|
switch (dwErrorCode)
|
||||||
|
{
|
||||||
case CDERR_DIALOGFAILURE:
|
case CDERR_DIALOGFAILURE:
|
||||||
break;
|
break;
|
||||||
case CDERR_FINDRESFAILURE:
|
case CDERR_FINDRESFAILURE:
|
||||||
|
@ -233,24 +238,24 @@ TCHAR FileTitleBuffer[_MAX_PATH];
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UINT DisplayID;
|
UINT DisplayID;
|
||||||
UINT FilterID;
|
UINT FilterID;
|
||||||
} FILTERPAIR, *PFILTERPAIR;
|
} FILTERPAIR, *PFILTERPAIR;
|
||||||
|
|
||||||
void
|
void
|
||||||
BuildFilterStrings(TCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
|
BuildFilterStrings(TCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
|
||||||
{
|
{
|
||||||
int i, c;
|
int i, c;
|
||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
for(i = 0; i < PairCount; i++)
|
for(i = 0; i < PairCount; i++)
|
||||||
{
|
{
|
||||||
c += LoadString(hInst, Pairs[i].DisplayID, &Filter[c], 255 * sizeof(TCHAR));
|
c += LoadString(hInst, Pairs[i].DisplayID, &Filter[c], 255 * sizeof(TCHAR));
|
||||||
|
Filter[++c] = '\0';
|
||||||
|
c += LoadString(hInst, Pairs[i].FilterID, &Filter[c], 255 * sizeof(TCHAR));
|
||||||
|
Filter[++c] = '\0';
|
||||||
|
}
|
||||||
Filter[++c] = '\0';
|
Filter[++c] = '\0';
|
||||||
c += LoadString(hInst, Pairs[i].FilterID, &Filter[c], 255 * sizeof(TCHAR));
|
|
||||||
Filter[++c] = '\0';
|
|
||||||
}
|
|
||||||
Filter[++c] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
|
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
|
||||||
|
@ -288,18 +293,18 @@ static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPAR
|
||||||
static INT sLength = 0;
|
static INT sLength = 0;
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
sKey = (LPTSTR)lParam;
|
sKey = (LPTSTR)lParam;
|
||||||
sLength = 128; /* FIXME: Ugly hack! */
|
sLength = 128; /* FIXME: Ugly hack! */
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch(LOWORD(wParam))
|
switch(LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case IDOK:
|
case IDOK:
|
||||||
if(GetDlgItemText(hWndDlg, IDC_EDIT_KEY, sKey, sLength))
|
if(GetDlgItemText(hWndDlg, IDC_EDIT_KEY, sKey, sLength))
|
||||||
return EndDialog(hWndDlg, -1);
|
return EndDialog(hWndDlg, -1);
|
||||||
else
|
else
|
||||||
return EndDialog(hWndDlg, 0);
|
return EndDialog(hWndDlg, 0);
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
return EndDialog(hWndDlg, 0);
|
return EndDialog(hWndDlg, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -349,7 +354,9 @@ static BOOL LoadHive(HWND hWnd)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CheckCommDlgError(hWnd);
|
CheckCommDlgError(hWnd);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -393,9 +400,11 @@ static BOOL ImportRegistryFile(HWND hWnd)
|
||||||
ofn.lpstrTitle = Caption;
|
ofn.lpstrTitle = Caption;
|
||||||
ofn.Flags |= OFN_ENABLESIZING;
|
ofn.Flags |= OFN_ENABLESIZING;
|
||||||
/* ofn.lCustData = ;*/
|
/* ofn.lCustData = ;*/
|
||||||
if (GetOpenFileName(&ofn)) {
|
if (GetOpenFileName(&ofn))
|
||||||
|
{
|
||||||
FILE *fp = _wfopen(ofn.lpstrFile, L"r");
|
FILE *fp = _wfopen(ofn.lpstrFile, L"r");
|
||||||
if (fp == NULL || !import_registry_file(fp)) {
|
if (fp == NULL || !import_registry_file(fp))
|
||||||
|
{
|
||||||
LPSTR p = GetMultiByteString(ofn.lpstrFile);
|
LPSTR p = GetMultiByteString(ofn.lpstrFile);
|
||||||
fprintf(stderr, "Can't open file \"%s\"\n", p);
|
fprintf(stderr, "Can't open file \"%s\"\n", p);
|
||||||
HeapFree(GetProcessHeap(), 0, p);
|
HeapFree(GetProcessHeap(), 0, p);
|
||||||
|
@ -404,7 +413,9 @@ static BOOL ImportRegistryFile(HWND hWnd)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CheckCommDlgError(hWnd);
|
CheckCommDlgError(hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,8 +438,9 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(wParam);
|
UNREFERENCED_PARAMETER(wParam);
|
||||||
|
|
||||||
switch(uiMsg) {
|
switch(uiMsg)
|
||||||
case WM_INITDIALOG:
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
pOfn = (OPENFILENAME *) lParam;
|
pOfn = (OPENFILENAME *) lParam;
|
||||||
pszSelectedKey = (LPTSTR) pOfn->lCustData;
|
pszSelectedKey = (LPTSTR) pOfn->lCustData;
|
||||||
|
|
||||||
|
@ -445,7 +457,7 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W
|
||||||
SetWindowText(hwndExportBranchText, pszSelectedKey);
|
SetWindowText(hwndExportBranchText, pszSelectedKey);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
if (((NMHDR *) lParam)->code == CDN_FILEOK)
|
if (((NMHDR *) lParam)->code == CDN_FILEOK)
|
||||||
{
|
{
|
||||||
pOfnNotify = (OFNOTIFY *) lParam;
|
pOfnNotify = (OFNOTIFY *) lParam;
|
||||||
|
@ -454,15 +466,15 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W
|
||||||
hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
|
hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
|
||||||
hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
|
hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
|
||||||
if (hwndExportBranch && hwndExportBranchText
|
if (hwndExportBranch && hwndExportBranchText
|
||||||
&& (SendMessage(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
&& (SendMessage(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED))
|
||||||
{
|
{
|
||||||
GetWindowText(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
|
GetWindowText(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pszSelectedKey[0] = '\0';
|
pszSelectedKey[0] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return iResult;
|
return iResult;
|
||||||
|
@ -492,7 +504,8 @@ BOOL ExportRegistryFile(HWND hWnd)
|
||||||
ofn.Flags = OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_OVERWRITEPROMPT;
|
ofn.Flags = OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_OVERWRITEPROMPT;
|
||||||
ofn.lpfnHook = ExportRegistryFile_OFNHookProc;
|
ofn.lpfnHook = ExportRegistryFile_OFNHookProc;
|
||||||
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EXPORTRANGE);
|
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EXPORTRANGE);
|
||||||
if (GetSaveFileName(&ofn)) {
|
if (GetSaveFileName(&ofn))
|
||||||
|
{
|
||||||
BOOL result;
|
BOOL result;
|
||||||
DWORD format;
|
DWORD format;
|
||||||
|
|
||||||
|
@ -501,13 +514,16 @@ BOOL ExportRegistryFile(HWND hWnd)
|
||||||
else
|
else
|
||||||
format = REG_FORMAT_4;
|
format = REG_FORMAT_4;
|
||||||
result = export_registry_key(ofn.lpstrFile, ExportKeyPath, format);
|
result = export_registry_key(ofn.lpstrFile, ExportKeyPath, format);
|
||||||
if (!result) {
|
if (!result)
|
||||||
|
{
|
||||||
LPSTR p = GetMultiByteString(ofn.lpstrFile);
|
LPSTR p = GetMultiByteString(ofn.lpstrFile);
|
||||||
fprintf(stderr, "Can't open file \"%s\"\n", p);
|
fprintf(stderr, "Can't open file \"%s\"\n", p);
|
||||||
HeapFree(GetProcessHeap(), 0, p);
|
HeapFree(GetProcessHeap(), 0, p);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CheckCommDlgError(hWnd);
|
CheckCommDlgError(hWnd);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -530,7 +546,8 @@ BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
|
||||||
pd.nToPage = 0xFFFF;
|
pd.nToPage = 0xFFFF;
|
||||||
pd.nMinPage = 1;
|
pd.nMinPage = 1;
|
||||||
pd.nMaxPage = 0xFFFF;
|
pd.nMaxPage = 0xFFFF;
|
||||||
if (PrintDlg(&pd)) {
|
if (PrintDlg(&pd))
|
||||||
|
{
|
||||||
/* GDI calls to render output. */
|
/* GDI calls to render output. */
|
||||||
DeleteDC(pd.hDC); /* Delete DC when done.*/
|
DeleteDC(pd.hDC); /* Delete DC when done.*/
|
||||||
}
|
}
|
||||||
|
@ -539,8 +556,10 @@ BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
|
||||||
PRINTDLGEX pd;
|
PRINTDLGEX pd;
|
||||||
|
|
||||||
hResult = PrintDlgEx(&pd);
|
hResult = PrintDlgEx(&pd);
|
||||||
if (hResult == S_OK) {
|
if (hResult == S_OK)
|
||||||
switch (pd.dwResultAction) {
|
{
|
||||||
|
switch (pd.dwResultAction)
|
||||||
|
{
|
||||||
case PD_RESULT_APPLY:
|
case PD_RESULT_APPLY:
|
||||||
/*The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked. */
|
/*The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked. */
|
||||||
break;
|
break;
|
||||||
|
@ -553,8 +572,11 @@ BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
switch (hResult) {
|
else
|
||||||
|
{
|
||||||
|
switch (hResult)
|
||||||
|
{
|
||||||
case E_OUTOFMEMORY:
|
case E_OUTOFMEMORY:
|
||||||
/*Insufficient memory. */
|
/*Insufficient memory. */
|
||||||
break;
|
break;
|
||||||
|
@ -662,9 +684,11 @@ static BOOL CreateNewValue(HKEY hRootKey, LPCTSTR pszKeyPath, DWORD dwType)
|
||||||
wsprintf(szNewValue, szNewValueFormat, iIndex++);
|
wsprintf(szNewValue, szNewValueFormat, iIndex++);
|
||||||
cbData = sizeof(data);
|
cbData = sizeof(data);
|
||||||
lResult = RegQueryValueEx(hKey, szNewValue, NULL, &dwExistingType, data, &cbData);
|
lResult = RegQueryValueEx(hKey, szNewValue, NULL, &dwExistingType, data, &cbData);
|
||||||
} while(lResult == ERROR_SUCCESS);
|
}
|
||||||
|
while(lResult == ERROR_SUCCESS);
|
||||||
|
|
||||||
switch(dwType) {
|
switch(dwType)
|
||||||
|
{
|
||||||
case REG_DWORD:
|
case REG_DWORD:
|
||||||
cbData = sizeof(DWORD);
|
cbData = sizeof(DWORD);
|
||||||
break;
|
break;
|
||||||
|
@ -723,9 +747,9 @@ InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
|
||||||
{
|
{
|
||||||
sizeof(DSOP_SCOPE_INIT_INFO),
|
sizeof(DSOP_SCOPE_INIT_INFO),
|
||||||
DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE | DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE |
|
DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE | DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE |
|
||||||
DSOP_SCOPE_TYPE_GLOBAL_CATALOG | DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN |
|
DSOP_SCOPE_TYPE_GLOBAL_CATALOG | DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN |
|
||||||
DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN | DSOP_SCOPE_TYPE_WORKGROUP |
|
DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN | DSOP_SCOPE_TYPE_WORKGROUP |
|
||||||
DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN | DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN,
|
DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN | DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN,
|
||||||
0,
|
0,
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -750,7 +774,7 @@ InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
|
||||||
InitInfo.apwzAttributeNames = NULL;
|
InitInfo.apwzAttributeNames = NULL;
|
||||||
|
|
||||||
hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
|
hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
|
||||||
&InitInfo);
|
&InitInfo);
|
||||||
|
|
||||||
if (FAILED(hRet))
|
if (FAILED(hRet))
|
||||||
{
|
{
|
||||||
|
@ -772,8 +796,8 @@ InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker *pDsObjectPicker,
|
||||||
HRESULT hRet;
|
HRESULT hRet;
|
||||||
|
|
||||||
hRet = pDsObjectPicker->lpVtbl->InvokeDialog(pDsObjectPicker,
|
hRet = pDsObjectPicker->lpVtbl->InvokeDialog(pDsObjectPicker,
|
||||||
hwndParent,
|
hwndParent,
|
||||||
&pdo);
|
&pdo);
|
||||||
if (hRet == S_OK)
|
if (hRet == S_OK)
|
||||||
{
|
{
|
||||||
STGMEDIUM stm;
|
STGMEDIUM stm;
|
||||||
|
@ -855,7 +879,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
UNREFERENCED_PARAMETER(lParam);
|
||||||
UNREFERENCED_PARAMETER(message);
|
UNREFERENCED_PARAMETER(message);
|
||||||
|
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam))
|
||||||
|
{
|
||||||
case ID_REGISTRY_LOADHIVE:
|
case ID_REGISTRY_LOADHIVE:
|
||||||
LoadHive(hWnd);
|
LoadHive(hWnd);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -924,9 +949,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
pts = pt;
|
pts = pt;
|
||||||
if(ClientToScreen(g_pChildWnd->hWnd, &pts))
|
if(ClientToScreen(g_pChildWnd->hWnd, &pts))
|
||||||
{
|
{
|
||||||
SetCursorPos(pts.x, pts.y);
|
SetCursorPos(pts.x, pts.y);
|
||||||
SetCursor(LoadCursor(0, IDC_SIZEWE));
|
SetCursor(LoadCursor(0, IDC_SIZEWE));
|
||||||
SendMessage(g_pChildWnd->hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
|
SendMessage(g_pChildWnd->hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -940,12 +965,14 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
|
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
|
||||||
valueName = GetValueName(g_pChildWnd->hListWnd, -1);
|
valueName = GetValueName(g_pChildWnd->hListWnd, -1);
|
||||||
if (keyPath) {
|
if (keyPath)
|
||||||
|
{
|
||||||
lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, regsam, &hKey);
|
lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, regsam, &hKey);
|
||||||
if (lRet != ERROR_SUCCESS) hKey = 0;
|
if (lRet != ERROR_SUCCESS) hKey = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam))
|
||||||
|
{
|
||||||
case ID_EDIT_MODIFY:
|
case ID_EDIT_MODIFY:
|
||||||
if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
|
if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
|
||||||
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
|
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
|
||||||
|
@ -978,49 +1005,49 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (GetFocus() == g_pChildWnd->hListWnd)
|
if (GetFocus() == g_pChildWnd->hListWnd)
|
||||||
{
|
{
|
||||||
UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
|
UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
|
||||||
if(nSelected >= 1)
|
if(nSelected >= 1)
|
||||||
{
|
|
||||||
TCHAR msg[128], caption[128];
|
|
||||||
LoadString(hInst, IDS_QUERY_DELETE_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR));
|
|
||||||
LoadString(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, sizeof(msg)/sizeof(TCHAR));
|
|
||||||
if(MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
|
|
||||||
{
|
{
|
||||||
int ni, errs;
|
TCHAR msg[128], caption[128];
|
||||||
|
LoadString(hInst, IDS_QUERY_DELETE_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR));
|
||||||
item = -1;
|
LoadString(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, sizeof(msg)/sizeof(TCHAR));
|
||||||
errs = 0;
|
if(MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
|
||||||
while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1)
|
|
||||||
{
|
|
||||||
valueName = GetValueName(g_pChildWnd->hListWnd, item);
|
|
||||||
if(RegDeleteValue(hKey, valueName) != ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
errs++;
|
int ni, errs;
|
||||||
}
|
|
||||||
item = ni;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
|
item = -1;
|
||||||
if(errs > 0)
|
errs = 0;
|
||||||
{
|
while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1)
|
||||||
LoadString(hInst, IDS_ERR_DELVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR));
|
{
|
||||||
LoadString(hInst, IDS_ERR_DELETEVALUE, msg, sizeof(msg)/sizeof(TCHAR));
|
valueName = GetValueName(g_pChildWnd->hListWnd, item);
|
||||||
MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
|
if(RegDeleteValue(hKey, valueName) != ERROR_SUCCESS)
|
||||||
}
|
{
|
||||||
|
errs++;
|
||||||
|
}
|
||||||
|
item = ni;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
|
||||||
|
if(errs > 0)
|
||||||
|
{
|
||||||
|
LoadString(hInst, IDS_ERR_DELVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR));
|
||||||
|
LoadString(hInst, IDS_ERR_DELETEVALUE, msg, sizeof(msg)/sizeof(TCHAR));
|
||||||
|
MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (GetFocus() == g_pChildWnd->hTreeWnd)
|
else if (GetFocus() == g_pChildWnd->hTreeWnd)
|
||||||
{
|
{
|
||||||
if (keyPath == 0 || *keyPath == 0)
|
if (keyPath == 0 || *keyPath == 0)
|
||||||
{
|
{
|
||||||
MessageBeep(MB_ICONHAND);
|
MessageBeep(MB_ICONHAND);
|
||||||
} else
|
}
|
||||||
if (DeleteKey(hWnd, hKeyRoot, keyPath))
|
else if (DeleteKey(hWnd, hKeyRoot, keyPath))
|
||||||
{
|
{
|
||||||
DeleteNode(g_pChildWnd->hTreeWnd, 0);
|
DeleteNode(g_pChildWnd->hTreeWnd, 0);
|
||||||
RefreshTreeView(g_pChildWnd->hTreeWnd);
|
RefreshTreeView(g_pChildWnd->hTreeWnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1064,9 +1091,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
RefreshTreeView(g_pChildWnd->hTreeWnd);
|
RefreshTreeView(g_pChildWnd->hTreeWnd);
|
||||||
/*RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL); */
|
/*RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL); */
|
||||||
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_EDIT_NEW_KEY:
|
case ID_EDIT_NEW_KEY:
|
||||||
CreateNewKey(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd));
|
CreateNewKey(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd));
|
||||||
break;
|
break;
|
||||||
|
@ -1099,7 +1126,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hKey)
|
if(hKey)
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,7 +1143,8 @@ 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)
|
||||||
{
|
{
|
||||||
switch (message) {
|
switch (message)
|
||||||
|
{
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
CreateWindowEx(0, szChildClass, NULL, WS_CHILD | WS_VISIBLE,
|
CreateWindowEx(0, szChildClass, NULL, WS_CHILD | WS_VISIBLE,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -96,23 +96,23 @@ VOID SetValueName(HWND hwndLV, LPCTSTR pszValueName)
|
||||||
i = ListView_FindItem(hwndLV, -1, &fi);
|
i = ListView_FindItem(hwndLV, -1, &fi);
|
||||||
}
|
}
|
||||||
ListView_SetItemState(hwndLV, i, LVIS_FOCUSED | LVIS_SELECTED,
|
ListView_SetItemState(hwndLV, i, LVIS_FOCUSED | LVIS_SELECTED,
|
||||||
LVIS_FOCUSED | LVIS_SELECTED);
|
LVIS_FOCUSED | LVIS_SELECTED);
|
||||||
iListViewSelect = i;
|
iListViewSelect = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL IsDefaultValue(HWND hwndLV, int i)
|
BOOL IsDefaultValue(HWND hwndLV, int i)
|
||||||
{
|
{
|
||||||
PLINE_INFO lineinfo;
|
PLINE_INFO lineinfo;
|
||||||
LVITEM Item;
|
LVITEM Item;
|
||||||
|
|
||||||
Item.mask = LVIF_PARAM;
|
Item.mask = LVIF_PARAM;
|
||||||
Item.iItem = i;
|
Item.iItem = i;
|
||||||
if(ListView_GetItem(hwndLV, &Item))
|
if(ListView_GetItem(hwndLV, &Item))
|
||||||
{
|
{
|
||||||
lineinfo = (PLINE_INFO)Item.lParam;
|
lineinfo = (PLINE_INFO)Item.lParam;
|
||||||
return lineinfo && (!lineinfo->name || !_tcscmp(lineinfo->name, _T("")));
|
return lineinfo && (!lineinfo->name || !_tcscmp(lineinfo->name, _T("")));
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -129,7 +129,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
|
||||||
linfo->val_len = dwCount;
|
linfo->val_len = dwCount;
|
||||||
if(dwCount > 0)
|
if(dwCount > 0)
|
||||||
{
|
{
|
||||||
memcpy(&linfo[1], ValBuf, dwCount);
|
memcpy(&linfo[1], ValBuf, dwCount);
|
||||||
}
|
}
|
||||||
linfo->name = _tcsdup(Name);
|
linfo->name = _tcsdup(Name);
|
||||||
|
|
||||||
|
@ -146,12 +146,12 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
|
||||||
item.lParam = (LPARAM)linfo;
|
item.lParam = (LPARAM)linfo;
|
||||||
switch(dwValType)
|
switch(dwValType)
|
||||||
{
|
{
|
||||||
case REG_SZ:
|
case REG_SZ:
|
||||||
case REG_EXPAND_SZ:
|
case REG_EXPAND_SZ:
|
||||||
case REG_MULTI_SZ:
|
case REG_MULTI_SZ:
|
||||||
item.iImage = Image_String;
|
item.iImage = Image_String;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
item.iImage = Image_Bin;
|
item.iImage = Image_Bin;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -162,87 +162,90 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
index = ListView_InsertItem(hwndLV, &item);
|
index = ListView_InsertItem(hwndLV, &item);
|
||||||
if (index != -1) {
|
if (index != -1)
|
||||||
switch (dwValType) {
|
{
|
||||||
|
switch (dwValType)
|
||||||
|
{
|
||||||
case REG_SZ:
|
case REG_SZ:
|
||||||
case REG_EXPAND_SZ:
|
case REG_EXPAND_SZ:
|
||||||
if(dwCount > 0)
|
if(dwCount > 0)
|
||||||
{
|
{
|
||||||
ListView_SetItemText(hwndLV, index, 2, ValBuf);
|
ListView_SetItemText(hwndLV, index, 2, ValBuf);
|
||||||
}
|
}
|
||||||
else if(!ValExists)
|
else if(!ValExists)
|
||||||
{
|
{
|
||||||
TCHAR buffer[255];
|
TCHAR buffer[255];
|
||||||
/* load (value not set) string */
|
/* load (value not set) string */
|
||||||
LoadString(hInst, IDS_VALUE_NOT_SET, buffer, sizeof(buffer)/sizeof(TCHAR));
|
LoadString(hInst, IDS_VALUE_NOT_SET, buffer, sizeof(buffer)/sizeof(TCHAR));
|
||||||
ListView_SetItemText(hwndLV, index, 2, buffer);
|
ListView_SetItemText(hwndLV, index, 2, buffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REG_MULTI_SZ:
|
case REG_MULTI_SZ:
|
||||||
|
{
|
||||||
|
LPTSTR src, str;
|
||||||
|
if(dwCount >= 2)
|
||||||
{
|
{
|
||||||
LPTSTR src, str;
|
src = (LPTSTR)ValBuf;
|
||||||
if(dwCount >= 2)
|
str = HeapAlloc(GetProcessHeap(), 0, dwCount);
|
||||||
{
|
if(str != NULL)
|
||||||
src = (LPTSTR)ValBuf;
|
|
||||||
str = HeapAlloc(GetProcessHeap(), 0, dwCount);
|
|
||||||
if(str != NULL)
|
|
||||||
{
|
|
||||||
*str = _T('\0');
|
|
||||||
/* concatenate all srings */
|
|
||||||
while(*src != _T('\0'))
|
|
||||||
{
|
|
||||||
_tcscat(str, src);
|
|
||||||
_tcscat(str, _T(" "));
|
|
||||||
src += _tcslen(src) + 1;
|
|
||||||
}
|
|
||||||
ListView_SetItemText(hwndLV, index, 2, str);
|
|
||||||
HeapFree(GetProcessHeap(), 0, str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ListView_SetItemText(hwndLV, index, 2, _T(""));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ListView_SetItemText(hwndLV, index, 2, _T(""));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case REG_DWORD: {
|
|
||||||
TCHAR buf[200];
|
|
||||||
if(dwCount == sizeof(DWORD))
|
|
||||||
{
|
{
|
||||||
wsprintf(buf, _T("0x%08x (%u)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf);
|
*str = _T('\0');
|
||||||
}
|
/* concatenate all srings */
|
||||||
else
|
while(*src != _T('\0'))
|
||||||
{
|
|
||||||
LoadString(hInst, IDS_INVALID_DWORD, buf, sizeof(buf)/sizeof(TCHAR));
|
|
||||||
}
|
|
||||||
ListView_SetItemText(hwndLV, index, 2, buf);
|
|
||||||
}
|
|
||||||
/* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
LPBYTE pData = (LPBYTE)ValBuf;
|
|
||||||
LPTSTR strBinary;
|
|
||||||
if(dwCount > 0)
|
|
||||||
{
|
|
||||||
strBinary = HeapAlloc(GetProcessHeap(), 0, (dwCount * sizeof(TCHAR) * 3) + sizeof(TCHAR));
|
|
||||||
for (i = 0; i < dwCount; i++)
|
|
||||||
{
|
{
|
||||||
wsprintf( strBinary + i*3, _T("%02X "), pData[i] );
|
_tcscat(str, src);
|
||||||
|
_tcscat(str, _T(" "));
|
||||||
|
src += _tcslen(src) + 1;
|
||||||
}
|
}
|
||||||
strBinary[dwCount * 3] = 0;
|
ListView_SetItemText(hwndLV, index, 2, str);
|
||||||
ListView_SetItemText(hwndLV, index, 2, strBinary);
|
HeapFree(GetProcessHeap(), 0, str);
|
||||||
HeapFree(GetProcessHeap(), 0, strBinary);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
ListView_SetItemText(hwndLV, index, 2, _T(""));
|
||||||
TCHAR szText[128];
|
|
||||||
LoadString(hInst, IDS_BINARY_EMPTY, szText, sizeof(szText)/sizeof(TCHAR));
|
|
||||||
ListView_SetItemText(hwndLV, index, 2, szText);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
else
|
||||||
|
ListView_SetItemText(hwndLV, index, 2, _T(""));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case REG_DWORD:
|
||||||
|
{
|
||||||
|
TCHAR buf[200];
|
||||||
|
if(dwCount == sizeof(DWORD))
|
||||||
|
{
|
||||||
|
wsprintf(buf, _T("0x%08x (%u)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadString(hInst, IDS_INVALID_DWORD, buf, sizeof(buf)/sizeof(TCHAR));
|
||||||
|
}
|
||||||
|
ListView_SetItemText(hwndLV, index, 2, buf);
|
||||||
|
}
|
||||||
|
/* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
LPBYTE pData = (LPBYTE)ValBuf;
|
||||||
|
LPTSTR strBinary;
|
||||||
|
if(dwCount > 0)
|
||||||
|
{
|
||||||
|
strBinary = HeapAlloc(GetProcessHeap(), 0, (dwCount * sizeof(TCHAR) * 3) + sizeof(TCHAR));
|
||||||
|
for (i = 0; i < dwCount; i++)
|
||||||
|
{
|
||||||
|
wsprintf( strBinary + i*3, _T("%02X "), pData[i] );
|
||||||
|
}
|
||||||
|
strBinary[dwCount * 3] = 0;
|
||||||
|
ListView_SetItemText(hwndLV, index, 2, strBinary);
|
||||||
|
HeapFree(GetProcessHeap(), 0, strBinary);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TCHAR szText[128];
|
||||||
|
LoadString(hInst, IDS_BINARY_EMPTY, szText, sizeof(szText)/sizeof(TCHAR));
|
||||||
|
ListView_SetItemText(hwndLV, index, 2, szText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,7 +261,8 @@ static BOOL CreateListColumns(HWND hWndListView)
|
||||||
lvC.pszText = szText;
|
lvC.pszText = szText;
|
||||||
|
|
||||||
/* Load the column labels from the resource file. */
|
/* Load the column labels from the resource file. */
|
||||||
for (index = 0; index < MAX_LIST_COLUMNS; index++) {
|
for (index = 0; index < MAX_LIST_COLUMNS; index++)
|
||||||
|
{
|
||||||
lvC.iSubItem = index;
|
lvC.iSubItem = index;
|
||||||
lvC.cx = default_column_widths[index];
|
lvC.cx = default_column_widths[index];
|
||||||
lvC.fmt = column_alignment[index];
|
lvC.fmt = column_alignment[index];
|
||||||
|
@ -288,7 +292,7 @@ static BOOL InitListViewImageLists(HWND hwndLV)
|
||||||
/* Fail if not all of the images were added. */
|
/* Fail if not all of the images were added. */
|
||||||
if (ImageList_GetImageCount(himl) < NUM_ICONS)
|
if (ImageList_GetImageCount(himl) < NUM_ICONS)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Associate the image list with the tree view control. */
|
/* Associate the image list with the tree view control. */
|
||||||
|
@ -306,13 +310,15 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
|
||||||
plvdi->item.pszText = NULL;
|
plvdi->item.pszText = NULL;
|
||||||
plvdi->item.cchTextMax = 0;
|
plvdi->item.cchTextMax = 0;
|
||||||
|
|
||||||
switch (plvdi->item.iSubItem) {
|
switch (plvdi->item.iSubItem)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
|
||||||
plvdi->item.pszText = buffer;
|
plvdi->item.pszText = buffer;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
switch (((LINE_INFO*)plvdi->item.lParam)->dwValType) {
|
switch (((LINE_INFO*)plvdi->item.lParam)->dwValType)
|
||||||
|
{
|
||||||
case REG_NONE:
|
case REG_NONE:
|
||||||
plvdi->item.pszText = _T("REG_NONE");
|
plvdi->item.pszText = _T("REG_NONE");
|
||||||
break;
|
break;
|
||||||
|
@ -349,13 +355,14 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
|
||||||
case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
|
case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
|
||||||
plvdi->item.pszText = _T("REG_QWORD");
|
plvdi->item.pszText = _T("REG_QWORD");
|
||||||
break;
|
break;
|
||||||
default: {
|
default:
|
||||||
|
{
|
||||||
TCHAR buf2[200];
|
TCHAR buf2[200];
|
||||||
LoadString(hInst, IDS_UNKNOWN_TYPE, buf2, sizeof(buf2)/sizeof(TCHAR));
|
LoadString(hInst, IDS_UNKNOWN_TYPE, buf2, sizeof(buf2)/sizeof(TCHAR));
|
||||||
wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType);
|
wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType);
|
||||||
plvdi->item.pszText = buffer;
|
plvdi->item.pszText = buffer;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -377,7 +384,8 @@ 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 ? _tcsicmp(r->name, l->name) : _tcsicmp(l->name, r->name);
|
return g_invertSort ? _tcsicmp(r->name, l->name) : _tcsicmp(l->name, r->name);
|
||||||
|
@ -388,87 +396,89 @@ BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
|
||||||
NMLVDISPINFO* Info;
|
NMLVDISPINFO* Info;
|
||||||
UNREFERENCED_PARAMETER(wParam);
|
UNREFERENCED_PARAMETER(wParam);
|
||||||
*Result = TRUE;
|
*Result = TRUE;
|
||||||
switch (((LPNMHDR)lParam)->code) {
|
switch (((LPNMHDR)lParam)->code)
|
||||||
case LVN_GETDISPINFO:
|
{
|
||||||
OnGetDispInfo((NMLVDISPINFO*)lParam);
|
case LVN_GETDISPINFO:
|
||||||
return TRUE;
|
OnGetDispInfo((NMLVDISPINFO*)lParam);
|
||||||
case LVN_COLUMNCLICK:
|
return TRUE;
|
||||||
if (g_columnToSort == (DWORD)((LPNMLISTVIEW)lParam)->iSubItem)
|
case LVN_COLUMNCLICK:
|
||||||
g_invertSort = !g_invertSort;
|
if (g_columnToSort == (DWORD)((LPNMLISTVIEW)lParam)->iSubItem)
|
||||||
else {
|
g_invertSort = !g_invertSort;
|
||||||
g_columnToSort = ((LPNMLISTVIEW)lParam)->iSubItem;
|
else
|
||||||
g_invertSort = FALSE;
|
{
|
||||||
}
|
g_columnToSort = ((LPNMLISTVIEW)lParam)->iSubItem;
|
||||||
|
g_invertSort = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
(void)ListView_SortItems(hWnd, CompareFunc, (WPARAM)hWnd);
|
(void)ListView_SortItems(hWnd, CompareFunc, (WPARAM)hWnd);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case NM_DBLCLK:
|
case NM_DBLCLK:
|
||||||
case NM_RETURN:
|
case NM_RETURN:
|
||||||
|
{
|
||||||
|
SendMessage(hFrameWnd, WM_COMMAND, MAKEWPARAM(ID_EDIT_MODIFY, 0), 0);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
case NM_SETFOCUS:
|
||||||
|
g_pChildWnd->nFocusPanel = 0;
|
||||||
|
break;
|
||||||
|
case LVN_BEGINLABELEDIT:
|
||||||
|
Info = (NMLVDISPINFO*)lParam;
|
||||||
|
if(Info)
|
||||||
|
{
|
||||||
|
PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
|
||||||
|
if(!lineinfo->name || !_tcscmp(lineinfo->name, _T("")))
|
||||||
{
|
{
|
||||||
SendMessage(hFrameWnd, WM_COMMAND, MAKEWPARAM(ID_EDIT_MODIFY, 0), 0);
|
*Result = TRUE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
else
|
||||||
case NM_SETFOCUS:
|
|
||||||
g_pChildWnd->nFocusPanel = 0;
|
|
||||||
break;
|
|
||||||
case LVN_BEGINLABELEDIT:
|
|
||||||
Info = (NMLVDISPINFO*)lParam;
|
|
||||||
if(Info)
|
|
||||||
{
|
{
|
||||||
PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
|
*Result = FALSE;
|
||||||
if(!lineinfo->name || !_tcscmp(lineinfo->name, _T("")))
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*Result = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
case LVN_ENDLABELEDIT:
|
||||||
|
Info = (NMLVDISPINFO*)lParam;
|
||||||
|
if(Info && Info->item.pszText)
|
||||||
|
{
|
||||||
|
PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
|
||||||
|
if(!lineinfo->name || !_tcscmp(lineinfo->name, _T("")))
|
||||||
|
{
|
||||||
|
*Result = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(_tcslen(Info->item.pszText) == 0)
|
||||||
{
|
{
|
||||||
|
TCHAR msg[128], caption[128];
|
||||||
|
|
||||||
|
LoadString(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, sizeof(msg)/sizeof(TCHAR));
|
||||||
|
LoadString(hInst, IDS_ERR_RENVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR));
|
||||||
|
MessageBox(0, msg, caption, 0);
|
||||||
*Result = TRUE;
|
*Result = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*Result = FALSE;
|
HKEY hKeyRoot;
|
||||||
|
LPCTSTR keyPath;
|
||||||
|
LONG lResult;
|
||||||
|
|
||||||
|
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
|
||||||
|
lResult = RenameValue(hKeyRoot, keyPath, Info->item.pszText, lineinfo->name);
|
||||||
|
lineinfo->name = realloc(lineinfo->name, (_tcslen(Info->item.pszText)+1)*sizeof(TCHAR));
|
||||||
|
if (lineinfo->name != NULL)
|
||||||
|
_tcscpy(lineinfo->name, Info->item.pszText);
|
||||||
|
|
||||||
|
*Result = TRUE;
|
||||||
|
return (lResult == ERROR_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
*Result = TRUE;
|
else
|
||||||
return TRUE;
|
*Result = TRUE;
|
||||||
case LVN_ENDLABELEDIT:
|
|
||||||
Info = (NMLVDISPINFO*)lParam;
|
|
||||||
if(Info && Info->item.pszText)
|
|
||||||
{
|
|
||||||
PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
|
|
||||||
if(!lineinfo->name || !_tcscmp(lineinfo->name, _T("")))
|
|
||||||
{
|
|
||||||
*Result = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(_tcslen(Info->item.pszText) == 0)
|
|
||||||
{
|
|
||||||
TCHAR msg[128], caption[128];
|
|
||||||
|
|
||||||
LoadString(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, sizeof(msg)/sizeof(TCHAR));
|
return TRUE;
|
||||||
LoadString(hInst, IDS_ERR_RENVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR));
|
|
||||||
MessageBox(0, msg, caption, 0);
|
|
||||||
*Result = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HKEY hKeyRoot;
|
|
||||||
LPCTSTR keyPath;
|
|
||||||
LONG lResult;
|
|
||||||
|
|
||||||
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
|
|
||||||
lResult = RenameValue(hKeyRoot, keyPath, Info->item.pszText, lineinfo->name);
|
|
||||||
lineinfo->name = realloc(lineinfo->name, (_tcslen(Info->item.pszText)+1)*sizeof(TCHAR));
|
|
||||||
if (lineinfo->name != NULL)
|
|
||||||
_tcscpy(lineinfo->name, Info->item.pszText);
|
|
||||||
|
|
||||||
*Result = TRUE;
|
|
||||||
return (lResult == ERROR_SUCCESS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*Result = TRUE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -500,10 +510,11 @@ fail:
|
||||||
void DestroyListView(HWND hwndLV)
|
void DestroyListView(HWND hwndLV)
|
||||||
{
|
{
|
||||||
INT count, i;
|
INT count, i;
|
||||||
LVITEM item;
|
LVITEM item;
|
||||||
|
|
||||||
count = ListView_GetItemCount(hwndLV);
|
count = ListView_GetItemCount(hwndLV);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
item.mask = LVIF_PARAM;
|
item.mask = LVIF_PARAM;
|
||||||
item.iItem = i;
|
item.iItem = i;
|
||||||
(void)ListView_GetItem(hwndLV, &item);
|
(void)ListView_GetItem(hwndLV, &item);
|
||||||
|
@ -555,7 +566,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
|
||||||
/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */
|
/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */
|
||||||
/* } */
|
/* } */
|
||||||
/* dwValSize = max_val_size; */
|
/* dwValSize = max_val_size; */
|
||||||
while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) {
|
while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
/* Add a terminating 0 character. Usually this is only necessary for strings. */
|
/* Add a terminating 0 character. Usually this is only necessary for strings. */
|
||||||
ValBuf[dwValSize] = 0;
|
ValBuf[dwValSize] = 0;
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
|
@ -568,7 +580,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
|
||||||
++dwIndex;
|
++dwIndex;
|
||||||
if(!_tcscmp(ValName, _T("")))
|
if(!_tcscmp(ValName, _T("")))
|
||||||
{
|
{
|
||||||
AddedDefault = TRUE;
|
AddedDefault = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, ValBuf);
|
HeapFree(GetProcessHeap(), 0, ValBuf);
|
||||||
|
@ -576,7 +588,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
|
||||||
}
|
}
|
||||||
if(!AddedDefault)
|
if(!AddedDefault)
|
||||||
{
|
{
|
||||||
AddEntryToList(hwndLV, _T(""), REG_SZ, NULL, 0, 0, FALSE);
|
AddEntryToList(hwndLV, _T(""), REG_SZ, NULL, 0, 0, FALSE);
|
||||||
}
|
}
|
||||||
ListView_SortItems(hwndLV, CompareFunc, (WPARAM)hwndLV);
|
ListView_SortItems(hwndLV, CompareFunc, (WPARAM)hwndLV);
|
||||||
c = ListView_GetItemCount(hwndLV);
|
c = ListView_GetItemCount(hwndLV);
|
||||||
|
@ -585,8 +597,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
|
||||||
ListView_SetItemState(hwndLV, i, 0, LVIS_FOCUSED | LVIS_SELECTED);
|
ListView_SetItemState(hwndLV, i, 0, LVIS_FOCUSED | LVIS_SELECTED);
|
||||||
}
|
}
|
||||||
ListView_SetItemState(hwndLV, iListViewSelect,
|
ListView_SetItemState(hwndLV, iListViewSelect,
|
||||||
LVIS_FOCUSED | LVIS_SELECTED,
|
LVIS_FOCUSED | LVIS_SELECTED,
|
||||||
LVIS_FOCUSED | LVIS_SELECTED);
|
LVIS_FOCUSED | LVIS_SELECTED);
|
||||||
RegCloseKey(hNewKey);
|
RegCloseKey(hNewKey);
|
||||||
SendMessage(hwndLV, WM_SETREDRAW, TRUE, 0);
|
SendMessage(hwndLV, WM_SETREDRAW, TRUE, 0);
|
||||||
|
|
||||||
|
|
|
@ -88,9 +88,9 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
wcChild.hInstance = hInstance;
|
wcChild.hInstance = hInstance;
|
||||||
wcChild.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT));
|
wcChild.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT));
|
||||||
wcChild.hCursor = LoadCursor(0, IDC_ARROW),
|
wcChild.hCursor = LoadCursor(0, IDC_ARROW),
|
||||||
wcChild.lpszClassName = szChildClass,
|
wcChild.lpszClassName = szChildClass,
|
||||||
wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
|
wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
|
||||||
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
||||||
|
|
||||||
RegisterClassEx(&wcChild); /* register child windows class */
|
RegisterClassEx(&wcChild); /* register child windows class */
|
||||||
|
|
||||||
|
@ -107,13 +107,13 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
AclUiAvailable = InitializeAclUiDll();
|
AclUiAvailable = InitializeAclUiDll();
|
||||||
if(!AclUiAvailable)
|
if(!AclUiAvailable)
|
||||||
{
|
{
|
||||||
/* hide the Edit/Permissions... menu entry */
|
/* hide the Edit/Permissions... menu entry */
|
||||||
if(hEditMenu != NULL)
|
if(hEditMenu != NULL)
|
||||||
{
|
{
|
||||||
RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND);
|
RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND);
|
||||||
/* remove the separator after the menu item */
|
/* remove the separator after the menu item */
|
||||||
RemoveMenu(hEditMenu, 4, MF_BYPOSITION);
|
RemoveMenu(hEditMenu, 4, MF_BYPOSITION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hEditMenu != NULL)
|
if(hEditMenu != NULL)
|
||||||
|
@ -129,14 +129,16 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
|
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
|
||||||
|
|
||||||
if (!hFrameWnd) {
|
if (!hFrameWnd)
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the status bar */
|
/* Create the status bar */
|
||||||
hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
|
hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
|
||||||
_T(""), hFrameWnd, STATUS_WINDOW);
|
_T(""), hFrameWnd, STATUS_WINDOW);
|
||||||
if (hStatusBar) {
|
if (hStatusBar)
|
||||||
|
{
|
||||||
/* Create the status bar panes */
|
/* Create the status bar panes */
|
||||||
SetupStatusBar(hFrameWnd, FALSE);
|
SetupStatusBar(hFrameWnd, FALSE);
|
||||||
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
|
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
|
||||||
|
@ -144,7 +146,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
|
|
||||||
/* Restore position */
|
/* Restore position */
|
||||||
if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("LastKey"),
|
if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("LastKey"),
|
||||||
szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS)
|
szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
SelectNode(g_pChildWnd->hTreeWnd, szBuffer);
|
SelectNode(g_pChildWnd->hTreeWnd, szBuffer);
|
||||||
}
|
}
|
||||||
|
@ -159,8 +161,9 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
/* we need to destroy the main menu before destroying the main window
|
/* we need to destroy the main menu before destroying the main window
|
||||||
to avoid a memory leak */
|
to avoid a memory leak */
|
||||||
|
|
||||||
void DestroyMainMenu() {
|
void DestroyMainMenu()
|
||||||
DestroyMenu(hMenuFrame);
|
{
|
||||||
|
DestroyMenu(hMenuFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -175,11 +178,11 @@ void ExitInstance(HINSTANCE hInstance)
|
||||||
|
|
||||||
BOOL TranslateChildTabMessage(MSG *msg)
|
BOOL TranslateChildTabMessage(MSG *msg)
|
||||||
{
|
{
|
||||||
if (msg->message != WM_KEYDOWN) return FALSE;
|
if (msg->message != WM_KEYDOWN) return FALSE;
|
||||||
if (msg->wParam != VK_TAB) return FALSE;
|
if (msg->wParam != VK_TAB) return FALSE;
|
||||||
if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
|
if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
|
||||||
PostMessage(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
|
PostMessage(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APIENTRY wWinMain(HINSTANCE hInstance,
|
int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||||
|
@ -192,7 +195,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
|
|
||||||
if (ProcessCmdLine(lpCmdLine)) {
|
if (ProcessCmdLine(lpCmdLine))
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,15 +209,18 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||||
hInst = hInstance;
|
hInst = hInstance;
|
||||||
|
|
||||||
/* Perform application initialization */
|
/* Perform application initialization */
|
||||||
if (!InitInstance(hInstance, nCmdShow)) {
|
if (!InitInstance(hInstance, nCmdShow))
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCEL));
|
hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCEL));
|
||||||
|
|
||||||
/* Main message loop */
|
/* Main message loop */
|
||||||
while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
|
while (GetMessage(&msg, (HWND)NULL, 0, 0))
|
||||||
|
{
|
||||||
if (!TranslateAccelerator(hFrameWnd, hAccel, &msg)
|
if (!TranslateAccelerator(hFrameWnd, hAccel, &msg)
|
||||||
&& !TranslateChildTabMessage(&msg)) {
|
&& !TranslateChildTabMessage(&msg))
|
||||||
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,8 @@ extern HINSTANCE hInst;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
enum OPTION_FLAGS {
|
enum OPTION_FLAGS
|
||||||
|
{
|
||||||
OPTIONS_AUTO_REFRESH = 0x01,
|
OPTIONS_AUTO_REFRESH = 0x01,
|
||||||
OPTIONS_READ_ONLY_MODE = 0x02,
|
OPTIONS_READ_ONLY_MODE = 0x02,
|
||||||
OPTIONS_CONFIRM_ON_DELETE = 0x04,
|
OPTIONS_CONFIRM_ON_DELETE = 0x04,
|
||||||
|
@ -53,12 +54,13 @@ enum OPTION_FLAGS {
|
||||||
OPTIONS_VIEW_DATA_ONLY = 0x40,
|
OPTIONS_VIEW_DATA_ONLY = 0x40,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
HWND hTreeWnd;
|
HWND hTreeWnd;
|
||||||
HWND hListWnd;
|
HWND hListWnd;
|
||||||
HWND hAddressBarWnd;
|
HWND hAddressBarWnd;
|
||||||
HWND hAddressBtnWnd;
|
HWND hAddressBtnWnd;
|
||||||
int nFocusPanel; /* 0: left 1: right */
|
int nFocusPanel; /* 0: left 1: right */
|
||||||
int nSplitPos;
|
int nSplitPos;
|
||||||
WINDOWPLACEMENT pos;
|
WINDOWPLACEMENT pos;
|
||||||
|
|
|
@ -52,7 +52,8 @@ static const char *usage =
|
||||||
"This program is command-line compatible with Microsoft Windows\n"
|
"This program is command-line compatible with Microsoft Windows\n"
|
||||||
"regedit.\n";
|
"regedit.\n";
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
|
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
|
||||||
} REGEDIT_ACTION;
|
} REGEDIT_ACTION;
|
||||||
|
|
||||||
|
@ -79,40 +80,52 @@ void get_file_name(LPWSTR *command_line, LPWSTR file_name)
|
||||||
int pos = 0; /* position of pointer "s" in *command_line */
|
int pos = 0; /* position of pointer "s" in *command_line */
|
||||||
file_name[0] = 0;
|
file_name[0] = 0;
|
||||||
|
|
||||||
if (!s[0]) {
|
if (!s[0])
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s[0] == L'"') {
|
if (s[0] == L'"')
|
||||||
|
{
|
||||||
s++;
|
s++;
|
||||||
(*command_line)++;
|
(*command_line)++;
|
||||||
while(s[0] != L'"') {
|
while(s[0] != L'"')
|
||||||
if (!s[0]) {
|
{
|
||||||
|
if (!s[0])
|
||||||
|
{
|
||||||
fprintf(stderr, "%s: Unexpected end of file name!\n", getAppName());
|
fprintf(stderr, "%s: Unexpected end of file name!\n", getAppName());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
while(s[0] && !iswspace(s[0])) {
|
else
|
||||||
|
{
|
||||||
|
while(s[0] && !iswspace(s[0]))
|
||||||
|
{
|
||||||
s++;
|
s++;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(file_name, *command_line, pos * sizeof((*command_line)[0]));
|
memcpy(file_name, *command_line, pos * sizeof((*command_line)[0]));
|
||||||
/* remove the last backslash */
|
/* remove the last backslash */
|
||||||
if (file_name[pos - 1] == L'\\') {
|
if (file_name[pos - 1] == L'\\')
|
||||||
|
{
|
||||||
file_name[pos - 1] = L'\0';
|
file_name[pos - 1] = L'\0';
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
file_name[pos] = L'\0';
|
file_name[pos] = L'\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s[0]) {
|
if (s[0])
|
||||||
|
{
|
||||||
s++;
|
s++;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
while(s[0] && iswspace(s[0])) {
|
while(s[0] && iswspace(s[0]))
|
||||||
|
{
|
||||||
s++;
|
s++;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
@ -121,64 +134,75 @@ void get_file_name(LPWSTR *command_line, LPWSTR file_name)
|
||||||
|
|
||||||
BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s)
|
BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s)
|
||||||
{
|
{
|
||||||
switch (action) {
|
switch (action)
|
||||||
case ACTION_ADD: {
|
{
|
||||||
WCHAR filename[MAX_PATH];
|
case ACTION_ADD:
|
||||||
FILE *fp;
|
{
|
||||||
|
WCHAR filename[MAX_PATH];
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
get_file_name(&s, filename);
|
get_file_name(&s, filename);
|
||||||
if (!filename[0]) {
|
if (!filename[0])
|
||||||
fprintf(stderr, "%s: No file name is specified\n", getAppName());
|
{
|
||||||
fprintf(stderr, usage);
|
fprintf(stderr, "%s: No file name is specified\n", getAppName());
|
||||||
exit(4);
|
fprintf(stderr, usage);
|
||||||
}
|
exit(4);
|
||||||
|
|
||||||
while(filename[0]) {
|
|
||||||
fp = _wfopen(filename, L"r");
|
|
||||||
if (fp == NULL)
|
|
||||||
{
|
|
||||||
LPSTR p = GetMultiByteString(filename);
|
|
||||||
perror("");
|
|
||||||
fprintf(stderr, "%s: Can't open file \"%s\"\n", getAppName(), p);
|
|
||||||
HeapFree(GetProcessHeap(), 0, p);
|
|
||||||
exit(5);
|
|
||||||
}
|
|
||||||
import_registry_file(fp);
|
|
||||||
get_file_name(&s, filename);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case ACTION_DELETE: {
|
|
||||||
|
while(filename[0])
|
||||||
|
{
|
||||||
|
fp = _wfopen(filename, L"r");
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
LPSTR p = GetMultiByteString(filename);
|
||||||
|
perror("");
|
||||||
|
fprintf(stderr, "%s: Can't open file \"%s\"\n", getAppName(), p);
|
||||||
|
HeapFree(GetProcessHeap(), 0, p);
|
||||||
|
exit(5);
|
||||||
|
}
|
||||||
|
import_registry_file(fp);
|
||||||
|
get_file_name(&s, filename);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_DELETE:
|
||||||
|
{
|
||||||
|
WCHAR reg_key_name[KEY_MAX_LEN];
|
||||||
|
get_file_name(&s, reg_key_name);
|
||||||
|
if (!reg_key_name[0])
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: No registry key is specified for removal\n", getAppName());
|
||||||
|
fprintf(stderr, usage);
|
||||||
|
exit(6);
|
||||||
|
}
|
||||||
|
delete_registry_key(reg_key_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_EXPORT:
|
||||||
|
{
|
||||||
|
WCHAR filename[MAX_PATH];
|
||||||
|
|
||||||
|
filename[0] = _T('\0');
|
||||||
|
get_file_name(&s, filename);
|
||||||
|
if (!filename[0])
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: No file name is specified\n", getAppName());
|
||||||
|
fprintf(stderr, usage);
|
||||||
|
exit(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s[0])
|
||||||
|
{
|
||||||
WCHAR reg_key_name[KEY_MAX_LEN];
|
WCHAR reg_key_name[KEY_MAX_LEN];
|
||||||
get_file_name(&s, reg_key_name);
|
get_file_name(&s, reg_key_name);
|
||||||
if (!reg_key_name[0]) {
|
export_registry_key(filename, reg_key_name, REG_FORMAT_4);
|
||||||
fprintf(stderr, "%s: No registry key is specified for removal\n", getAppName());
|
|
||||||
fprintf(stderr, usage);
|
|
||||||
exit(6);
|
|
||||||
}
|
|
||||||
delete_registry_key(reg_key_name);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case ACTION_EXPORT: {
|
else
|
||||||
WCHAR filename[MAX_PATH];
|
{
|
||||||
|
export_registry_key(filename, NULL, REG_FORMAT_4);
|
||||||
filename[0] = _T('\0');
|
|
||||||
get_file_name(&s, filename);
|
|
||||||
if (!filename[0]) {
|
|
||||||
fprintf(stderr, "%s: No file name is specified\n", getAppName());
|
|
||||||
fprintf(stderr, usage);
|
|
||||||
exit(7);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s[0]) {
|
|
||||||
WCHAR reg_key_name[KEY_MAX_LEN];
|
|
||||||
get_file_name(&s, reg_key_name);
|
|
||||||
export_registry_key(filename, reg_key_name, REG_FORMAT_4);
|
|
||||||
} else {
|
|
||||||
export_registry_key(filename, NULL, REG_FORMAT_4);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: Unhandled action!\n", getAppName());
|
fprintf(stderr, "%s: Unhandled action!\n", getAppName());
|
||||||
exit(8);
|
exit(8);
|
||||||
|
@ -196,9 +220,12 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s)
|
||||||
*/
|
*/
|
||||||
static void error_unknown_switch(WCHAR chu, LPWSTR s)
|
static void error_unknown_switch(WCHAR chu, LPWSTR s)
|
||||||
{
|
{
|
||||||
if (iswalpha(chu)) {
|
if (iswalpha(chu))
|
||||||
|
{
|
||||||
fprintf(stderr, "%s: Undefined switch /%c!\n", getAppName(), chu);
|
fprintf(stderr, "%s: Undefined switch /%c!\n", getAppName(), chu);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
fprintf(stderr, "%s: Alphabetic character is expected after '%c' "
|
fprintf(stderr, "%s: Alphabetic character is expected after '%c' "
|
||||||
"in swit ch specification\n", getAppName(), *(s - 1));
|
"in swit ch specification\n", getAppName(), *(s - 1));
|
||||||
}
|
}
|
||||||
|
@ -220,12 +247,16 @@ BOOL ProcessCmdLine(LPWSTR lpCmdLine)
|
||||||
ch = *s;
|
ch = *s;
|
||||||
ch2 = *(s + 1);
|
ch2 = *(s + 1);
|
||||||
chu = (WCHAR)towupper(ch);
|
chu = (WCHAR)towupper(ch);
|
||||||
if (!ch2 || iswspace(ch2)) {
|
if (!ch2 || iswspace(ch2))
|
||||||
|
{
|
||||||
if (chu == L'S' || chu == L'V')
|
if (chu == L'S' || chu == L'V')
|
||||||
{
|
{
|
||||||
/* ignore these switches */
|
/* ignore these switches */
|
||||||
} else {
|
}
|
||||||
switch (chu) {
|
else
|
||||||
|
{
|
||||||
|
switch (chu)
|
||||||
|
{
|
||||||
case L'D':
|
case L'D':
|
||||||
action = ACTION_DELETE;
|
action = ACTION_DELETE;
|
||||||
break;
|
break;
|
||||||
|
@ -242,14 +273,19 @@ BOOL ProcessCmdLine(LPWSTR lpCmdLine)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
} else {
|
}
|
||||||
if (ch2 == L':') {
|
else
|
||||||
switch (chu) {
|
{
|
||||||
|
if (ch2 == L':')
|
||||||
|
{
|
||||||
|
switch (chu)
|
||||||
|
{
|
||||||
case L'L':
|
case L'L':
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case L'R':
|
case L'R':
|
||||||
s += 2;
|
s += 2;
|
||||||
while (*s && !iswspace(*s)) {
|
while (*s && !iswspace(*s))
|
||||||
|
{
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -257,7 +293,9 @@ BOOL ProcessCmdLine(LPWSTR lpCmdLine)
|
||||||
error_unknown_switch(chu, s);
|
error_unknown_switch(chu, s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* this is a file name, starting from '/' */
|
/* this is a file name, starting from '/' */
|
||||||
s--;
|
s--;
|
||||||
break;
|
break;
|
||||||
|
@ -265,7 +303,8 @@ BOOL ProcessCmdLine(LPWSTR lpCmdLine)
|
||||||
}
|
}
|
||||||
/* skip spaces to the next parameter */
|
/* skip spaces to the next parameter */
|
||||||
ch = *s;
|
ch = *s;
|
||||||
while (ch && iswspace(ch)) {
|
while (ch && iswspace(ch))
|
||||||
|
{
|
||||||
s++;
|
s++;
|
||||||
ch = *s;
|
ch = *s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,10 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
|
||||||
#include "rsrc.rc"
|
#include "rsrc.rc"
|
||||||
|
|
||||||
IDI_OPEN_FILE ICON DISCARDABLE res/folderopen.ico
|
IDI_OPEN_FILE ICON DISCARDABLE res/folderopen.ico
|
||||||
IDI_CLOSED_FILE ICON DISCARDABLE res/folder.ico
|
IDI_CLOSED_FILE ICON DISCARDABLE res/folder.ico
|
||||||
IDI_ROOT ICON DISCARDABLE res/computer.ico
|
IDI_ROOT ICON DISCARDABLE res/computer.ico
|
||||||
IDI_STRING ICON DISCARDABLE res/string.ico
|
IDI_STRING ICON DISCARDABLE res/string.ico
|
||||||
IDI_BIN ICON DISCARDABLE res/bin.ico
|
IDI_BIN ICON DISCARDABLE res/bin.ico
|
||||||
IDI_REGEDIT ICON DISCARDABLE res/regedit.ico
|
IDI_REGEDIT ICON DISCARDABLE res/regedit.ico
|
||||||
IDI_REGFILE ICON DISCARDABLE res/regfile.ico
|
IDI_REGFILE ICON DISCARDABLE res/regfile.ico
|
||||||
|
|
|
@ -30,22 +30,25 @@
|
||||||
*/
|
*/
|
||||||
#define REG_FILE_HEX_LINE_LEN (2 + 25 * 3)
|
#define REG_FILE_HEX_LINE_LEN (2 + 25 * 3)
|
||||||
|
|
||||||
static const CHAR *reg_class_names[] = {
|
static const CHAR *reg_class_names[] =
|
||||||
"HKEY_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CLASSES_ROOT",
|
{
|
||||||
"HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER", "HKEY_DYN_DATA"
|
"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]))
|
#define REG_CLASS_NUMBER (sizeof(reg_class_names) / sizeof(reg_class_names[0]))
|
||||||
|
|
||||||
const WCHAR* reg_class_namesW[REG_CLASS_NUMBER] = {
|
const WCHAR* reg_class_namesW[REG_CLASS_NUMBER] =
|
||||||
|
{
|
||||||
L"HKEY_LOCAL_MACHINE", L"HKEY_USERS", L"HKEY_CLASSES_ROOT",
|
L"HKEY_LOCAL_MACHINE", L"HKEY_USERS", L"HKEY_CLASSES_ROOT",
|
||||||
L"HKEY_CURRENT_CONFIG", L"HKEY_CURRENT_USER", L"HKEY_DYN_DATA"
|
L"HKEY_CURRENT_CONFIG", L"HKEY_CURRENT_USER", L"HKEY_DYN_DATA"
|
||||||
};
|
};
|
||||||
|
|
||||||
static HKEY reg_class_keys[REG_CLASS_NUMBER] = {
|
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
|
HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT,
|
||||||
};
|
HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA
|
||||||
|
};
|
||||||
|
|
||||||
/* return values */
|
/* return values */
|
||||||
#define NOT_ENOUGH_MEMORY 1
|
#define NOT_ENOUGH_MEMORY 1
|
||||||
|
@ -149,7 +152,8 @@ static BOOL convertHexToDWord(WCHAR* str, DWORD *dw)
|
||||||
char dummy;
|
char dummy;
|
||||||
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, 9, NULL, NULL);
|
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, 9, NULL, NULL);
|
||||||
if (lstrlenW(str) > 8 || sscanf(buf, "%lx%c", dw, &dummy) != 1) {
|
if (lstrlenW(str) > 8 || sscanf(buf, "%lx%c", dw, &dummy) != 1)
|
||||||
|
{
|
||||||
fprintf(stderr,"%s: ERROR, invalid hex value\n", getAppName());
|
fprintf(stderr,"%s: ERROR, invalid hex value\n", getAppName());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -172,12 +176,14 @@ static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size)
|
||||||
s = str;
|
s = str;
|
||||||
d = data;
|
d = data;
|
||||||
*size=0;
|
*size=0;
|
||||||
while (*s != '\0') {
|
while (*s != '\0')
|
||||||
|
{
|
||||||
UINT wc;
|
UINT wc;
|
||||||
WCHAR *end;
|
WCHAR *end;
|
||||||
|
|
||||||
wc = wcstoul(s,&end, 16);
|
wc = wcstoul(s,&end, 16);
|
||||||
if (end == s || wc > 0xff || (*end && *end != L',')) {
|
if (end == s || wc > 0xff || (*end && *end != L','))
|
||||||
|
{
|
||||||
char* strA = GetMultiByteString(s);
|
char* strA = GetMultiByteString(s);
|
||||||
fprintf(stderr,"%s: ERROR converting CSV hex stream. Invalid value at '%s'\n",
|
fprintf(stderr,"%s: ERROR converting CSV hex stream. Invalid value at '%s'\n",
|
||||||
getAppName(), strA);
|
getAppName(), strA);
|
||||||
|
@ -203,7 +209,13 @@ static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size)
|
||||||
*/
|
*/
|
||||||
static DWORD getDataType(LPWSTR *lpValue, DWORD* parse_type)
|
static DWORD getDataType(LPWSTR *lpValue, DWORD* parse_type)
|
||||||
{
|
{
|
||||||
struct data_type { const WCHAR *tag; int len; int type; int parse_type; };
|
struct data_type
|
||||||
|
{
|
||||||
|
const WCHAR *tag;
|
||||||
|
int len;
|
||||||
|
int type;
|
||||||
|
int parse_type;
|
||||||
|
};
|
||||||
|
|
||||||
static const WCHAR quote[] = {'"'};
|
static const WCHAR quote[] = {'"'};
|
||||||
static const WCHAR str[] = {'s','t','r',':','"'};
|
static const WCHAR str[] = {'s','t','r',':','"'};
|
||||||
|
@ -213,19 +225,20 @@ static DWORD getDataType(LPWSTR *lpValue, DWORD* parse_type)
|
||||||
static const WCHAR hexp[] = {'h','e','x','('};
|
static const WCHAR hexp[] = {'h','e','x','('};
|
||||||
|
|
||||||
static const struct data_type data_types[] = { /* actual type */ /* type to assume for parsing */
|
static const struct data_type data_types[] = { /* actual type */ /* type to assume for parsing */
|
||||||
{ quote, 1, REG_SZ, REG_SZ },
|
{ quote, 1, REG_SZ, REG_SZ },
|
||||||
{ str, 5, REG_SZ, REG_SZ },
|
{ str, 5, REG_SZ, REG_SZ },
|
||||||
{ str2, 8, REG_EXPAND_SZ, REG_SZ },
|
{ str2, 8, REG_EXPAND_SZ, REG_SZ },
|
||||||
{ hex, 4, REG_BINARY, REG_BINARY },
|
{ hex, 4, REG_BINARY, REG_BINARY },
|
||||||
{ dword, 6, REG_DWORD, REG_DWORD },
|
{ dword, 6, REG_DWORD, REG_DWORD },
|
||||||
{ hexp, 4, -1, REG_BINARY },
|
{ hexp, 4, -1, REG_BINARY },
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct data_type *ptr;
|
const struct data_type *ptr;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
for (ptr = data_types; ptr->tag; ptr++) {
|
for (ptr = data_types; ptr->tag; ptr++)
|
||||||
|
{
|
||||||
if (wcsncmp(ptr->tag, *lpValue, ptr->len))
|
if (wcsncmp(ptr->tag, *lpValue, ptr->len))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -233,14 +246,18 @@ static DWORD getDataType(LPWSTR *lpValue, DWORD* parse_type)
|
||||||
*parse_type = ptr->parse_type;
|
*parse_type = ptr->parse_type;
|
||||||
type=ptr->type;
|
type=ptr->type;
|
||||||
*lpValue+=ptr->len;
|
*lpValue+=ptr->len;
|
||||||
if (type == -1) {
|
if (type == -1)
|
||||||
|
{
|
||||||
WCHAR* end;
|
WCHAR* end;
|
||||||
|
|
||||||
/* "hex(xx):" is special */
|
/* "hex(xx):" is special */
|
||||||
type = (int)wcstoul( *lpValue , &end, 16 );
|
type = (int)wcstoul( *lpValue , &end, 16 );
|
||||||
if (**lpValue=='\0' || *end!=')' || *(end+1)!=':') {
|
if (**lpValue=='\0' || *end!=')' || *(end+1)!=':')
|
||||||
|
{
|
||||||
type=REG_NONE;
|
type=REG_NONE;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*lpValue = end + 2;
|
*lpValue = end + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,10 +275,13 @@ static void REGPROC_unescape_string(WCHAR* str)
|
||||||
int str_idx = 0; /* current character under analysis */
|
int str_idx = 0; /* current character under analysis */
|
||||||
int val_idx = 0; /* the last character of the unescaped string */
|
int val_idx = 0; /* the last character of the unescaped string */
|
||||||
int len = lstrlenW(str);
|
int len = lstrlenW(str);
|
||||||
for (str_idx = 0; str_idx < len; str_idx++, val_idx++) {
|
for (str_idx = 0; str_idx < len; str_idx++, val_idx++)
|
||||||
if (str[str_idx] == '\\') {
|
{
|
||||||
|
if (str[str_idx] == '\\')
|
||||||
|
{
|
||||||
str_idx++;
|
str_idx++;
|
||||||
switch (str[str_idx]) {
|
switch (str[str_idx])
|
||||||
|
{
|
||||||
case 'n':
|
case 'n':
|
||||||
str[val_idx] = '\n';
|
str[val_idx] = '\n';
|
||||||
break;
|
break;
|
||||||
|
@ -271,11 +291,13 @@ static void REGPROC_unescape_string(WCHAR* str)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"Warning! Unrecognized escape sequence: \\%c'\n",
|
fprintf(stderr,"Warning! Unrecognized escape sequence: \\%c'\n",
|
||||||
str[str_idx]);
|
str[str_idx]);
|
||||||
str[val_idx] = str[str_idx];
|
str[val_idx] = str[str_idx];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
str[val_idx] = str[str_idx];
|
str[val_idx] = str[str_idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,9 +332,11 @@ static BOOL parseKeyName(LPWSTR lpKeyName, HKEY *hKey, LPWSTR *lpKeyPath)
|
||||||
}
|
}
|
||||||
*hKey = NULL;
|
*hKey = NULL;
|
||||||
|
|
||||||
for (i = 0; i < REG_CLASS_NUMBER; i++) {
|
for (i = 0; i < REG_CLASS_NUMBER; i++)
|
||||||
|
{
|
||||||
if (CompareStringW(LOCALE_USER_DEFAULT, 0, lpKeyName, len, reg_class_namesW[i], len) == CSTR_EQUAL &&
|
if (CompareStringW(LOCALE_USER_DEFAULT, 0, lpKeyName, len, reg_class_namesW[i], len) == CSTR_EQUAL &&
|
||||||
len == lstrlenW(reg_class_namesW[i])) {
|
len == lstrlenW(reg_class_namesW[i]))
|
||||||
|
{
|
||||||
*hKey = reg_class_keys[i];
|
*hKey = reg_class_keys[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -404,12 +428,12 @@ static LONG setValue(WCHAR* val_name, WCHAR* val_data, BOOL is_unicode)
|
||||||
}
|
}
|
||||||
|
|
||||||
res = RegSetValueExW(
|
res = RegSetValueExW(
|
||||||
currentKeyHandle,
|
currentKeyHandle,
|
||||||
val_name,
|
val_name,
|
||||||
0, /* Reserved */
|
0, /* Reserved */
|
||||||
dwDataType,
|
dwDataType,
|
||||||
lpbData,
|
lpbData,
|
||||||
dwLen);
|
dwLen);
|
||||||
if (dwParseType == REG_BINARY)
|
if (dwParseType == REG_BINARY)
|
||||||
HeapFree(GetProcessHeap(), 0, lpbData);
|
HeapFree(GetProcessHeap(), 0, lpbData);
|
||||||
return res;
|
return res;
|
||||||
|
@ -435,15 +459,15 @@ static LONG openKeyW(WCHAR* stdInput)
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
|
||||||
res = RegCreateKeyExW(
|
res = RegCreateKeyExW(
|
||||||
keyClass, /* Class */
|
keyClass, /* Class */
|
||||||
keyPath, /* Sub Key */
|
keyPath, /* Sub Key */
|
||||||
0, /* MUST BE 0 */
|
0, /* MUST BE 0 */
|
||||||
NULL, /* object type */
|
NULL, /* object type */
|
||||||
REG_OPTION_NON_VOLATILE, /* option, REG_OPTION_NON_VOLATILE ... */
|
REG_OPTION_NON_VOLATILE, /* option, REG_OPTION_NON_VOLATILE ... */
|
||||||
KEY_ALL_ACCESS, /* access mask, KEY_ALL_ACCESS */
|
KEY_ALL_ACCESS, /* access mask, KEY_ALL_ACCESS */
|
||||||
NULL, /* security attribute */
|
NULL, /* security attribute */
|
||||||
¤tKeyHandle, /* result */
|
¤tKeyHandle, /* result */
|
||||||
&dwDisp); /* disposition, REG_CREATED_NEW_KEY or
|
&dwDisp); /* disposition, REG_CREATED_NEW_KEY or
|
||||||
REG_OPENED_EXISTING_KEY */
|
REG_OPENED_EXISTING_KEY */
|
||||||
|
|
||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
|
@ -485,29 +509,39 @@ static void processSetValue(WCHAR* line, BOOL is_unicode)
|
||||||
|
|
||||||
/* get value name */
|
/* get value name */
|
||||||
while ( iswspace(line[line_idx]) ) line_idx++;
|
while ( iswspace(line[line_idx]) ) line_idx++;
|
||||||
if (line[line_idx] == '@' && line[line_idx + 1] == '=') {
|
if (line[line_idx] == '@' && line[line_idx + 1] == '=')
|
||||||
|
{
|
||||||
line[line_idx] = '\0';
|
line[line_idx] = '\0';
|
||||||
val_name = line;
|
val_name = line;
|
||||||
line_idx++;
|
line_idx++;
|
||||||
} else if (line[line_idx] == '\"') {
|
}
|
||||||
|
else if (line[line_idx] == '\"')
|
||||||
|
{
|
||||||
line_idx++;
|
line_idx++;
|
||||||
val_name = line + line_idx;
|
val_name = line + line_idx;
|
||||||
while (TRUE) {
|
while (TRUE)
|
||||||
|
{
|
||||||
if (line[line_idx] == '\\') /* skip escaped character */
|
if (line[line_idx] == '\\') /* skip escaped character */
|
||||||
{
|
{
|
||||||
line_idx += 2;
|
line_idx += 2;
|
||||||
} else {
|
}
|
||||||
if (line[line_idx] == '\"') {
|
else
|
||||||
|
{
|
||||||
|
if (line[line_idx] == '\"')
|
||||||
|
{
|
||||||
line[line_idx] = '\0';
|
line[line_idx] = '\0';
|
||||||
line_idx++;
|
line_idx++;
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
line_idx++;
|
line_idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ( iswspace(line[line_idx]) ) line_idx++;
|
while ( iswspace(line[line_idx]) ) line_idx++;
|
||||||
if (line[line_idx] != '=') {
|
if (line[line_idx] != '=')
|
||||||
|
{
|
||||||
char* lineA;
|
char* lineA;
|
||||||
line[line_idx] = '\"';
|
line[line_idx] = '\"';
|
||||||
lineA = GetMultiByteString(line);
|
lineA = GetMultiByteString(line);
|
||||||
|
@ -516,7 +550,9 @@ static void processSetValue(WCHAR* line, BOOL is_unicode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
char* lineA = GetMultiByteString(line);
|
char* lineA = GetMultiByteString(line);
|
||||||
fprintf(stderr,"Warning! unrecognized line:\n%s\n", lineA);
|
fprintf(stderr,"Warning! unrecognized line:\n%s\n", lineA);
|
||||||
HeapFree(GetProcessHeap(), 0, lineA);
|
HeapFree(GetProcessHeap(), 0, lineA);
|
||||||
|
@ -538,10 +574,10 @@ static void processSetValue(WCHAR* line, BOOL is_unicode)
|
||||||
char* val_nameA = GetMultiByteString(val_name);
|
char* val_nameA = GetMultiByteString(val_name);
|
||||||
char* val_dataA = GetMultiByteString(val_data);
|
char* val_dataA = GetMultiByteString(val_data);
|
||||||
fprintf(stderr,"%s: ERROR Key %s not created. Value: %s, Data: %s\n",
|
fprintf(stderr,"%s: ERROR Key %s not created. Value: %s, Data: %s\n",
|
||||||
getAppName(),
|
getAppName(),
|
||||||
currentKeyName,
|
currentKeyName,
|
||||||
val_nameA,
|
val_nameA,
|
||||||
val_dataA);
|
val_dataA);
|
||||||
HeapFree(GetProcessHeap(), 0, val_nameA);
|
HeapFree(GetProcessHeap(), 0, val_nameA);
|
||||||
HeapFree(GetProcessHeap(), 0, val_dataA);
|
HeapFree(GetProcessHeap(), 0, val_dataA);
|
||||||
}
|
}
|
||||||
|
@ -558,7 +594,8 @@ static void processRegEntry(WCHAR* stdInput, BOOL isUnicode)
|
||||||
* We encountered the end of the file, make sure we
|
* We encountered the end of the file, make sure we
|
||||||
* close the opened key and exit
|
* close the opened key and exit
|
||||||
*/
|
*/
|
||||||
if (stdInput == NULL) {
|
if (stdInput == NULL)
|
||||||
|
{
|
||||||
closeKey();
|
closeKey();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -578,19 +615,22 @@ static void processRegEntry(WCHAR* stdInput, BOOL isUnicode)
|
||||||
if ( stdInput[0] == '-')
|
if ( stdInput[0] == '-')
|
||||||
{
|
{
|
||||||
delete_registry_key(stdInput + 1);
|
delete_registry_key(stdInput + 1);
|
||||||
} else if ( openKeyW(stdInput) != ERROR_SUCCESS )
|
}
|
||||||
|
else if ( openKeyW(stdInput) != ERROR_SUCCESS )
|
||||||
{
|
{
|
||||||
char* stdInputA = GetMultiByteString(stdInput);
|
char* stdInputA = GetMultiByteString(stdInput);
|
||||||
fprintf(stderr,"%s: setValue failed to open key %s\n",
|
fprintf(stderr,"%s: setValue failed to open key %s\n",
|
||||||
getAppName(), stdInputA);
|
getAppName(), stdInputA);
|
||||||
HeapFree(GetProcessHeap(), 0, stdInputA);
|
HeapFree(GetProcessHeap(), 0, stdInputA);
|
||||||
}
|
}
|
||||||
} else if( currentKeyHandle &&
|
}
|
||||||
(( stdInput[0] == '@') || /* reading a default @=data pair */
|
else if( currentKeyHandle &&
|
||||||
( stdInput[0] == '\"'))) /* reading a new value=data pair */
|
(( stdInput[0] == '@') || /* reading a default @=data pair */
|
||||||
|
( stdInput[0] == '\"'))) /* reading a new value=data pair */
|
||||||
{
|
{
|
||||||
processSetValue(stdInput, isUnicode);
|
processSetValue(stdInput, isUnicode);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* Since we are assuming that the file format is valid we must be
|
/* Since we are assuming that the file format is valid we must be
|
||||||
* reading a blank line which indicates the end of this key processing
|
* reading a blank line which indicates the end of this key processing
|
||||||
|
@ -614,13 +654,15 @@ static void processRegLinesA(FILE *in)
|
||||||
line = HeapAlloc(GetProcessHeap(), 0, lineSize);
|
line = HeapAlloc(GetProcessHeap(), 0, lineSize);
|
||||||
CHECK_ENOUGH_MEMORY(line);
|
CHECK_ENOUGH_MEMORY(line);
|
||||||
|
|
||||||
while (!feof(in)) {
|
while (!feof(in))
|
||||||
|
{
|
||||||
LPSTR s; /* The pointer into line for where the current fgets should read */
|
LPSTR s; /* The pointer into line for where the current fgets should read */
|
||||||
LPSTR check;
|
LPSTR check;
|
||||||
WCHAR* lineW;
|
WCHAR* lineW;
|
||||||
s = line;
|
s = line;
|
||||||
|
|
||||||
for (;;) {
|
for (;;)
|
||||||
|
{
|
||||||
size_t size_remaining;
|
size_t size_remaining;
|
||||||
int size_to_get;
|
int size_to_get;
|
||||||
char *s_eol; /* various local uses */
|
char *s_eol; /* various local uses */
|
||||||
|
@ -650,11 +692,15 @@ static void processRegLinesA(FILE *in)
|
||||||
|
|
||||||
check = fgets (s, size_to_get, in);
|
check = fgets (s, size_to_get, in);
|
||||||
|
|
||||||
if (check == NULL) {
|
if (check == NULL)
|
||||||
if (ferror(in)) {
|
{
|
||||||
|
if (ferror(in))
|
||||||
|
{
|
||||||
perror ("While reading input");
|
perror ("While reading input");
|
||||||
exit (IO_ERROR);
|
exit (IO_ERROR);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
assert (feof(in));
|
assert (feof(in));
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
/* It is not clear to me from the definition that the
|
/* It is not clear to me from the definition that the
|
||||||
|
@ -666,40 +712,46 @@ static void processRegLinesA(FILE *in)
|
||||||
|
|
||||||
/* If we didn't read the eol nor the eof go around for the rest */
|
/* If we didn't read the eol nor the eof go around for the rest */
|
||||||
s_eol = strchr (s, '\n');
|
s_eol = strchr (s, '\n');
|
||||||
if (!feof (in) && !s_eol) {
|
if (!feof (in) && !s_eol)
|
||||||
|
{
|
||||||
s = strchr (s, '\0');
|
s = strchr (s, '\0');
|
||||||
/* It should be s + size_to_get - 1 but this is safer */
|
/* It should be s + size_to_get - 1 but this is safer */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If it is a comment line then discard it and go around again */
|
/* If it is a comment line then discard it and go around again */
|
||||||
if (line [0] == '#') {
|
if (line [0] == '#')
|
||||||
|
{
|
||||||
s = line;
|
s = line;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove any line feed. Leave s_eol on the \0 */
|
/* Remove any line feed. Leave s_eol on the \0 */
|
||||||
if (s_eol) {
|
if (s_eol)
|
||||||
|
{
|
||||||
*s_eol = '\0';
|
*s_eol = '\0';
|
||||||
if (s_eol > line && *(s_eol-1) == '\r')
|
if (s_eol > line && *(s_eol-1) == '\r')
|
||||||
*--s_eol = '\0';
|
*--s_eol = '\0';
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
s_eol = strchr (s, '\0');
|
s_eol = strchr (s, '\0');
|
||||||
|
|
||||||
/* If there is a concatenating \\ then go around again */
|
/* If there is a concatenating \\ then go around again */
|
||||||
if (s_eol > line && *(s_eol-1) == '\\') {
|
if (s_eol > line && *(s_eol-1) == '\\')
|
||||||
|
{
|
||||||
int c;
|
int c;
|
||||||
s = s_eol-1;
|
s = s_eol-1;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
c = fgetc(in);
|
c = fgetc(in);
|
||||||
} while(c == ' ' || c == '\t');
|
}
|
||||||
|
while(c == ' ' || c == '\t');
|
||||||
|
|
||||||
if(c == EOF)
|
if(c == EOF)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: ERROR - invalid continuation.\n",
|
fprintf(stderr,"%s: ERROR - invalid continuation.\n",
|
||||||
getAppName());
|
getAppName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -737,7 +789,8 @@ static void processRegLinesW(FILE *in)
|
||||||
s = buf;
|
s = buf;
|
||||||
line = buf;
|
line = buf;
|
||||||
|
|
||||||
while(!feof(in)) {
|
while(!feof(in))
|
||||||
|
{
|
||||||
size_t size_remaining;
|
size_t size_remaining;
|
||||||
int size_to_get;
|
int size_to_get;
|
||||||
WCHAR *s_eol = NULL; /* various local uses */
|
WCHAR *s_eol = NULL; /* various local uses */
|
||||||
|
@ -769,11 +822,15 @@ static void processRegLinesW(FILE *in)
|
||||||
CharsInBuf = fread(s, sizeof(WCHAR), size_to_get - 1, in);
|
CharsInBuf = fread(s, sizeof(WCHAR), size_to_get - 1, in);
|
||||||
s[CharsInBuf] = 0;
|
s[CharsInBuf] = 0;
|
||||||
|
|
||||||
if (CharsInBuf == 0) {
|
if (CharsInBuf == 0)
|
||||||
if (ferror(in)) {
|
{
|
||||||
|
if (ferror(in))
|
||||||
|
{
|
||||||
perror ("While reading input");
|
perror ("While reading input");
|
||||||
exit (IO_ERROR);
|
exit (IO_ERROR);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
assert (feof(in));
|
assert (feof(in));
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
/* It is not clear to me from the definition that the
|
/* It is not clear to me from the definition that the
|
||||||
|
@ -788,7 +845,8 @@ static void processRegLinesW(FILE *in)
|
||||||
{
|
{
|
||||||
s_eol = wcschr(line, '\n');
|
s_eol = wcschr(line, '\n');
|
||||||
|
|
||||||
if(!s_eol) {
|
if(!s_eol)
|
||||||
|
{
|
||||||
/* Move the stub of the line to the start of the buffer so
|
/* Move the stub of the line to the start of the buffer so
|
||||||
* we get the maximum space to read into, and so we don't
|
* we get the maximum space to read into, and so we don't
|
||||||
* have to recalculate 'line' if the buffer expands */
|
* have to recalculate 'line' if the buffer expands */
|
||||||
|
@ -799,14 +857,16 @@ static void processRegLinesW(FILE *in)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If it is a comment line then discard it and go around again */
|
/* If it is a comment line then discard it and go around again */
|
||||||
if (*line == '#') {
|
if (*line == '#')
|
||||||
|
{
|
||||||
line = s_eol + 1;
|
line = s_eol + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there is a concatenating \\ then go around again */
|
/* If there is a concatenating \\ then go around again */
|
||||||
if ((*(s_eol-1) == '\\') ||
|
if ((*(s_eol-1) == '\\') ||
|
||||||
(*(s_eol-1) == '\r' && *(s_eol-2) == '\\')) {
|
(*(s_eol-1) == '\r' && *(s_eol-2) == '\\'))
|
||||||
|
{
|
||||||
WCHAR* NextLine = s_eol;
|
WCHAR* NextLine = s_eol;
|
||||||
|
|
||||||
while(*(NextLine+1) == ' ' || *(NextLine+1) == '\t')
|
while(*(NextLine+1) == ' ' || *(NextLine+1) == '\t')
|
||||||
|
@ -824,7 +884,8 @@ static void processRegLinesW(FILE *in)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove any line feed. Leave s_eol on the \0 */
|
/* Remove any line feed. Leave s_eol on the \0 */
|
||||||
if (s_eol) {
|
if (s_eol)
|
||||||
|
{
|
||||||
*s_eol = '\0';
|
*s_eol = '\0';
|
||||||
if (s_eol > buf && *(s_eol-1) == '\r')
|
if (s_eol > buf && *(s_eol-1) == '\r')
|
||||||
*(s_eol-1) = '\0';
|
*(s_eol-1) = '\0';
|
||||||
|
@ -859,10 +920,11 @@ static void REGPROC_print_error(void)
|
||||||
|
|
||||||
error_code = GetLastError ();
|
error_code = GetLastError ();
|
||||||
status = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
status = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
NULL, error_code, 0, (LPTSTR) &lpMsgBuf, 0, NULL);
|
NULL, error_code, 0, (LPTSTR) &lpMsgBuf, 0, NULL);
|
||||||
if (!status) {
|
if (!status)
|
||||||
|
{
|
||||||
fprintf(stderr,"%s: Cannot display message for error %ld, status %ld\n",
|
fprintf(stderr,"%s: Cannot display message for error %ld, status %ld\n",
|
||||||
getAppName(), error_code, GetLastError());
|
getAppName(), error_code, GetLastError());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
puts(lpMsgBuf);
|
puts(lpMsgBuf);
|
||||||
|
@ -883,7 +945,8 @@ static void REGPROC_print_error(void)
|
||||||
static void REGPROC_resize_char_buffer(WCHAR **buffer, DWORD *len, DWORD required_len)
|
static void REGPROC_resize_char_buffer(WCHAR **buffer, DWORD *len, DWORD required_len)
|
||||||
{
|
{
|
||||||
required_len++;
|
required_len++;
|
||||||
if (required_len > *len) {
|
if (required_len > *len)
|
||||||
|
{
|
||||||
*len = required_len;
|
*len = required_len;
|
||||||
if (!*buffer)
|
if (!*buffer)
|
||||||
*buffer = HeapAlloc(GetProcessHeap(), 0, *len * sizeof(**buffer));
|
*buffer = HeapAlloc(GetProcessHeap(), 0, *len * sizeof(**buffer));
|
||||||
|
@ -903,7 +966,8 @@ static void REGPROC_resize_char_buffer(WCHAR **buffer, DWORD *len, DWORD require
|
||||||
*/
|
*/
|
||||||
static void REGPROC_resize_binary_buffer(BYTE **buffer, DWORD *size, DWORD required_size)
|
static void REGPROC_resize_binary_buffer(BYTE **buffer, DWORD *size, DWORD required_size)
|
||||||
{
|
{
|
||||||
if (required_size > *size) {
|
if (required_size > *size)
|
||||||
|
{
|
||||||
*size = required_size;
|
*size = required_size;
|
||||||
if (!*buffer)
|
if (!*buffer)
|
||||||
*buffer = HeapAlloc(GetProcessHeap(), 0, *size);
|
*buffer = HeapAlloc(GetProcessHeap(), 0, *size);
|
||||||
|
@ -925,9 +989,11 @@ static void REGPROC_export_string(WCHAR **line_buf, DWORD *line_buf_size, DWORD
|
||||||
|
|
||||||
/* escaping characters */
|
/* escaping characters */
|
||||||
pos = *line_len;
|
pos = *line_len;
|
||||||
for (i = 0; i < str_len; i++) {
|
for (i = 0; i < str_len; i++)
|
||||||
|
{
|
||||||
WCHAR c = str[i];
|
WCHAR c = str[i];
|
||||||
switch (c) {
|
switch (c)
|
||||||
|
{
|
||||||
case '\n':
|
case '\n':
|
||||||
extra++;
|
extra++;
|
||||||
REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + str_len + extra);
|
REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len + str_len + extra);
|
||||||
|
@ -962,9 +1028,12 @@ static void REGPROC_export_binary(WCHAR **line_buf, DWORD *line_buf_size, DWORD
|
||||||
const WCHAR newline[] = {'\n',0};
|
const WCHAR newline[] = {'\n',0};
|
||||||
CHAR* value_multibyte = NULL;
|
CHAR* value_multibyte = NULL;
|
||||||
|
|
||||||
if (type == REG_BINARY) {
|
if (type == REG_BINARY)
|
||||||
|
{
|
||||||
hex_prefix = hex;
|
hex_prefix = hex;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
const WCHAR hex_format[] = {'h','e','x','(','%','u',')',':',0};
|
const WCHAR hex_format[] = {'h','e','x','(','%','u',')',':',0};
|
||||||
hex_prefix = hex_buf;
|
hex_prefix = hex_buf;
|
||||||
wsprintfW(hex_buf, hex_format, type);
|
wsprintfW(hex_buf, hex_format, type);
|
||||||
|
@ -1011,7 +1080,8 @@ static void REGPROC_export_binary(WCHAR **line_buf, DWORD *line_buf_size, DWORD
|
||||||
column += 3;
|
column += 3;
|
||||||
|
|
||||||
/* wrap the line */
|
/* wrap the line */
|
||||||
if (column >= REG_FILE_HEX_LINE_LEN) {
|
if (column >= REG_FILE_HEX_LINE_LEN)
|
||||||
|
{
|
||||||
lstrcpyW(*line_buf + data_pos, concat);
|
lstrcpyW(*line_buf + data_pos, concat);
|
||||||
data_pos += concat_len;
|
data_pos += concat_len;
|
||||||
column = concat_prefix;
|
column = concat_prefix;
|
||||||
|
@ -1062,11 +1132,11 @@ static void REGPROC_write_line(FILE *file, const WCHAR* str, BOOL unicode)
|
||||||
* val_size - size of the buffer for storing values in bytes.
|
* val_size - size of the buffer for storing values in bytes.
|
||||||
*/
|
*/
|
||||||
static void export_hkey(FILE *file, HKEY key,
|
static void export_hkey(FILE *file, HKEY key,
|
||||||
WCHAR **reg_key_name_buf, DWORD *reg_key_name_size,
|
WCHAR **reg_key_name_buf, DWORD *reg_key_name_size,
|
||||||
WCHAR **val_name_buf, DWORD *val_name_size,
|
WCHAR **val_name_buf, DWORD *val_name_size,
|
||||||
BYTE **val_buf, DWORD *val_size,
|
BYTE **val_buf, DWORD *val_size,
|
||||||
WCHAR **line_buf, DWORD *line_buf_size,
|
WCHAR **line_buf, DWORD *line_buf_size,
|
||||||
BOOL unicode)
|
BOOL unicode)
|
||||||
{
|
{
|
||||||
DWORD max_sub_key_len;
|
DWORD max_sub_key_len;
|
||||||
DWORD max_val_name_len;
|
DWORD max_val_name_len;
|
||||||
|
@ -1079,16 +1149,17 @@ static void export_hkey(FILE *file, HKEY key,
|
||||||
|
|
||||||
/* get size information and resize the buffers if necessary */
|
/* get size information and resize the buffers if necessary */
|
||||||
if (RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL,
|
if (RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL,
|
||||||
&max_sub_key_len, NULL,
|
&max_sub_key_len, NULL,
|
||||||
NULL, &max_val_name_len, &max_val_size, NULL, NULL
|
NULL, &max_val_name_len, &max_val_size, NULL, NULL
|
||||||
) != ERROR_SUCCESS) {
|
) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
REGPROC_print_error();
|
REGPROC_print_error();
|
||||||
}
|
}
|
||||||
curr_len = lstrlenW(*reg_key_name_buf);
|
curr_len = lstrlenW(*reg_key_name_buf);
|
||||||
REGPROC_resize_char_buffer(reg_key_name_buf, reg_key_name_size,
|
REGPROC_resize_char_buffer(reg_key_name_buf, reg_key_name_size,
|
||||||
max_sub_key_len + curr_len + 1);
|
max_sub_key_len + curr_len + 1);
|
||||||
REGPROC_resize_char_buffer(val_name_buf, val_name_size,
|
REGPROC_resize_char_buffer(val_name_buf, val_name_size,
|
||||||
max_val_name_len);
|
max_val_name_len);
|
||||||
REGPROC_resize_binary_buffer(val_buf, val_size, max_val_size);
|
REGPROC_resize_binary_buffer(val_buf, val_size, max_val_size);
|
||||||
REGPROC_resize_char_buffer(line_buf, line_buf_size, lstrlenW(*reg_key_name_buf) + 4);
|
REGPROC_resize_char_buffer(line_buf, line_buf_size, lstrlenW(*reg_key_name_buf) + 4);
|
||||||
/* output data for the current key */
|
/* output data for the current key */
|
||||||
|
@ -1098,26 +1169,34 @@ static void export_hkey(FILE *file, HKEY key,
|
||||||
/* print all the values */
|
/* print all the values */
|
||||||
i = 0;
|
i = 0;
|
||||||
more_data = TRUE;
|
more_data = TRUE;
|
||||||
while(more_data) {
|
while(more_data)
|
||||||
|
{
|
||||||
DWORD value_type;
|
DWORD value_type;
|
||||||
DWORD val_name_size1 = *val_name_size;
|
DWORD val_name_size1 = *val_name_size;
|
||||||
DWORD val_size1 = *val_size;
|
DWORD val_size1 = *val_size;
|
||||||
ret = RegEnumValueW(key, i, *val_name_buf, &val_name_size1, NULL,
|
ret = RegEnumValueW(key, i, *val_name_buf, &val_name_size1, NULL,
|
||||||
&value_type, *val_buf, &val_size1);
|
&value_type, *val_buf, &val_size1);
|
||||||
if (ret == ERROR_MORE_DATA) {
|
if (ret == ERROR_MORE_DATA)
|
||||||
|
{
|
||||||
/* Increase the size of the buffers and retry */
|
/* Increase the size of the buffers and retry */
|
||||||
REGPROC_resize_char_buffer(val_name_buf, val_name_size, val_name_size1);
|
REGPROC_resize_char_buffer(val_name_buf, val_name_size, val_name_size1);
|
||||||
REGPROC_resize_binary_buffer(val_buf, val_size, val_size1);
|
REGPROC_resize_binary_buffer(val_buf, val_size, val_size1);
|
||||||
} else if (ret != ERROR_SUCCESS) {
|
}
|
||||||
|
else if (ret != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
more_data = FALSE;
|
more_data = FALSE;
|
||||||
if (ret != ERROR_NO_MORE_ITEMS) {
|
if (ret != ERROR_NO_MORE_ITEMS)
|
||||||
|
{
|
||||||
REGPROC_print_error();
|
REGPROC_print_error();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
DWORD line_len;
|
DWORD line_len;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if ((*val_name_buf)[0]) {
|
if ((*val_name_buf)[0])
|
||||||
|
{
|
||||||
const WCHAR val_start[] = {'"','%','s','"','=',0};
|
const WCHAR val_start[] = {'"','%','s','"','=',0};
|
||||||
|
|
||||||
line_len = 0;
|
line_len = 0;
|
||||||
|
@ -1128,22 +1207,28 @@ static void export_hkey(FILE *file, HKEY key,
|
||||||
line_len = 3 + lstrlenW(*val_name_buf);
|
line_len = 3 + lstrlenW(*val_name_buf);
|
||||||
REGPROC_resize_char_buffer(line_buf, line_buf_size, line_len);
|
REGPROC_resize_char_buffer(line_buf, line_buf_size, line_len);
|
||||||
wsprintfW(*line_buf, val_start, *val_name_buf);
|
wsprintfW(*line_buf, val_start, *val_name_buf);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
const WCHAR std_val[] = {'@','=',0};
|
const WCHAR std_val[] = {'@','=',0};
|
||||||
line_len = 2;
|
line_len = 2;
|
||||||
REGPROC_resize_char_buffer(line_buf, line_buf_size, line_len);
|
REGPROC_resize_char_buffer(line_buf, line_buf_size, line_len);
|
||||||
lstrcpyW(*line_buf, std_val);
|
lstrcpyW(*line_buf, std_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (value_type) {
|
switch (value_type)
|
||||||
|
{
|
||||||
case REG_SZ:
|
case REG_SZ:
|
||||||
{
|
{
|
||||||
WCHAR* wstr = (WCHAR*)*val_buf;
|
WCHAR* wstr = (WCHAR*)*val_buf;
|
||||||
|
|
||||||
if (val_size1 < sizeof(WCHAR) || val_size1 % sizeof(WCHAR) ||
|
if (val_size1 < sizeof(WCHAR) || val_size1 % sizeof(WCHAR) ||
|
||||||
wstr[val_size1 / sizeof(WCHAR) - 1]) {
|
wstr[val_size1 / sizeof(WCHAR) - 1])
|
||||||
|
{
|
||||||
REGPROC_export_binary(line_buf, line_buf_size, &line_len, value_type, *val_buf, val_size1, unicode);
|
REGPROC_export_binary(line_buf, line_buf_size, &line_len, value_type, *val_buf, val_size1, unicode);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
const WCHAR start[] = {'"',0};
|
const WCHAR start[] = {'"',0};
|
||||||
const WCHAR end[] = {'"','\n',0};
|
const WCHAR end[] = {'"','\n',0};
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
@ -1178,14 +1263,14 @@ static void export_hkey(FILE *file, HKEY key,
|
||||||
char* key_nameA = GetMultiByteString(*reg_key_name_buf);
|
char* key_nameA = GetMultiByteString(*reg_key_name_buf);
|
||||||
char* value_nameA = GetMultiByteString(*val_name_buf);
|
char* value_nameA = GetMultiByteString(*val_name_buf);
|
||||||
fprintf(stderr,"%s: warning - unsupported registry format '%ld', "
|
fprintf(stderr,"%s: warning - unsupported registry format '%ld', "
|
||||||
"treat as binary\n",
|
"treat as binary\n",
|
||||||
getAppName(), value_type);
|
getAppName(), value_type);
|
||||||
fprintf(stderr,"key name: \"%s\"\n", key_nameA);
|
fprintf(stderr,"key name: \"%s\"\n", key_nameA);
|
||||||
fprintf(stderr,"value name:\"%s\"\n\n", value_nameA);
|
fprintf(stderr,"value name:\"%s\"\n\n", value_nameA);
|
||||||
HeapFree(GetProcessHeap(), 0, key_nameA);
|
HeapFree(GetProcessHeap(), 0, key_nameA);
|
||||||
HeapFree(GetProcessHeap(), 0, value_nameA);
|
HeapFree(GetProcessHeap(), 0, value_nameA);
|
||||||
}
|
}
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case REG_EXPAND_SZ:
|
case REG_EXPAND_SZ:
|
||||||
case REG_MULTI_SZ:
|
case REG_MULTI_SZ:
|
||||||
/* falls through */
|
/* falls through */
|
||||||
|
@ -1199,30 +1284,40 @@ static void export_hkey(FILE *file, HKEY key,
|
||||||
i = 0;
|
i = 0;
|
||||||
more_data = TRUE;
|
more_data = TRUE;
|
||||||
(*reg_key_name_buf)[curr_len] = '\\';
|
(*reg_key_name_buf)[curr_len] = '\\';
|
||||||
while(more_data) {
|
while(more_data)
|
||||||
|
{
|
||||||
DWORD buf_size = *reg_key_name_size - curr_len - 1;
|
DWORD buf_size = *reg_key_name_size - curr_len - 1;
|
||||||
|
|
||||||
ret = RegEnumKeyExW(key, i, *reg_key_name_buf + curr_len + 1, &buf_size,
|
ret = RegEnumKeyExW(key, i, *reg_key_name_buf + curr_len + 1, &buf_size,
|
||||||
NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL);
|
||||||
if (ret == ERROR_MORE_DATA) {
|
if (ret == ERROR_MORE_DATA)
|
||||||
|
{
|
||||||
/* Increase the size of the buffer and retry */
|
/* Increase the size of the buffer and retry */
|
||||||
REGPROC_resize_char_buffer(reg_key_name_buf, reg_key_name_size, curr_len + 1 + buf_size);
|
REGPROC_resize_char_buffer(reg_key_name_buf, reg_key_name_size, curr_len + 1 + buf_size);
|
||||||
} else if (ret != ERROR_SUCCESS) {
|
}
|
||||||
|
else if (ret != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
more_data = FALSE;
|
more_data = FALSE;
|
||||||
if (ret != ERROR_NO_MORE_ITEMS) {
|
if (ret != ERROR_NO_MORE_ITEMS)
|
||||||
|
{
|
||||||
REGPROC_print_error();
|
REGPROC_print_error();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
HKEY subkey;
|
HKEY subkey;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
if (RegOpenKeyW(key, *reg_key_name_buf + curr_len + 1,
|
if (RegOpenKeyW(key, *reg_key_name_buf + curr_len + 1,
|
||||||
&subkey) == ERROR_SUCCESS) {
|
&subkey) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
export_hkey(file, subkey, reg_key_name_buf, reg_key_name_size,
|
export_hkey(file, subkey, reg_key_name_buf, reg_key_name_size,
|
||||||
val_name_buf, val_name_size, val_buf, val_size,
|
val_name_buf, val_name_size, val_buf, val_size,
|
||||||
line_buf, line_buf_size, unicode);
|
line_buf, line_buf_size, unicode);
|
||||||
RegCloseKey(subkey);
|
RegCloseKey(subkey);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
REGPROC_print_error();
|
REGPROC_print_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1246,7 +1341,8 @@ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode)
|
||||||
file = _wfopen(file_name, L"wb");
|
file = _wfopen(file_name, L"wb");
|
||||||
else
|
else
|
||||||
file = _wfopen(file_name, L"w");
|
file = _wfopen(file_name, L"w");
|
||||||
if (!file) {
|
if (!file)
|
||||||
|
{
|
||||||
CHAR* file_nameA = GetMultiByteString(file_name);
|
CHAR* file_nameA = GetMultiByteString(file_name);
|
||||||
perror("");
|
perror("");
|
||||||
fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), file_nameA);
|
fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), file_nameA);
|
||||||
|
@ -1291,75 +1387,87 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
|
||||||
BOOL unicode = (format == REG_FORMAT_5);
|
BOOL unicode = (format == REG_FORMAT_5);
|
||||||
|
|
||||||
reg_key_name_buf = HeapAlloc(GetProcessHeap(), 0,
|
reg_key_name_buf = HeapAlloc(GetProcessHeap(), 0,
|
||||||
reg_key_name_size * sizeof(*reg_key_name_buf));
|
reg_key_name_size * sizeof(*reg_key_name_buf));
|
||||||
val_name_buf = HeapAlloc(GetProcessHeap(), 0,
|
val_name_buf = HeapAlloc(GetProcessHeap(), 0,
|
||||||
val_name_size * sizeof(*val_name_buf));
|
val_name_size * sizeof(*val_name_buf));
|
||||||
val_buf = HeapAlloc(GetProcessHeap(), 0, val_size);
|
val_buf = HeapAlloc(GetProcessHeap(), 0, val_size);
|
||||||
line_buf = HeapAlloc(GetProcessHeap(), 0, line_buf_size * sizeof(*line_buf));
|
line_buf = HeapAlloc(GetProcessHeap(), 0, line_buf_size * sizeof(*line_buf));
|
||||||
CHECK_ENOUGH_MEMORY(reg_key_name_buf && val_name_buf && val_buf && line_buf);
|
CHECK_ENOUGH_MEMORY(reg_key_name_buf && val_name_buf && val_buf && line_buf);
|
||||||
|
|
||||||
if (reg_key_name && reg_key_name[0]) {
|
if (reg_key_name && reg_key_name[0])
|
||||||
|
{
|
||||||
HKEY reg_key_class;
|
HKEY reg_key_class;
|
||||||
WCHAR *branch_name = NULL;
|
WCHAR *branch_name = NULL;
|
||||||
HKEY key;
|
HKEY key;
|
||||||
|
|
||||||
REGPROC_resize_char_buffer(®_key_name_buf, ®_key_name_size,
|
REGPROC_resize_char_buffer(®_key_name_buf, ®_key_name_size,
|
||||||
lstrlenW(reg_key_name));
|
lstrlenW(reg_key_name));
|
||||||
lstrcpyW(reg_key_name_buf, reg_key_name);
|
lstrcpyW(reg_key_name_buf, reg_key_name);
|
||||||
|
|
||||||
/* open the specified key */
|
/* open the specified key */
|
||||||
if (!parseKeyName(reg_key_name, ®_key_class, &branch_name)) {
|
if (!parseKeyName(reg_key_name, ®_key_class, &branch_name))
|
||||||
|
{
|
||||||
CHAR* key_nameA = GetMultiByteString(reg_key_name);
|
CHAR* key_nameA = GetMultiByteString(reg_key_name);
|
||||||
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
|
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
|
||||||
getAppName(), key_nameA);
|
getAppName(), key_nameA);
|
||||||
HeapFree(GetProcessHeap(), 0, key_nameA);
|
HeapFree(GetProcessHeap(), 0, key_nameA);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!branch_name[0]) {
|
if (!branch_name[0])
|
||||||
|
{
|
||||||
/* no branch - registry class is specified */
|
/* no branch - registry class is specified */
|
||||||
file = REGPROC_open_export_file(file_name, unicode);
|
file = REGPROC_open_export_file(file_name, unicode);
|
||||||
export_hkey(file, reg_key_class,
|
export_hkey(file, reg_key_class,
|
||||||
®_key_name_buf, ®_key_name_size,
|
®_key_name_buf, ®_key_name_size,
|
||||||
&val_name_buf, &val_name_size,
|
&val_name_buf, &val_name_size,
|
||||||
&val_buf, &val_size, &line_buf,
|
&val_buf, &val_size, &line_buf,
|
||||||
&line_buf_size, unicode);
|
&line_buf_size, unicode);
|
||||||
} else if (RegOpenKeyW(reg_key_class, branch_name, &key) == ERROR_SUCCESS) {
|
}
|
||||||
|
else if (RegOpenKeyW(reg_key_class, branch_name, &key) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
file = REGPROC_open_export_file(file_name, unicode);
|
file = REGPROC_open_export_file(file_name, unicode);
|
||||||
export_hkey(file, key,
|
export_hkey(file, key,
|
||||||
®_key_name_buf, ®_key_name_size,
|
®_key_name_buf, ®_key_name_size,
|
||||||
&val_name_buf, &val_name_size,
|
&val_name_buf, &val_name_size,
|
||||||
&val_buf, &val_size, &line_buf,
|
&val_buf, &val_size, &line_buf,
|
||||||
&line_buf_size, unicode);
|
&line_buf_size, unicode);
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CHAR* key_nameA = GetMultiByteString(reg_key_name);
|
CHAR* key_nameA = GetMultiByteString(reg_key_name);
|
||||||
fprintf(stderr,"%s: Can't export. Registry key '%s' does not exist!\n",
|
fprintf(stderr,"%s: Can't export. Registry key '%s' does not exist!\n",
|
||||||
getAppName(), key_nameA);
|
getAppName(), key_nameA);
|
||||||
HeapFree(GetProcessHeap(), 0, key_nameA);
|
HeapFree(GetProcessHeap(), 0, key_nameA);
|
||||||
REGPROC_print_error();
|
REGPROC_print_error();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
/* export all registry classes */
|
/* export all registry classes */
|
||||||
file = REGPROC_open_export_file(file_name, unicode);
|
file = REGPROC_open_export_file(file_name, unicode);
|
||||||
for (i = 0; i < REG_CLASS_NUMBER; i++) {
|
for (i = 0; i < REG_CLASS_NUMBER; i++)
|
||||||
|
{
|
||||||
/* do not export HKEY_CLASSES_ROOT */
|
/* do not export HKEY_CLASSES_ROOT */
|
||||||
if (reg_class_keys[i] != HKEY_CLASSES_ROOT &&
|
if (reg_class_keys[i] != HKEY_CLASSES_ROOT &&
|
||||||
reg_class_keys[i] != HKEY_CURRENT_USER &&
|
reg_class_keys[i] != HKEY_CURRENT_USER &&
|
||||||
reg_class_keys[i] != HKEY_CURRENT_CONFIG &&
|
reg_class_keys[i] != HKEY_CURRENT_CONFIG &&
|
||||||
reg_class_keys[i] != HKEY_DYN_DATA) {
|
reg_class_keys[i] != HKEY_DYN_DATA)
|
||||||
|
{
|
||||||
lstrcpyW(reg_key_name_buf, reg_class_namesW[i]);
|
lstrcpyW(reg_key_name_buf, reg_class_namesW[i]);
|
||||||
export_hkey(file, reg_class_keys[i],
|
export_hkey(file, reg_class_keys[i],
|
||||||
®_key_name_buf, ®_key_name_size,
|
®_key_name_buf, ®_key_name_size,
|
||||||
&val_name_buf, &val_name_size,
|
&val_name_buf, &val_name_size,
|
||||||
&val_buf, &val_size, &line_buf,
|
&val_buf, &val_size, &line_buf,
|
||||||
&line_buf_size, unicode);
|
&line_buf_size, unicode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file) {
|
if (file)
|
||||||
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, reg_key_name);
|
HeapFree(GetProcessHeap(), 0, reg_key_name);
|
||||||
|
@ -1382,7 +1490,8 @@ BOOL import_registry_file(FILE* reg_file)
|
||||||
if (s[0] == 0xff && s[1] == 0xfe)
|
if (s[0] == 0xff && s[1] == 0xfe)
|
||||||
{
|
{
|
||||||
processRegLinesW(reg_file);
|
processRegLinesW(reg_file);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
fseek(reg_file, 0, SEEK_SET);
|
fseek(reg_file, 0, SEEK_SET);
|
||||||
processRegLinesA(reg_file);
|
processRegLinesA(reg_file);
|
||||||
|
@ -1408,17 +1517,19 @@ void delete_registry_key(WCHAR *reg_key_name)
|
||||||
if (!reg_key_name || !reg_key_name[0])
|
if (!reg_key_name || !reg_key_name[0])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!parseKeyName(reg_key_name, &key_class, &key_name)) {
|
if (!parseKeyName(reg_key_name, &key_class, &key_name))
|
||||||
|
{
|
||||||
char* reg_key_nameA = GetMultiByteString(reg_key_name);
|
char* reg_key_nameA = GetMultiByteString(reg_key_name);
|
||||||
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
|
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
|
||||||
getAppName(), reg_key_nameA);
|
getAppName(), reg_key_nameA);
|
||||||
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
|
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!*key_name) {
|
if (!*key_name)
|
||||||
|
{
|
||||||
char* reg_key_nameA = GetMultiByteString(reg_key_name);
|
char* reg_key_nameA = GetMultiByteString(reg_key_name);
|
||||||
fprintf(stderr,"%s: Can't delete registry class '%s'\n",
|
fprintf(stderr,"%s: Can't delete registry class '%s'\n",
|
||||||
getAppName(), reg_key_nameA);
|
getAppName(), reg_key_nameA);
|
||||||
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
|
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,19 +42,22 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe
|
||||||
item.hItem = hItem;
|
item.hItem = hItem;
|
||||||
if (!TreeView_GetItem(hwndTV, &item)) return FALSE;
|
if (!TreeView_GetItem(hwndTV, &item)) return FALSE;
|
||||||
|
|
||||||
if (item.lParam) {
|
if (item.lParam)
|
||||||
/* found root key with valid key value */
|
{
|
||||||
*phKey = (HKEY)item.lParam;
|
/* found root key with valid key value */
|
||||||
return TRUE;
|
*phKey = (HKEY)item.lParam;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!get_item_path(hwndTV, TreeView_GetParent(hwndTV, hItem), phKey, pKeyPath, pPathLen, pMaxLen)) return FALSE;
|
if(!get_item_path(hwndTV, TreeView_GetParent(hwndTV, hItem), phKey, pKeyPath, pPathLen, pMaxLen)) return FALSE;
|
||||||
if (*pPathLen) {
|
if (*pPathLen)
|
||||||
|
{
|
||||||
(*pKeyPath)[*pPathLen] = _T('\\');
|
(*pKeyPath)[*pPathLen] = _T('\\');
|
||||||
++(*pPathLen);
|
++(*pPathLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
item.mask = TVIF_TEXT;
|
item.mask = TVIF_TEXT;
|
||||||
item.hItem = hItem;
|
item.hItem = hItem;
|
||||||
item.pszText = *pKeyPath + *pPathLen;
|
item.pszText = *pKeyPath + *pPathLen;
|
||||||
|
@ -62,15 +65,17 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe
|
||||||
item.cchTextMax = (int) maxLen;
|
item.cchTextMax = (int) maxLen;
|
||||||
if (!TreeView_GetItem(hwndTV, &item)) return FALSE;
|
if (!TreeView_GetItem(hwndTV, &item)) return FALSE;
|
||||||
len = _tcslen(item.pszText);
|
len = _tcslen(item.pszText);
|
||||||
if (len < maxLen - 1) {
|
if (len < maxLen - 1)
|
||||||
|
{
|
||||||
*pPathLen += (int) len;
|
*pPathLen += (int) len;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
newStr = HeapReAlloc(GetProcessHeap(), 0, *pKeyPath, *pMaxLen * 2);
|
newStr = HeapReAlloc(GetProcessHeap(), 0, *pKeyPath, *pMaxLen * 2);
|
||||||
if (!newStr) return FALSE;
|
if (!newStr) return FALSE;
|
||||||
*pKeyPath = newStr;
|
*pKeyPath = newStr;
|
||||||
*pMaxLen *= 2;
|
*pMaxLen *= 2;
|
||||||
} while(TRUE);
|
}
|
||||||
|
while(TRUE);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -87,9 +92,10 @@ LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
|
||||||
if (maxLen == -1) return NULL;
|
if (maxLen == -1) return NULL;
|
||||||
if (!hItem) hItem = TreeView_GetSelection(hwndTV);
|
if (!hItem) hItem = TreeView_GetSelection(hwndTV);
|
||||||
if (!hItem) return NULL;
|
if (!hItem) return NULL;
|
||||||
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) {
|
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen))
|
||||||
return NULL;
|
{
|
||||||
}
|
return NULL;
|
||||||
|
}
|
||||||
return pathBuffer;
|
return pathBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +112,10 @@ static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HK
|
||||||
TVITEM tvi;
|
TVITEM tvi;
|
||||||
TVINSERTSTRUCT tvins;
|
TVINSERTSTRUCT tvins;
|
||||||
|
|
||||||
if (hKey) {
|
if (hKey)
|
||||||
if (RegQueryInfoKey(hKey, 0, 0, 0, &dwChildren, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
|
{
|
||||||
|
if (RegQueryInfoKey(hKey, 0, 0, 0, &dwChildren, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
dwChildren = 0;
|
dwChildren = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,15 +148,20 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
|
||||||
|
|
||||||
KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
|
KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
|
||||||
|
|
||||||
if (*KeyPath) {
|
if (*KeyPath)
|
||||||
if (RegOpenKeyEx(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
|
{
|
||||||
|
if (RegOpenKeyEx(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
hKey = hRoot;
|
hKey = hRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RegQueryInfoKey(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
|
if (RegQueryInfoKey(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,19 +169,22 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
|
||||||
tvItem.mask = TVIF_CHILDREN;
|
tvItem.mask = TVIF_CHILDREN;
|
||||||
tvItem.hItem = hItem;
|
tvItem.hItem = hItem;
|
||||||
tvItem.cChildren = dwCount;
|
tvItem.cChildren = dwCount;
|
||||||
if (!TreeView_SetItem(hwndTV, &tvItem)) {
|
if (!TreeView_SetItem(hwndTV, &tvItem))
|
||||||
|
{
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We don't have to bother with the rest if it's not expanded. */
|
/* We don't have to bother with the rest if it's not expanded. */
|
||||||
if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDED) == 0) {
|
if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDED) == 0)
|
||||||
|
{
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
bSuccess = TRUE;
|
bSuccess = TRUE;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwMaxSubKeyLen++; /* account for the \0 terminator */
|
dwMaxSubKeyLen++; /* account for the \0 terminator */
|
||||||
if (!(Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR)))) {
|
if (!(Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR))))
|
||||||
|
{
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
tvItem.cchTextMax = dwMaxSubKeyLen;
|
tvItem.cchTextMax = dwMaxSubKeyLen;
|
||||||
|
@ -185,7 +201,8 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
|
||||||
DWORD dwStep = 10000;
|
DWORD dwStep = 10000;
|
||||||
|
|
||||||
for (childItem = TreeView_GetChild(hwndTV, hItem); childItem;
|
for (childItem = TreeView_GetChild(hwndTV, hItem); childItem;
|
||||||
childItem = TreeView_GetNextSibling(hwndTV, childItem)) {
|
childItem = TreeView_GetNextSibling(hwndTV, childItem))
|
||||||
|
{
|
||||||
|
|
||||||
if (dwActualSize + dwMaxSubKeyLen + 1 > dwPhysicalSize)
|
if (dwActualSize + dwMaxSubKeyLen + 1 > dwPhysicalSize)
|
||||||
{
|
{
|
||||||
|
@ -218,40 +235,50 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
|
||||||
|
|
||||||
/* Now go through all the children in the tree, and check if any have to be removed. */
|
/* Now go through all the children in the tree, and check if any have to be removed. */
|
||||||
childItem = TreeView_GetChild(hwndTV, hItem);
|
childItem = TreeView_GetChild(hwndTV, hItem);
|
||||||
while (childItem) {
|
while (childItem)
|
||||||
|
{
|
||||||
HTREEITEM nextItem = TreeView_GetNextSibling(hwndTV, childItem);
|
HTREEITEM nextItem = TreeView_GetNextSibling(hwndTV, childItem);
|
||||||
if (RefreshTreeItem(hwndTV, childItem) == FALSE) {
|
if (RefreshTreeItem(hwndTV, childItem) == FALSE)
|
||||||
|
{
|
||||||
(void)TreeView_DeleteItem(hwndTV, childItem);
|
(void)TreeView_DeleteItem(hwndTV, childItem);
|
||||||
}
|
}
|
||||||
childItem = nextItem;
|
childItem = nextItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now go through all the children in the registry, and check if any have to be added. */
|
/* Now go through all the children in the registry, and check if any have to be added. */
|
||||||
bAddedAny = FALSE;
|
bAddedAny = FALSE;
|
||||||
for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
|
for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
|
||||||
|
{
|
||||||
DWORD cName = dwMaxSubKeyLen, dwSubCount;
|
DWORD cName = dwMaxSubKeyLen, dwSubCount;
|
||||||
BOOL found;
|
BOOL found;
|
||||||
|
|
||||||
found = FALSE;
|
found = FALSE;
|
||||||
if (RegEnumKeyEx(hKey, dwIndex, Name, &cName, 0, 0, 0, NULL) != ERROR_SUCCESS) {
|
if (RegEnumKeyEx(hKey, dwIndex, Name, &cName, 0, 0, 0, NULL) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the node is already in there. */
|
/* Check if the node is already in there. */
|
||||||
if (pszNodes) {
|
if (pszNodes)
|
||||||
for (s = pszNodes; *s; s += _tcslen(s) + 1) {
|
{
|
||||||
if (!_tcscmp(s, Name)) {
|
for (s = pszNodes; *s; s += _tcslen(s) + 1)
|
||||||
|
{
|
||||||
|
if (!_tcscmp(s, Name))
|
||||||
|
{
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == FALSE) {
|
if (found == FALSE)
|
||||||
|
{
|
||||||
/* Find the number of children of the node. */
|
/* Find the number of children of the node. */
|
||||||
dwSubCount = 0;
|
dwSubCount = 0;
|
||||||
if (RegOpenKeyEx(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS) {
|
if (RegOpenKeyEx(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
|
||||||
if (RegQueryInfoKey(hSubKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
|
{
|
||||||
|
if (RegQueryInfoKey(hSubKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
dwSubCount = 0;
|
dwSubCount = 0;
|
||||||
}
|
}
|
||||||
RegCloseKey(hSubKey);
|
RegCloseKey(hSubKey);
|
||||||
|
@ -287,7 +314,8 @@ BOOL RefreshTreeView(HWND hwndTV)
|
||||||
SendMessage(hwndTV, WM_SETREDRAW, FALSE, 0);
|
SendMessage(hwndTV, WM_SETREDRAW, FALSE, 0);
|
||||||
|
|
||||||
hItem = TreeView_GetChild(hwndTV, TreeView_GetRoot(hwndTV));
|
hItem = TreeView_GetChild(hwndTV, TreeView_GetRoot(hwndTV));
|
||||||
while (hItem) {
|
while (hItem)
|
||||||
|
{
|
||||||
RefreshTreeItem(hwndTV, hItem);
|
RefreshTreeItem(hwndTV, hItem);
|
||||||
hItem = TreeView_GetNextSibling(hwndTV, hItem);
|
hItem = TreeView_GetNextSibling(hwndTV, hItem);
|
||||||
}
|
}
|
||||||
|
@ -325,7 +353,7 @@ HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name)
|
||||||
hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
|
hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
|
||||||
SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
|
SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item.mask = TVIF_CHILDREN | TVIF_HANDLE;
|
item.mask = TVIF_CHILDREN | TVIF_HANDLE;
|
||||||
item.hItem = hItem;
|
item.hItem = hItem;
|
||||||
|
@ -388,11 +416,11 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName)
|
||||||
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_USERS"), HKEY_USERS, 1)) return FALSE;
|
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_USERS"), HKEY_USERS, 1)) return FALSE;
|
||||||
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_CONFIG"), HKEY_CURRENT_CONFIG, 1)) return FALSE;
|
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_CONFIG"), HKEY_CURRENT_CONFIG, 1)) return FALSE;
|
||||||
|
|
||||||
if (GetVersion() & 0x80000000)
|
if (GetVersion() & 0x80000000)
|
||||||
{
|
{
|
||||||
/* Win9x specific key */
|
/* Win9x specific key */
|
||||||
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_DYN_DATA"), HKEY_DYN_DATA, 1)) return FALSE;
|
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_DYN_DATA"), HKEY_DYN_DATA, 1)) return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* expand and select host name */
|
/* expand and select host name */
|
||||||
(void)TreeView_Expand(hwndTV, hRoot, TVE_EXPAND);
|
(void)TreeView_Expand(hwndTV, hRoot, TVE_EXPAND);
|
||||||
|
@ -431,8 +459,8 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
|
||||||
0);
|
0);
|
||||||
if (hico)
|
if (hico)
|
||||||
{
|
{
|
||||||
Image_Open = ImageList_AddIcon(himl, hico);
|
Image_Open = ImageList_AddIcon(himl, hico);
|
||||||
DestroyIcon(hico);
|
DestroyIcon(hico);
|
||||||
}
|
}
|
||||||
|
|
||||||
hico = LoadImage(hInst,
|
hico = LoadImage(hInst,
|
||||||
|
@ -443,8 +471,8 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
|
||||||
0);
|
0);
|
||||||
if (hico)
|
if (hico)
|
||||||
{
|
{
|
||||||
Image_Closed = ImageList_AddIcon(himl, hico);
|
Image_Closed = ImageList_AddIcon(himl, hico);
|
||||||
DestroyIcon(hico);
|
DestroyIcon(hico);
|
||||||
}
|
}
|
||||||
|
|
||||||
hico = LoadImage(hInst,
|
hico = LoadImage(hInst,
|
||||||
|
@ -455,8 +483,8 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
|
||||||
0);
|
0);
|
||||||
if (hico)
|
if (hico)
|
||||||
{
|
{
|
||||||
Image_Root = ImageList_AddIcon(himl, hico);
|
Image_Root = ImageList_AddIcon(himl, hico);
|
||||||
DestroyIcon(hico);
|
DestroyIcon(hico);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fail if not all of the images were added. */
|
/* Fail if not all of the images were added. */
|
||||||
|
@ -483,7 +511,8 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
|
||||||
|
|
||||||
static int expanding;
|
static int expanding;
|
||||||
if (expanding) return FALSE;
|
if (expanding) return FALSE;
|
||||||
if (pnmtv->itemNew.state & TVIS_EXPANDEDONCE ) {
|
if (pnmtv->itemNew.state & TVIS_EXPANDEDONCE )
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
expanding = TRUE;
|
expanding = TRUE;
|
||||||
|
@ -493,11 +522,14 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
|
||||||
keyPath = GetItemPath(hwndTV, pnmtv->itemNew.hItem, &hRoot);
|
keyPath = GetItemPath(hwndTV, pnmtv->itemNew.hItem, &hRoot);
|
||||||
if (!keyPath) goto done;
|
if (!keyPath) goto done;
|
||||||
|
|
||||||
if (*keyPath) {
|
if (*keyPath)
|
||||||
|
{
|
||||||
errCode = RegOpenKeyEx(hRoot, keyPath, 0, KEY_READ, &hNewKey);
|
errCode = RegOpenKeyEx(hRoot, keyPath, 0, KEY_READ, &hNewKey);
|
||||||
if (errCode != ERROR_SUCCESS) goto done;
|
if (errCode != ERROR_SUCCESS) goto done;
|
||||||
} else {
|
}
|
||||||
hNewKey = hRoot;
|
else
|
||||||
|
{
|
||||||
|
hNewKey = hRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
errCode = RegQueryInfoKey(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
|
errCode = RegQueryInfoKey(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
|
||||||
|
@ -506,13 +538,15 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
|
||||||
Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR));
|
Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR));
|
||||||
if (!Name) goto done;
|
if (!Name) goto done;
|
||||||
|
|
||||||
for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
|
for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
|
||||||
|
{
|
||||||
DWORD cName = dwMaxSubKeyLen, dwSubCount;
|
DWORD cName = dwMaxSubKeyLen, dwSubCount;
|
||||||
|
|
||||||
errCode = RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, 0, 0, 0, 0);
|
errCode = RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, 0, 0, 0, 0);
|
||||||
if (errCode != ERROR_SUCCESS) continue;
|
if (errCode != ERROR_SUCCESS) continue;
|
||||||
errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_QUERY_VALUE, &hKey);
|
errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_QUERY_VALUE, &hKey);
|
||||||
if (errCode == ERROR_SUCCESS) {
|
if (errCode == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
errCode = RegQueryInfoKey(hKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0);
|
errCode = RegQueryInfoKey(hKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0);
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
@ -611,88 +645,90 @@ HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, HMENU id)
|
||||||
0, 0, rcClient.right, rcClient.bottom,
|
0, 0, rcClient.right, rcClient.bottom,
|
||||||
hwndParent, id, hInst, NULL);
|
hwndParent, id, hInst, NULL);
|
||||||
/* Initialize the image list, and add items to the control. */
|
/* Initialize the image list, and add items to the control. */
|
||||||
if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) {
|
if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName))
|
||||||
|
{
|
||||||
DestroyWindow(hwndTV);
|
DestroyWindow(hwndTV);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return hwndTV;
|
return hwndTV;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyTreeView() {
|
void DestroyTreeView()
|
||||||
if (pathBuffer)
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, pathBuffer);
|
if (pathBuffer)
|
||||||
|
HeapFree(GetProcessHeap(), 0, pathBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
|
BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
|
||||||
{
|
{
|
||||||
HTREEITEM hRoot, hItem;
|
HTREEITEM hRoot, hItem;
|
||||||
HTREEITEM hChildItem;
|
HTREEITEM hChildItem;
|
||||||
TCHAR szPathPart[128];
|
TCHAR szPathPart[128];
|
||||||
TCHAR szBuffer[128];
|
TCHAR szBuffer[128];
|
||||||
LPCTSTR s;
|
LPCTSTR s;
|
||||||
TVITEM tvi;
|
TVITEM tvi;
|
||||||
|
|
||||||
/* Total no-good hack */
|
/* Total no-good hack */
|
||||||
if (!_tcsnicmp(keyPath, _T("My Computer\\"), 12))
|
if (!_tcsnicmp(keyPath, _T("My Computer\\"), 12))
|
||||||
keyPath += 12;
|
keyPath += 12;
|
||||||
|
|
||||||
hRoot = TreeView_GetRoot(hwndTV);
|
hRoot = TreeView_GetRoot(hwndTV);
|
||||||
hItem = hRoot;
|
hItem = hRoot;
|
||||||
|
|
||||||
while(keyPath[0])
|
while(keyPath[0])
|
||||||
{
|
{
|
||||||
s = _tcschr(keyPath, TEXT('\\'));
|
s = _tcschr(keyPath, TEXT('\\'));
|
||||||
lstrcpyn(szPathPart, keyPath, s ? s - keyPath + 1 : _tcslen(keyPath) + 1);
|
lstrcpyn(szPathPart, keyPath, s ? s - keyPath + 1 : _tcslen(keyPath) + 1);
|
||||||
|
|
||||||
/* Special case for root to expand root key abbreviations */
|
/* Special case for root to expand root key abbreviations */
|
||||||
if (hItem == hRoot)
|
if (hItem == hRoot)
|
||||||
{
|
{
|
||||||
if (!_tcsicmp(szPathPart, TEXT("HKCR")))
|
if (!_tcsicmp(szPathPart, TEXT("HKCR")))
|
||||||
_tcscpy(szPathPart, TEXT("HKEY_CLASSES_ROOT"));
|
_tcscpy(szPathPart, TEXT("HKEY_CLASSES_ROOT"));
|
||||||
else if (!_tcsicmp(szPathPart, TEXT("HKCU")))
|
else if (!_tcsicmp(szPathPart, TEXT("HKCU")))
|
||||||
_tcscpy(szPathPart, TEXT("HKEY_CURRENT_USER"));
|
_tcscpy(szPathPart, TEXT("HKEY_CURRENT_USER"));
|
||||||
else if (!_tcsicmp(szPathPart, TEXT("HKLM")))
|
else if (!_tcsicmp(szPathPart, TEXT("HKLM")))
|
||||||
_tcscpy(szPathPart, TEXT("HKEY_LOCAL_MACHINE"));
|
_tcscpy(szPathPart, TEXT("HKEY_LOCAL_MACHINE"));
|
||||||
else if (!_tcsicmp(szPathPart, TEXT("HKU")))
|
else if (!_tcsicmp(szPathPart, TEXT("HKU")))
|
||||||
_tcscpy(szPathPart, TEXT("HKEY_USERS"));
|
_tcscpy(szPathPart, TEXT("HKEY_USERS"));
|
||||||
else if (!_tcsicmp(szPathPart, TEXT("HKCC")))
|
else if (!_tcsicmp(szPathPart, TEXT("HKCC")))
|
||||||
_tcscpy(szPathPart, TEXT("HKEY_CURRENT_CONFIG"));
|
_tcscpy(szPathPart, TEXT("HKEY_CURRENT_CONFIG"));
|
||||||
else if (!_tcsicmp(szPathPart, TEXT("HKDD")))
|
else if (!_tcsicmp(szPathPart, TEXT("HKDD")))
|
||||||
_tcscpy(szPathPart, TEXT("HKEY_DYN_DATA"));
|
_tcscpy(szPathPart, TEXT("HKEY_DYN_DATA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (hChildItem = TreeView_GetChild(hwndTV, hItem); hChildItem;
|
for (hChildItem = TreeView_GetChild(hwndTV, hItem); hChildItem;
|
||||||
hChildItem = TreeView_GetNextSibling(hwndTV, hChildItem))
|
hChildItem = TreeView_GetNextSibling(hwndTV, hChildItem))
|
||||||
{
|
{
|
||||||
memset(&tvi, 0, sizeof(tvi));
|
memset(&tvi, 0, sizeof(tvi));
|
||||||
tvi.hItem = hChildItem;
|
tvi.hItem = hChildItem;
|
||||||
tvi.mask = TVIF_TEXT | TVIF_CHILDREN;
|
tvi.mask = TVIF_TEXT | TVIF_CHILDREN;
|
||||||
tvi.pszText = szBuffer;
|
tvi.pszText = szBuffer;
|
||||||
tvi.cchTextMax = sizeof(szBuffer) / sizeof(szBuffer[0]);
|
tvi.cchTextMax = sizeof(szBuffer) / sizeof(szBuffer[0]);
|
||||||
|
|
||||||
(void)TreeView_GetItem(hwndTV, &tvi);
|
(void)TreeView_GetItem(hwndTV, &tvi);
|
||||||
|
|
||||||
if (!_tcsicmp(szBuffer, szPathPart))
|
if (!_tcsicmp(szBuffer, szPathPart))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hChildItem)
|
if (!hChildItem)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (tvi.cChildren > 0)
|
if (tvi.cChildren > 0)
|
||||||
{
|
{
|
||||||
if (!TreeView_Expand(hwndTV, hChildItem, TVE_EXPAND))
|
if (!TreeView_Expand(hwndTV, hChildItem, TVE_EXPAND))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPath = s ? s + 1 : _T("");
|
keyPath = s ? s + 1 : _T("");
|
||||||
hItem = hChildItem;
|
hItem = hChildItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)TreeView_SelectItem(hwndTV, hItem);
|
(void)TreeView_SelectItem(hwndTV, hItem);
|
||||||
(void)TreeView_EnsureVisible(hwndTV, hItem);
|
(void)TreeView_EnsureVisible(hwndTV, hItem);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue