mirror of
https://github.com/reactos/reactos.git
synced 2025-05-21 01:54: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
reactos/base/applications/regedit
|
@ -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);
|
||||||
|
@ -157,8 +159,8 @@ 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:
|
||||||
|
@ -317,7 +319,8 @@ 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;
|
||||||
|
@ -362,10 +365,12 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
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,11 +378,13 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -391,11 +398,13 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
pChildWnd = NULL;
|
pChildWnd = NULL;
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDOWN: {
|
case WM_LBUTTONDOWN:
|
||||||
|
{
|
||||||
RECT rt;
|
RECT rt;
|
||||||
int x = (short)LOWORD(lParam);
|
int x = (short)LOWORD(lParam);
|
||||||
GetClientRect(hWnd, &rt);
|
GetClientRect(hWnd, &rt);
|
||||||
if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1)
|
||||||
|
{
|
||||||
last_split = pChildWnd->nSplitPos;
|
last_split = pChildWnd->nSplitPos;
|
||||||
draw_splitbar(hWnd, last_split);
|
draw_splitbar(hWnd, last_split);
|
||||||
SetCapture(hWnd);
|
SetCapture(hWnd);
|
||||||
|
@ -405,7 +414,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
|
|
||||||
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,7 +440,8 @@ 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;
|
||||||
|
@ -464,7 +476,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
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,21 +486,26 @@ 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;
|
LPCTSTR keyPath, rootName;
|
||||||
LPTSTR fullPath;
|
LPTSTR fullPath;
|
||||||
HKEY hRootKey;
|
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);
|
RefreshListView(pChildWnd->hListWnd, hRootKey, keyPath);
|
||||||
rootName = get_root_key_name(hRootKey);
|
rootName = get_root_key_name(hRootKey);
|
||||||
fullPath = HeapAlloc(GetProcessHeap(), 0, (_tcslen(rootName) + 1 + _tcslen(keyPath) + 1) * sizeof(TCHAR));
|
fullPath = HeapAlloc(GetProcessHeap(), 0, (_tcslen(rootName) + 1 + _tcslen(keyPath) + 1) * sizeof(TCHAR));
|
||||||
if (fullPath) {
|
if (fullPath)
|
||||||
|
{
|
||||||
/* set (correct) the address bar text */
|
/* set (correct) the address bar text */
|
||||||
if(keyPath[0] != '\0')
|
if(keyPath[0] != '\0')
|
||||||
_stprintf(fullPath, _T("%s\\%s"), rootName, keyPath);
|
_stprintf(fullPath, _T("%s\\%s"), rootName, keyPath);
|
||||||
|
@ -573,11 +591,13 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
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:
|
case NM_SETFOCUS:
|
||||||
pChildWnd->nFocusPanel = 1;
|
pChildWnd->nFocusPanel = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -745,11 +765,13 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -96,7 +96,8 @@ 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("")))
|
||||||
{
|
{
|
||||||
|
@ -163,7 +164,8 @@ 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("")))
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -382,7 +385,8 @@ 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("")))
|
||||||
{
|
{
|
||||||
|
@ -786,7 +790,8 @@ 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);
|
error_code_messagebox(hwnd, lRet);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -798,7 +803,8 @@ 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);
|
error(hwnd, IDS_BAD_KEY, keyPath);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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*/
|
||||||
|
@ -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:
|
||||||
|
@ -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,7 +438,8 @@ 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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
@ -1015,8 +1042,8 @@ 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, 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);
|
||||||
|
@ -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,
|
||||||
|
|
|
@ -162,8 +162,10 @@ 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)
|
||||||
|
@ -205,7 +207,8 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
|
||||||
ListView_SetItemText(hwndLV, index, 2, _T(""));
|
ListView_SetItemText(hwndLV, index, 2, _T(""));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REG_DWORD: {
|
case REG_DWORD:
|
||||||
|
{
|
||||||
TCHAR buf[200];
|
TCHAR buf[200];
|
||||||
if(dwCount == sizeof(DWORD))
|
if(dwCount == sizeof(DWORD))
|
||||||
{
|
{
|
||||||
|
@ -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];
|
||||||
|
@ -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,7 +355,8 @@ 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);
|
||||||
|
@ -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,14 +396,16 @@ 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:
|
case LVN_GETDISPINFO:
|
||||||
OnGetDispInfo((NMLVDISPINFO*)lParam);
|
OnGetDispInfo((NMLVDISPINFO*)lParam);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case LVN_COLUMNCLICK:
|
case LVN_COLUMNCLICK:
|
||||||
if (g_columnToSort == (DWORD)((LPNMLISTVIEW)lParam)->iSubItem)
|
if (g_columnToSort == (DWORD)((LPNMLISTVIEW)lParam)->iSubItem)
|
||||||
g_invertSort = !g_invertSort;
|
g_invertSort = !g_invertSort;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
g_columnToSort = ((LPNMLISTVIEW)lParam)->iSubItem;
|
g_columnToSort = ((LPNMLISTVIEW)lParam)->iSubItem;
|
||||||
g_invertSort = FALSE;
|
g_invertSort = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -503,7 +513,8 @@ void DestroyListView(HWND hwndLV)
|
||||||
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
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -159,7 +161,8 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,7 +54,8 @@ 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;
|
||||||
|
|
|
@ -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,19 +134,23 @@ 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: {
|
{
|
||||||
|
case ACTION_ADD:
|
||||||
|
{
|
||||||
WCHAR filename[MAX_PATH];
|
WCHAR filename[MAX_PATH];
|
||||||
FILE *fp;
|
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, "%s: No file name is specified\n", getAppName());
|
||||||
fprintf(stderr, usage);
|
fprintf(stderr, usage);
|
||||||
exit(4);
|
exit(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(filename[0]) {
|
while(filename[0])
|
||||||
|
{
|
||||||
fp = _wfopen(filename, L"r");
|
fp = _wfopen(filename, L"r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
|
@ -148,10 +165,12 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTION_DELETE: {
|
case ACTION_DELETE:
|
||||||
|
{
|
||||||
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]) {
|
if (!reg_key_name[0])
|
||||||
|
{
|
||||||
fprintf(stderr, "%s: No registry key is specified for removal\n", getAppName());
|
fprintf(stderr, "%s: No registry key is specified for removal\n", getAppName());
|
||||||
fprintf(stderr, usage);
|
fprintf(stderr, usage);
|
||||||
exit(6);
|
exit(6);
|
||||||
|
@ -159,22 +178,27 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s)
|
||||||
delete_registry_key(reg_key_name);
|
delete_registry_key(reg_key_name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTION_EXPORT: {
|
case ACTION_EXPORT:
|
||||||
|
{
|
||||||
WCHAR filename[MAX_PATH];
|
WCHAR filename[MAX_PATH];
|
||||||
|
|
||||||
filename[0] = _T('\0');
|
filename[0] = _T('\0');
|
||||||
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, "%s: No file name is specified\n", getAppName());
|
||||||
fprintf(stderr, usage);
|
fprintf(stderr, usage);
|
||||||
exit(7);
|
exit(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s[0]) {
|
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);
|
||||||
export_registry_key(filename, reg_key_name, REG_FORMAT_4);
|
export_registry_key(filename, reg_key_name, REG_FORMAT_4);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
export_registry_key(filename, NULL, REG_FORMAT_4);
|
export_registry_key(filename, NULL, REG_FORMAT_4);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,19 +30,22 @@
|
||||||
*/
|
*/
|
||||||
#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_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CLASSES_ROOT",
|
||||||
"HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER", "HKEY_DYN_DATA"
|
"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_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT,
|
||||||
HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA
|
HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA
|
||||||
};
|
};
|
||||||
|
@ -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',':','"'};
|
||||||
|
@ -225,7 +237,8 @@ static DWORD getDataType(LPWSTR *lpValue, DWORD* parse_type)
|
||||||
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;
|
||||||
|
@ -275,7 +295,9 @@ static void REGPROC_unescape_string(WCHAR* str)
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -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 &&
|
}
|
||||||
|
else if( currentKeyHandle &&
|
||||||
(( stdInput[0] == '@') || /* reading a default @=data pair */
|
(( stdInput[0] == '@') || /* reading a default @=data pair */
|
||||||
( stdInput[0] == '\"'))) /* reading a new value=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,35 +712,41 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -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';
|
||||||
|
@ -860,7 +921,8 @@ 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);
|
||||||
|
@ -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;
|
||||||
|
@ -1081,7 +1151,8 @@ static void export_hkey(FILE *file, HKEY key,
|
||||||
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);
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
@ -1298,7 +1394,8 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
|
||||||
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;
|
||||||
|
@ -1308,14 +1405,16 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
|
||||||
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,
|
||||||
|
@ -1323,7 +1422,9 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
|
||||||
&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,
|
||||||
|
@ -1331,24 +1432,30 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
|
||||||
&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,
|
||||||
|
@ -1359,7 +1466,8 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,14 +1517,16 @@ 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);
|
||||||
|
|
|
@ -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 */
|
/* found root key with valid key value */
|
||||||
*phKey = (HKEY)item.lParam;
|
*phKey = (HKEY)item.lParam;
|
||||||
return TRUE;
|
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,7 +65,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +74,8 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe
|
||||||
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,7 +92,8 @@ 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,9 +235,11 @@ 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;
|
||||||
|
@ -228,30 +247,38 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
|
||||||
|
|
||||||
/* 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);
|
||||||
}
|
}
|
||||||
|
@ -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,10 +522,13 @@ 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 {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
hNewKey = hRoot;
|
hNewKey = hRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,14 +645,16 @@ 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)
|
if (pathBuffer)
|
||||||
HeapFree(GetProcessHeap(), 0, pathBuffer);
|
HeapFree(GetProcessHeap(), 0, pathBuffer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue