Commit 58c185ec authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Reformat regedit in a consistent manner.

parent 8aef340c
...@@ -56,25 +56,25 @@ static void MakeFullRegPath(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* p ...@@ -56,25 +56,25 @@ static void MakeFullRegPath(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* p
static void draw_splitbar(HWND hWnd, int x) static void draw_splitbar(HWND hWnd, int x)
{ {
RECT rt; RECT rt;
HDC hdc = GetDC(hWnd); HDC hdc = GetDC(hWnd);
GetClientRect(hWnd, &rt); GetClientRect(hWnd, &rt);
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;
InvertRect(hdc, &rt); InvertRect(hdc, &rt);
ReleaseDC(hWnd, hdc); ReleaseDC(hWnd, hdc);
} }
static void ResizeWnd(ChildWnd* pChildWnd, int cx, int cy) static void ResizeWnd(ChildWnd* pChildWnd, int cx, int cy)
{ {
HDWP hdwp = BeginDeferWindowPos(2); HDWP hdwp = BeginDeferWindowPos(2);
RECT rt = {0, 0, cx, cy}; RECT rt = {0, 0, cx, cy};
cx = pChildWnd->nSplitPos + SPLIT_WIDTH/2; cx = pChildWnd->nSplitPos + SPLIT_WIDTH/2;
DeferWindowPos(hdwp, pChildWnd->hTreeWnd, 0, rt.left, rt.top, pChildWnd->nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); DeferWindowPos(hdwp, pChildWnd->hTreeWnd, 0, rt.left, rt.top, pChildWnd->nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
DeferWindowPos(hdwp, pChildWnd->hListWnd, 0, rt.left+cx , rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); DeferWindowPos(hdwp, pChildWnd->hListWnd, 0, rt.left+cx , rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
EndDeferWindowPos(hdwp); EndDeferWindowPos(hdwp);
} }
static void OnPaint(HWND hWnd) static void OnPaint(HWND hWnd)
...@@ -99,8 +99,8 @@ static void OnPaint(HWND hWnd) ...@@ -99,8 +99,8 @@ static void OnPaint(HWND hWnd)
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
/* Parse the menu selections: */ /* Parse the menu selections: */
case ID_REGISTRY_EXIT: case ID_REGISTRY_EXIT:
DestroyWindow(hWnd); DestroyWindow(hWnd);
break; break;
...@@ -110,7 +110,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -110,7 +110,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
default: default:
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
/******************************************************************************* /*******************************************************************************
...@@ -127,12 +127,12 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -127,12 +127,12 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
static int last_split; static int last_split;
/* ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA); */ /* ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA); */
switch (message) { switch (message) {
case WM_CREATE: case WM_CREATE:
pChildWnd = (ChildWnd*)((LPCREATESTRUCT)lParam)->lpCreateParams; pChildWnd = (ChildWnd*)((LPCREATESTRUCT)lParam)->lpCreateParams;
if (!pChildWnd) return 0; if (!pChildWnd) return 0;
pChildWnd->nSplitPos = 250; pChildWnd->nSplitPos = 250;
pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, TREE_WINDOW); pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, TREE_WINDOW);
pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW/*, pChildWnd->szPath*/); pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW/*, pChildWnd->szPath*/);
...@@ -141,99 +141,99 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa ...@@ -141,99 +141,99 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
if (!_CmdWndProc(hWnd, message, wParam, lParam)) { if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
goto def; goto def;
} }
break; break;
case WM_PAINT: case WM_PAINT:
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:
PostQuitMessage(0); PostQuitMessage(0);
break; break;
case WM_LBUTTONDOWN: { case WM_LBUTTONDOWN: {
RECT rt; RECT rt;
int x = LOWORD(lParam); int x = 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);
} }
break;} break;
}
case WM_LBUTTONUP: case WM_LBUTTONUP:
if (GetCapture() == hWnd) { if (GetCapture() == hWnd) {
RECT rt; RECT rt;
int x = LOWORD(lParam); int x = LOWORD(lParam);
draw_splitbar(hWnd, last_split); draw_splitbar(hWnd, last_split);
last_split = -1; last_split = -1;
GetClientRect(hWnd, &rt); GetClientRect(hWnd, &rt);
pChildWnd->nSplitPos = x; pChildWnd->nSplitPos = x;
ResizeWnd(pChildWnd, rt.right, rt.bottom); ResizeWnd(pChildWnd, rt.right, rt.bottom);
ReleaseCapture(); ReleaseCapture();
} }
break; break;
case WM_CAPTURECHANGED: case WM_CAPTURECHANGED:
if (GetCapture()==hWnd && last_split>=0) if (GetCapture()==hWnd && last_split>=0)
draw_splitbar(hWnd, last_split); draw_splitbar(hWnd, last_split);
break; break;
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);
ResizeWnd(pChildWnd, rt.right, rt.bottom); ResizeWnd(pChildWnd, rt.right, rt.bottom);
last_split = -1; last_split = -1;
ReleaseCapture(); ReleaseCapture();
SetCursor(LoadCursor(0, IDC_ARROW)); SetCursor(LoadCursor(0, IDC_ARROW));
} }
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (GetCapture() == hWnd) { if (GetCapture() == hWnd) {
RECT rt; RECT rt;
int x = LOWORD(lParam); int x = LOWORD(lParam);
HDC hdc = GetDC(hWnd); HDC hdc = GetDC(hWnd);
GetClientRect(hWnd, &rt); GetClientRect(hWnd, &rt);
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;
InvertRect(hdc, &rt); InvertRect(hdc, &rt);
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;
InvertRect(hdc, &rt); InvertRect(hdc, &rt);
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;
case WM_TIMER: case WM_TIMER:
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: {
{
HKEY hKey; HKEY hKey;
TCHAR keyPath[1000]; TCHAR keyPath[1000];
int keyPathLen = 0; int keyPathLen = 0;
...@@ -251,20 +251,20 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa ...@@ -251,20 +251,20 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
goto def; goto def;
} }
} else } else
if ((int)wParam == LIST_WINDOW) { if ((int)wParam == LIST_WINDOW) {
if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) { if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) {
goto def; goto def;
}
} }
}
break; 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;
} }
...@@ -47,10 +47,10 @@ void error(HWND hwnd, INT resId, ...) ...@@ -47,10 +47,10 @@ void error(HWND hwnd, INT resId, ...)
hInstance = GetModuleHandle(0); hInstance = GetModuleHandle(0);
if (!LoadString(hInstance, IDS_ERROR, title, COUNT_OF(title))) if (!LoadString(hInstance, IDS_ERROR, title, COUNT_OF(title)))
lstrcpy(title, "Error"); lstrcpy(title, "Error");
if (!LoadString(hInstance, resId, errfmt, COUNT_OF(errfmt))) if (!LoadString(hInstance, resId, errfmt, COUNT_OF(errfmt)))
lstrcpy(errfmt, "Unknown error string!"); lstrcpy(errfmt, "Unknown error string!");
va_start(ap, resId); va_start(ap, resId);
_vsntprintf(errstr, COUNT_OF(errstr), errfmt, ap); _vsntprintf(errstr, COUNT_OF(errstr), errfmt, ap);
...@@ -66,27 +66,27 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L ...@@ -66,27 +66,27 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
int len; int len;
switch(uMsg) { switch(uMsg) {
case WM_INITDIALOG: case WM_INITDIALOG:
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData); SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
return TRUE; return TRUE;
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
case IDOK: case IDOK:
if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) { if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) {
if ((len = GetWindowTextLength(hwndValue))) { if ((len = GetWindowTextLength(hwndValue))) {
if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR)))) { if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR)))) {
stringValueData = valueData; stringValueData = valueData;
if (!GetWindowText(hwndValue, stringValueData, len + 1)) if (!GetWindowText(hwndValue, stringValueData, len + 1))
*stringValueData = 0; *stringValueData = 0;
} }
} }
} }
/* Fall through */ /* Fall through */
case IDCANCEL: case IDCANCEL:
EndDialog(hwndDlg, wParam); EndDialog(hwndDlg, wParam);
return TRUE; return TRUE;
} }
} }
return FALSE; return FALSE;
} }
...@@ -104,28 +104,28 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPTSTR valueName) ...@@ -104,28 +104,28 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPTSTR valueName)
lRet = RegQueryValueEx(hKey, valueName, 0, &type, 0, &valueDataLen); lRet = RegQueryValueEx(hKey, valueName, 0, &type, 0, &valueDataLen);
if (lRet != ERROR_SUCCESS) { if (lRet != ERROR_SUCCESS) {
error(hwnd, IDS_BAD_VALUE, valueName); error(hwnd, IDS_BAD_VALUE, valueName);
goto done; goto done;
} }
if ( (type == REG_SZ) || (type == REG_EXPAND_SZ) ) { if ( (type == REG_SZ) || (type == REG_EXPAND_SZ) ) {
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;
} }
lRet = RegQueryValueEx(hKey, valueName, 0, 0, stringValueData, &valueDataLen); lRet = RegQueryValueEx(hKey, valueName, 0, 0, stringValueData, &valueDataLen);
if (lRet != ERROR_SUCCESS) { if (lRet != ERROR_SUCCESS) {
error(hwnd, IDS_BAD_VALUE, valueName); error(hwnd, IDS_BAD_VALUE, valueName);
goto done; goto done;
} }
if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) { if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) {
lRet = RegSetValueEx(hKey, valueName, 0, type, stringValueData, lstrlen(stringValueData) + 1); lRet = RegSetValueEx(hKey, valueName, 0, type, stringValueData, lstrlen(stringValueData) + 1);
if (lRet == ERROR_SUCCESS) result = TRUE; if (lRet == ERROR_SUCCESS) result = TRUE;
} }
} else if ( type == REG_DWORD ) { } else if ( type == REG_DWORD ) {
MessageBox(hwnd, "Can't edit dwords for now", "Error", MB_OK | MB_ICONERROR); MessageBox(hwnd, "Can't edit dwords for now", "Error", MB_OK | MB_ICONERROR);
} else { } else {
error(hwnd, IDS_UNSUPPORTED_TYPE, type); error(hwnd, IDS_UNSUPPORTED_TYPE, type);
} }
done: done:
......
...@@ -46,29 +46,29 @@ static HWND hChildWnd; ...@@ -46,29 +46,29 @@ static HWND hChildWnd;
static void resize_frame_rect(HWND hWnd, PRECT prect) static void resize_frame_rect(HWND hWnd, PRECT prect)
{ {
RECT rt; RECT rt;
/* /*
if (IsWindowVisible(hToolBar)) { if (IsWindowVisible(hToolBar)) {
SendMessage(hToolBar, WM_SIZE, 0, 0); SendMessage(hToolBar, WM_SIZE, 0, 0);
GetClientRect(hToolBar, &rt); GetClientRect(hToolBar, &rt);
prect->top = rt.bottom+3; prect->top = rt.bottom+3;
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;
} }
MoveWindow(hChildWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE); MoveWindow(hChildWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
} }
void resize_frame_client(HWND hWnd) void resize_frame_client(HWND hWnd)
{ {
RECT rect; RECT rect;
GetClientRect(hWnd, &rect); GetClientRect(hWnd, &rect);
resize_frame_rect(hWnd, &rect); resize_frame_rect(hWnd, &rect);
} }
/********************************************************************************/ /********************************************************************************/
...@@ -88,8 +88,8 @@ static void OnExitMenuLoop(HWND hWnd) ...@@ -88,8 +88,8 @@ static void OnExitMenuLoop(HWND hWnd)
{ {
bInMenuLoop = FALSE; bInMenuLoop = FALSE;
/* Update the status bar pane sizes*/ /* Update the status bar pane sizes*/
SetupStatusBar(hWnd, TRUE); SetupStatusBar(hWnd, TRUE);
UpdateStatusBar(); UpdateStatusBar();
} }
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu) static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
...@@ -119,70 +119,70 @@ void SetupStatusBar(HWND hWnd, BOOL bResize) ...@@ -119,70 +119,70 @@ void SetupStatusBar(HWND hWnd, BOOL bResize)
int nParts; int nParts;
GetClientRect(hWnd, &rc); GetClientRect(hWnd, &rc);
nParts = rc.right; nParts = rc.right;
/* nParts = -1;*/ /* nParts = -1;*/
if (bResize) if (bResize)
SendMessage(hStatusBar, WM_SIZE, 0, 0); SendMessage(hStatusBar, WM_SIZE, 0, 0);
SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts); SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
} }
void UpdateStatusBar(void) void UpdateStatusBar(void)
{ {
TCHAR text[260]; TCHAR text[260];
DWORD size; DWORD size;
size = sizeof(text)/sizeof(TCHAR); size = sizeof(text)/sizeof(TCHAR);
GetComputerName(text, &size); GetComputerName(text, &size);
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text); SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text);
} }
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild) static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
{ {
BOOL vis = IsWindowVisible(hchild); BOOL vis = IsWindowVisible(hchild);
HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU); HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED); CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED);
ShowWindow(hchild, vis?SW_HIDE:SW_SHOW); ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
resize_frame_client(hWnd); resize_frame_client(hWnd);
} }
static BOOL CheckCommDlgError(HWND hWnd) static BOOL CheckCommDlgError(HWND hWnd)
{ {
DWORD dwErrorCode = CommDlgExtendedError(); DWORD dwErrorCode = CommDlgExtendedError();
switch (dwErrorCode) { switch (dwErrorCode) {
case CDERR_DIALOGFAILURE: case CDERR_DIALOGFAILURE:
break; break;
case CDERR_FINDRESFAILURE: case CDERR_FINDRESFAILURE:
break; break;
case CDERR_NOHINSTANCE: case CDERR_NOHINSTANCE:
break; break;
case CDERR_INITIALIZATION: case CDERR_INITIALIZATION:
break; break;
case CDERR_NOHOOK: case CDERR_NOHOOK:
break; break;
case CDERR_LOCKRESFAILURE: case CDERR_LOCKRESFAILURE:
break; break;
case CDERR_NOTEMPLATE: case CDERR_NOTEMPLATE:
break; break;
case CDERR_LOADRESFAILURE: case CDERR_LOADRESFAILURE:
break; break;
case CDERR_STRUCTSIZE: case CDERR_STRUCTSIZE:
break; break;
case CDERR_LOADSTRFAILURE: case CDERR_LOADSTRFAILURE:
break; break;
case FNERR_BUFFERTOOSMALL: case FNERR_BUFFERTOOSMALL:
break; break;
case CDERR_MEMALLOCFAILURE: case CDERR_MEMALLOCFAILURE:
break; break;
case FNERR_INVALIDFILENAME: case FNERR_INVALIDFILENAME:
break; break;
case CDERR_MEMLOCKFAILURE: case CDERR_MEMLOCKFAILURE:
break; break;
case FNERR_SUBCLASSFAILURE: case FNERR_SUBCLASSFAILURE:
break; break;
default: default:
break; break;
} }
return TRUE; return TRUE;
} }
UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
...@@ -196,8 +196,7 @@ UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM w ...@@ -196,8 +196,7 @@ UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM w
break; break;
case WM_NOTIFY: case WM_NOTIFY:
pOfNotify = (OFNOTIFY*)lParam; pOfNotify = (OFNOTIFY*)lParam;
if (pOfNotify->hdr.code == CDN_INITDONE) { if (pOfNotify->hdr.code == CDN_INITDONE) {}
}
break; break;
default: default:
break; break;
...@@ -225,19 +224,19 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn) ...@@ -225,19 +224,19 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
pofn->nMaxFile = _MAX_PATH; pofn->nMaxFile = _MAX_PATH;
pofn->lpstrFileTitle = FileTitleBuffer; pofn->lpstrFileTitle = FileTitleBuffer;
pofn->nMaxFileTitle = _MAX_PATH; pofn->nMaxFileTitle = _MAX_PATH;
/* pofn->lpstrInitialDir = _T("");*/ /* pofn->lpstrInitialDir = _T("");*/
/* pofn->lpstrTitle = _T("Import Registry File");*/ /* pofn->lpstrTitle = _T("Import Registry File");*/
/* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/ /* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/
pofn->Flags = OFN_HIDEREADONLY; pofn->Flags = OFN_HIDEREADONLY;
/* pofn->nFileOffset = ;*/ /* pofn->nFileOffset = ;*/
/* pofn->nFileExtension = ;*/ /* pofn->nFileExtension = ;*/
/* pofn->lpstrDefExt = _T("");*/ /* pofn->lpstrDefExt = _T("");*/
/* pofn->lCustData = ;*/ /* pofn->lCustData = ;*/
/* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/ /* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/
/* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/ /* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/
/* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/ /* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/
/* pofn->FlagsEx = ;*/ /* pofn->FlagsEx = ;*/
return TRUE; return TRUE;
} }
static BOOL ImportRegistryFile(HWND hWnd) static BOOL ImportRegistryFile(HWND hWnd)
...@@ -246,7 +245,7 @@ static BOOL ImportRegistryFile(HWND hWnd) ...@@ -246,7 +245,7 @@ static BOOL ImportRegistryFile(HWND hWnd)
InitOpenFileName(hWnd, &ofn); InitOpenFileName(hWnd, &ofn);
ofn.lpstrTitle = _T("Import Registry File"); ofn.lpstrTitle = _T("Import Registry File");
/* ofn.lCustData = ;*/ /* ofn.lCustData = ;*/
if (GetOpenFileName(&ofn)) { if (GetOpenFileName(&ofn)) {
if (!import_registry_file(ofn.lpstrFile)) { if (!import_registry_file(ofn.lpstrFile)) {
/*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/ /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
...@@ -269,10 +268,11 @@ static BOOL ImportRegistryFile(HWND hWnd) ...@@ -269,10 +268,11 @@ static BOOL ImportRegistryFile(HWND hWnd)
get_file_name(&s, filename, MAX_PATH); get_file_name(&s, filename, MAX_PATH);
} }
#endif #endif
} else { } else {
CheckCommDlgError(hWnd); CheckCommDlgError(hWnd);
} }
return TRUE; return TRUE;
} }
...@@ -284,7 +284,7 @@ static BOOL ExportRegistryFile(HWND hWnd) ...@@ -284,7 +284,7 @@ static BOOL ExportRegistryFile(HWND hWnd)
ExportKeyPath[0] = _T('\0'); ExportKeyPath[0] = _T('\0');
InitOpenFileName(hWnd, &ofn); InitOpenFileName(hWnd, &ofn);
ofn.lpstrTitle = _T("Export Registry File"); ofn.lpstrTitle = _T("Export Registry File");
/* ofn.lCustData = ;*/ /* ofn.lCustData = ;*/
ofn.Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER; ofn.Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER;
ofn.lpfnHook = ImportRegistryFile_OFNHookProc; ofn.lpfnHook = ImportRegistryFile_OFNHookProc;
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1); ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);
...@@ -314,10 +314,11 @@ static BOOL ExportRegistryFile(HWND hWnd) ...@@ -314,10 +314,11 @@ static BOOL ExportRegistryFile(HWND hWnd)
export_registry_key(filename, NULL); export_registry_key(filename, NULL);
} }
#endif #endif
} else { } else {
CheckCommDlgError(hWnd); CheckCommDlgError(hWnd);
} }
return TRUE; return TRUE;
} }
BOOL PrintRegistryHive(HWND hWnd, LPTSTR path) BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
...@@ -449,8 +450,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -449,8 +450,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
item = ListView_GetNextItem(pChildWnd->hListWnd, -1, LVNI_FOCUSED); item = ListView_GetNextItem(pChildWnd->hListWnd, -1, LVNI_FOCUSED);
if (item != -1) ListView_GetItemText(pChildWnd->hListWnd, item, 0, valueName, sizeof(valueName)/sizeof(TCHAR)); if (item != -1) ListView_GetItemText(pChildWnd->hListWnd, item, 0, valueName, sizeof(valueName)/sizeof(TCHAR));
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
/* Parse the menu selections:*/ /* Parse the menu selections:*/
case ID_REGISTRY_IMPORTREGISTRYFILE: case ID_REGISTRY_IMPORTREGISTRYFILE:
ImportRegistryFile(hWnd); ImportRegistryFile(hWnd);
break; break;
...@@ -465,9 +466,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -465,9 +466,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
PrintRegistryHive(hWnd, _T("")); PrintRegistryHive(hWnd, _T(""));
break; break;
case ID_EDIT_MODIFY: case ID_EDIT_MODIFY:
if (ModifyValue(hWnd, hKey, valueName)) if (ModifyValue(hWnd, hKey, valueName))
RefreshListView(pChildWnd->hListWnd, hKeyRoot, keyPath); RefreshListView(pChildWnd->hListWnd, hKeyRoot, keyPath);
break; break;
case ID_EDIT_COPYKEYNAME: case ID_EDIT_COPYKEYNAME:
CopyKeyName(hWnd, _T("")); CopyKeyName(hWnd, _T(""));
break; break;
...@@ -485,27 +486,27 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -485,27 +486,27 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case ID_VIEW_REFRESH: case ID_VIEW_REFRESH:
RefreshView(hWnd); RefreshView(hWnd);
break; break;
/* case ID_OPTIONS_TOOLBAR:*/ /* case ID_OPTIONS_TOOLBAR:*/
/* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/ /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
/* break;*/ /* break;*/
case ID_VIEW_STATUSBAR: case ID_VIEW_STATUSBAR:
toggle_child(hWnd, LOWORD(wParam), hStatusBar); toggle_child(hWnd, LOWORD(wParam), hStatusBar);
break; break;
case ID_HELP_HELPTOPICS: case ID_HELP_HELPTOPICS:
/* WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);*/ /* WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);*/
WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0); WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
break; break;
case ID_HELP_ABOUT: case ID_HELP_ABOUT:
#ifdef WINSHELLAPI #ifdef WINSHELLAPI
/* ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));*/ /* ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));*/
#else #else
ShowAboutBox(hWnd); ShowAboutBox(hWnd);
#endif #endif
break; break;
default: default:
result = FALSE; result = FALSE;
} }
RegCloseKey(hKey); RegCloseKey(hKey);
return result; return result;
} }
...@@ -526,15 +527,14 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa ...@@ -526,15 +527,14 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
static ChildWnd* pChildWnd = NULL; static ChildWnd* pChildWnd = NULL;
switch (message) { switch (message) {
case WM_CREATE: case WM_CREATE: {
{ pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd));
pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd)); _tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH);
_tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH); hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"),
hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"), /* WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,*/
/* WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,*/ WS_CHILD|WS_VISIBLE,
WS_CHILD|WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hWnd, (HMENU)0, hInst, pChildWnd);
hWnd, (HMENU)0, hInst, pChildWnd);
} }
break; break;
case WM_COMMAND: case WM_COMMAND:
...@@ -565,6 +565,6 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa ...@@ -565,6 +565,6 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
PostQuitMessage(0); PostQuitMessage(0);
default: default:
return DefWindowProc(hWnd, message, wParam, lParam); return DefWindowProc(hWnd, message, wParam, lParam);
} }
return 0; return 0;
} }
...@@ -61,30 +61,28 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB ...@@ -61,30 +61,28 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
item.pszText = LPSTR_TEXTCALLBACK; item.pszText = LPSTR_TEXTCALLBACK;
item.iImage = 0; item.iImage = 0;
item.lParam = (LPARAM)dwValType; item.lParam = (LPARAM)dwValType;
/* item.lParam = (LPARAM)ValBuf; */ /* item.lParam = (LPARAM)ValBuf; */
#if (_WIN32_IE >= 0x0300) #if (_WIN32_IE >= 0x0300)
item.iIndent = 0; item.iIndent = 0;
#endif #endif
index = ListView_InsertItem(hwndLV, &item); index = ListView_InsertItem(hwndLV, &item);
if (index != -1) { if (index != -1) {
/* LPTSTR pszText = NULL; */ /* LPTSTR pszText = NULL; */
LPTSTR pszText = _T("value"); LPTSTR pszText = _T("value");
switch (dwValType) { switch (dwValType) {
case REG_SZ: case REG_SZ:
case REG_EXPAND_SZ: case REG_EXPAND_SZ:
ListView_SetItemText(hwndLV, index, 2, ValBuf); ListView_SetItemText(hwndLV, index, 2, ValBuf);
break; break;
case REG_DWORD: case REG_DWORD: {
{
TCHAR buf[64]; TCHAR buf[64];
wsprintf(buf, _T("0x%08X (%d)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf); wsprintf(buf, _T("0x%08X (%d)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf);
ListView_SetItemText(hwndLV, index, 2, buf); ListView_SetItemText(hwndLV, index, 2, buf);
} }
/* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */ /* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
break; break;
case REG_BINARY: case REG_BINARY: {
{
unsigned int i; unsigned int i;
LPBYTE pData = (LPBYTE)ValBuf; LPBYTE pData = (LPBYTE)ValBuf;
LPTSTR strBinary = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(TCHAR) * 3 + 1); LPTSTR strBinary = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(TCHAR) * 3 + 1);
...@@ -96,7 +94,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB ...@@ -96,7 +94,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
} }
break; break;
default: default:
/* lpsRes = convertHexToHexCSV(lpbData, dwLen); */ /* lpsRes = convertHexToHexCSV(lpbData, dwLen); */
ListView_SetItemText(hwndLV, index, 2, pszText); ListView_SetItemText(hwndLV, index, 2, pszText);
break; break;
} }
...@@ -153,9 +151,9 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi) ...@@ -153,9 +151,9 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
case REG_DWORD: case REG_DWORD:
plvdi->item.pszText = _T("REG_DWORD"); plvdi->item.pszText = _T("REG_DWORD");
break; break;
/* case REG_DWORD_LITTLE_ENDIAN: */ /* case REG_DWORD_LITTLE_ENDIAN: */
/* plvdi->item.pszText = _T("REG_DWORD_LITTLE_ENDIAN"); */ /* plvdi->item.pszText = _T("REG_DWORD_LITTLE_ENDIAN"); */
/* break; */ /* break; */
case REG_DWORD_BIG_ENDIAN: case REG_DWORD_BIG_ENDIAN:
plvdi->item.pszText = _T("REG_DWORD_BIG_ENDIAN"); plvdi->item.pszText = _T("REG_DWORD_BIG_ENDIAN");
break; break;
...@@ -199,97 +197,93 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor ...@@ -199,97 +197,93 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor
#endif #endif
static void ListViewPopUpMenu(HWND hWnd, POINT pt) static void ListViewPopUpMenu(HWND hWnd, POINT pt)
{ {}
}
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
/* case ID_FILE_OPEN: */ /* case ID_FILE_OPEN: */
/* break; */ /* break; */
default: default:
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) { switch (message) {
case WM_COMMAND: case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam)) { if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam);
} }
break; break;
case WM_NOTIFY: case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code) { switch (((LPNMHDR)lParam)->code) {
case LVN_GETDISPINFO: case LVN_GETDISPINFO:
OnGetDispInfo((NMLVDISPINFO*)lParam); OnGetDispInfo((NMLVDISPINFO*)lParam);
break; break;
case NM_DBLCLK: case NM_DBLCLK: {
{ NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam;
NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam; LVHITTESTINFO info;
LVHITTESTINFO info;
if (nmitem->hdr.hwndFrom != hWnd) break;
if (nmitem->hdr.hwndFrom != hWnd) break; /* if (nmitem->hdr.idFrom != IDW_LISTVIEW) break; */
/* if (nmitem->hdr.idFrom != IDW_LISTVIEW) break; */ /* if (nmitem->hdr.code != ???) break; */
/* if (nmitem->hdr.code != ???) break; */
#ifdef _MSC_VER #ifdef _MSC_VER
switch (nmitem->uKeyFlags) { switch (nmitem->uKeyFlags) {
case LVKF_ALT: /* The ALT key is pressed. */ case LVKF_ALT: /* The ALT key is pressed. */
/* properties dialog box ? */ /* properties dialog box ? */
break; break;
case LVKF_CONTROL: /* The CTRL key is pressed. */ case LVKF_CONTROL: /* The CTRL key is pressed. */
/* run dialog box for providing parameters... */ /* run dialog box for providing parameters... */
break; break;
case LVKF_SHIFT: /* The SHIFT key is pressed. */ case LVKF_SHIFT: /* The SHIFT key is pressed. */
break; break;
} }
#endif #endif
info.pt.x = nmitem->ptAction.x; info.pt.x = nmitem->ptAction.x;
info.pt.y = nmitem->ptAction.y; info.pt.y = nmitem->ptAction.y;
if (ListView_HitTest(hWnd, &info) != -1) { if (ListView_HitTest(hWnd, &info) != -1) {
LVITEM item; LVITEM item;
item.mask = LVIF_PARAM; item.mask = LVIF_PARAM;
item.iItem = info.iItem; item.iItem = info.iItem;
if (ListView_GetItem(hWnd, &item)) { if (ListView_GetItem(hWnd, &item)) {}
} }
} }
}
break; break;
case NM_RCLICK: case NM_RCLICK: {
{ int idx;
int idx; LV_HITTESTINFO lvH;
LV_HITTESTINFO lvH; NM_LISTVIEW* pNm = (NM_LISTVIEW*)lParam;
NM_LISTVIEW* pNm = (NM_LISTVIEW*)lParam; lvH.pt.x = pNm->ptAction.x;
lvH.pt.x = pNm->ptAction.x; lvH.pt.y = pNm->ptAction.y;
lvH.pt.y = pNm->ptAction.y; idx = ListView_HitTest(hWnd, &lvH);
idx = ListView_HitTest(hWnd, &lvH); if (idx != -1) {
if (idx != -1) { POINT pt;
POINT pt; GetCursorPos(&pt);
GetCursorPos(&pt); ListViewPopUpMenu(hWnd, pt);
ListViewPopUpMenu(hWnd, pt); return idx;
return idx; }
}
} }
break; break;
default: default:
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam);
} }
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:
if (wParam == VK_TAB) { if (wParam == VK_TAB) {
/*TODO: SetFocus(Globals.hDriveBar) */ /*TODO: SetFocus(Globals.hDriveBar) */
/*SetFocus(child->nFocusPanel? child->left.hWnd: child->right.hWnd); */ /*SetFocus(child->nFocusPanel? child->left.hWnd: child->right.hWnd); */
} }
/* fall thru... */ /* fall thru... */
default: default:
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam);
break; break;
} }
return 0; return 0;
} }
...@@ -301,21 +295,21 @@ HWND CreateListView(HWND hwndParent, int id) ...@@ -301,21 +295,21 @@ HWND CreateListView(HWND hwndParent, int id)
/* Get the dimensions of the parent window's client area, and create the list view control. */ /* Get the dimensions of the parent window's client area, and create the list view control. */
GetClientRect(hwndParent, &rcClient); GetClientRect(hwndParent, &rcClient);
hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"), hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"),
WS_VISIBLE | WS_CHILD | LVS_REPORT, WS_VISIBLE | WS_CHILD | LVS_REPORT,
0, 0, rcClient.right, rcClient.bottom, 0, 0, rcClient.right, rcClient.bottom,
hwndParent, (HMENU)id, hInst, NULL); hwndParent, (HMENU)id, hInst, NULL);
ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT); ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT);
/* Initialize the image list, and add items to the control. */ /* Initialize the image list, and add items to the control. */
/* /*
if (!InitListViewImageLists(hwndLV) || if (!InitListViewImageLists(hwndLV) ||
!InitListViewItems(hwndLV, szName)) { !InitListViewItems(hwndLV, szName)) {
DestroyWindow(hwndLV); DestroyWindow(hwndLV);
return FALSE; return FALSE;
} }
*/ */
CreateListColumns(hwndLV); CreateListColumns(hwndLV);
g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc); g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc);
return hwndLV; return hwndLV;
} }
...@@ -336,9 +330,9 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath) ...@@ -336,9 +330,9 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
ShowWindow(hwndLV, SW_HIDE); ShowWindow(hwndLV, SW_HIDE);
/* get size information and resize the buffers if necessary */ /* get size information and resize the buffers if necessary */
errCode = RegQueryInfoKey(hNewKey, NULL, NULL, NULL, NULL, errCode = RegQueryInfoKey(hNewKey, NULL, NULL, NULL, NULL,
&max_sub_key_len, NULL, &val_count, &max_val_name_len, &max_val_size, NULL, NULL); &max_sub_key_len, NULL, &val_count, &max_val_name_len, &max_val_size, NULL, NULL);
#define BUF_HEAD_SPACE 2 /* TODO: check why this is required with ROS ??? */ #define BUF_HEAD_SPACE 2 /* TODO: check why this is required with ROS ??? */
if (errCode == ERROR_SUCCESS) { if (errCode == ERROR_SUCCESS) {
TCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE); TCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE);
...@@ -347,10 +341,10 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath) ...@@ -347,10 +341,10 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
DWORD dwValSize = max_val_size; DWORD dwValSize = max_val_size;
DWORD dwIndex = 0L; DWORD dwIndex = 0L;
DWORD dwValType; DWORD dwValType;
/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */ /* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
/* 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) {
ValBuf[dwValSize] = 0; ValBuf[dwValSize] = 0;
AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize); AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize);
...@@ -363,7 +357,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath) ...@@ -363,7 +357,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
HeapFree(GetProcessHeap(), 0, ValName); HeapFree(GetProcessHeap(), 0, ValName);
} }
/*ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV); */ /*ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV); */
/* SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); */ /* SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); */
ShowWindow(hwndLV, SW_SHOW); ShowWindow(hwndLV, SW_SHOW);
RegCloseKey(hNewKey); RegCloseKey(hNewKey);
} }
......
...@@ -67,42 +67,42 @@ TCHAR szChildClass[MAX_LOADSTRING]; ...@@ -67,42 +67,42 @@ TCHAR szChildClass[MAX_LOADSTRING];
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{ {
WNDCLASSEX wcFrame = { WNDCLASSEX wcFrame = {
sizeof(WNDCLASSEX), sizeof(WNDCLASSEX),
CS_HREDRAW | CS_VREDRAW/*style*/, CS_HREDRAW | CS_VREDRAW/*style*/,
FrameWndProc, FrameWndProc,
0/*cbClsExtra*/, 0/*cbClsExtra*/,
0/*cbWndExtra*/, 0/*cbWndExtra*/,
hInstance, hInstance,
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)), LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
LoadCursor(0, IDC_ARROW), LoadCursor(0, IDC_ARROW),
0/*hbrBackground*/, 0/*hbrBackground*/,
0/*lpszMenuName*/, 0/*lpszMenuName*/,
szFrameClass, szFrameClass,
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
}; };
ATOM hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */ ATOM hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */
WNDCLASSEX wcChild = { WNDCLASSEX wcChild = {
sizeof(WNDCLASSEX), sizeof(WNDCLASSEX),
CS_HREDRAW | CS_VREDRAW/*style*/, CS_HREDRAW | CS_VREDRAW/*style*/,
ChildWndProc, ChildWndProc,
0/*cbClsExtra*/, 0/*cbClsExtra*/,
sizeof(HANDLE)/*cbWndExtra*/, sizeof(HANDLE)/*cbWndExtra*/,
hInstance, hInstance,
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)), LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
LoadCursor(0, IDC_ARROW), LoadCursor(0, IDC_ARROW),
0/*hbrBackground*/, 0/*hbrBackground*/,
0/*lpszMenuName*/, 0/*lpszMenuName*/,
szChildClass, szChildClass,
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
}; };
ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */ ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */
hChildWndClass = hChildWndClass; /* warning eater */ hChildWndClass = hChildWndClass; /* warning eater */
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU)); hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
/* Initialize the Windows Common Controls DLL */ /* Initialize the Windows Common Controls DLL */
InitCommonControls(); InitCommonControls();
...@@ -113,9 +113,9 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) ...@@ -113,9 +113,9 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
} */ } */
hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle, hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,
WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE, WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
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;
...@@ -148,20 +148,20 @@ int APIENTRY WinMain(HINSTANCE hInstance, ...@@ -148,20 +148,20 @@ int APIENTRY WinMain(HINSTANCE hInstance,
{ {
MSG msg; MSG msg;
HACCEL hAccel; HACCEL hAccel;
/* /*
int hCrt; int hCrt;
FILE *hf; FILE *hf;
AllocConsole(); AllocConsole();
hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
hf = _fdopen(hCrt, "w"); hf = _fdopen(hCrt, "w");
*stdout = *hf; *stdout = *hf;
setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0);
wprintf(L"command line exit, hInstance = %d\n", hInstance); wprintf(L"command line exit, hInstance = %d\n", hInstance);
getch(); getch();
FreeConsole(); FreeConsole();
return 0; return 0;
*/ */
if (ProcessCmdLine(lpCmdLine)) { if (ProcessCmdLine(lpCmdLine)) {
return 0; return 0;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define LIST_WINDOW 2003 #define LIST_WINDOW 2003
#define MAX_LOADSTRING 100 #define MAX_LOADSTRING 100
#define SPLIT_WIDTH 5 #define SPLIT_WIDTH 5
#define MAX_NAME_LEN 500 #define MAX_NAME_LEN 500
#define COUNT_OF(a) (sizeof(a)/sizeof(a[0])) #define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
...@@ -37,23 +37,23 @@ ...@@ -37,23 +37,23 @@
/******************************************************************************/ /******************************************************************************/
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,
OPTIONS_SAVE_ON_EXIT = 0x08, OPTIONS_SAVE_ON_EXIT = 0x08,
OPTIONS_DISPLAY_BINARY_DATA = 0x10, OPTIONS_DISPLAY_BINARY_DATA = 0x10,
OPTIONS_VIEW_TREE_ONLY = 0x20, OPTIONS_VIEW_TREE_ONLY = 0x20,
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;
int nFocusPanel; /* 0: left 1: right */ int nFocusPanel; /* 0: left 1: right */
int nSplitPos; int nSplitPos;
WINDOWPLACEMENT pos; WINDOWPLACEMENT pos;
TCHAR szPath[MAX_PATH]; TCHAR szPath[MAX_PATH];
} ChildWnd; } ChildWnd;
extern ChildWnd* pChildWnd; extern ChildWnd* pChildWnd;
......
...@@ -24,36 +24,36 @@ ...@@ -24,36 +24,36 @@
#include "regproc.h" #include "regproc.h"
static char *usage = static char *usage =
"Usage:\n" "Usage:\n"
" regedit filename\n" " regedit filename\n"
" regedit /E filename [regpath]\n" " regedit /E filename [regpath]\n"
" regedit /D regpath\n" " regedit /D regpath\n"
"\n" "\n"
"filename - registry file name\n" "filename - registry file name\n"
"regpath - name of the registry key\n" "regpath - name of the registry key\n"
"\n" "\n"
"When is called without any switches adds contents of the specified\n" "When is called without any switches adds contents of the specified\n"
"registry file to the registry\n" "registry file to the registry\n"
"\n" "\n"
"Switches:\n" "Switches:\n"
" /E - exports contents of the specified registry key to the specified\n" " /E - exports contents of the specified registry key to the specified\n"
" file. Exports the whole registry if no key is specified.\n" " file. Exports the whole registry if no key is specified.\n"
" /D - deletes specified registry key\n" " /D - deletes specified registry key\n"
" /S - silent execution, can be used with any other switch.\n" " /S - silent execution, can be used with any other switch.\n"
" The only existing mode, exists for compatibility with Windows regedit.\n" " The only existing mode, exists for compatibility with Windows regedit.\n"
" /V - advanced mode, can be used with any other switch.\n" " /V - advanced mode, can be used with any other switch.\n"
" Ignored, exists for compatibility with Windows regedit.\n" " Ignored, exists for compatibility with Windows regedit.\n"
" /L - location of system.dat file. Can be used with any other switch.\n" " /L - location of system.dat file. Can be used with any other switch.\n"
" Ignored. Exists for compatibility with Windows regedit.\n" " Ignored. Exists for compatibility with Windows regedit.\n"
" /R - location of user.dat file. Can be used with any other switch.\n" " /R - location of user.dat file. Can be used with any other switch.\n"
" Ignored. Exists for compatibility with Windows regedit.\n" " Ignored. Exists for compatibility with Windows regedit.\n"
" /? - print this help. Any other switches are ignored.\n" " /? - print this help. Any other switches are ignored.\n"
" /C - create registry from. Not implemented.\n" " /C - create registry from. Not implemented.\n"
"\n" "\n"
"The switches are case-insensitive, can be prefixed either by '-' or '/'.\n" "The switches are case-insensitive, can be prefixed either by '-' or '/'.\n"
"This program is command-line compatible with Microsoft Windows\n" "This program is command-line compatible with Microsoft Windows\n"
"regedit. The difference with Windows regedit - this application has\n" "regedit. The difference with Windows regedit - this application has\n"
"command-line interface only.\n"; "command-line interface only.\n";
typedef enum { typedef enum {
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
...@@ -70,8 +70,7 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s); ...@@ -70,8 +70,7 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s);
*/ */
void error_unknown_switch(char chu, char *s) void error_unknown_switch(char chu, char *s)
{ {
if (isalpha(chu)) if (isalpha(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' "
...@@ -87,8 +86,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) ...@@ -87,8 +86,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
CHAR ch = *s; /* current character */ CHAR ch = *s; /* current character */
setAppName("regedit"); setAppName("regedit");
while (ch && ((ch == '-') || (ch == '/'))) while (ch && ((ch == '-') || (ch == '/'))) {
{
char chu; char chu;
char ch2; char ch2;
...@@ -96,14 +94,11 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) ...@@ -96,14 +94,11 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
ch = *s; ch = *s;
ch2 = *(s+1); ch2 = *(s+1);
chu = toupper(ch); chu = toupper(ch);
if (!ch2 || isspace(ch2)) if (!ch2 || isspace(ch2)) {
{ if (chu == 'S' || chu == 'V') {
if (chu == 'S' || chu == 'V')
{
/* ignore these switches */ /* ignore these switches */
} else { } else {
switch (chu) switch (chu) {
{
case 'D': case 'D':
action = ACTION_DELETE; action = ACTION_DELETE;
break; break;
...@@ -121,16 +116,13 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) ...@@ -121,16 +116,13 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
} }
s++; s++;
} else { } else {
if (ch2 == ':') if (ch2 == ':') {
{ switch (chu) {
switch (chu)
{
case 'L': case 'L':
/* fall through */ /* fall through */
case 'R': case 'R':
s += 2; s += 2;
while (*s && !isspace(*s)) while (*s && !isspace(*s)) {
{
s++; s++;
} }
break; break;
...@@ -146,8 +138,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) ...@@ -146,8 +138,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
} }
/* skip spaces to the next parameter */ /* skip spaces to the next parameter */
ch = *s; ch = *s;
while (ch && isspace(ch)) while (ch && isspace(ch)) {
{
s++; s++;
ch = *s; ch = *s;
} }
...@@ -164,75 +155,65 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) ...@@ -164,75 +155,65 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s) BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
{ {
switch (action) switch (action) {
{ case ACTION_ADD: {
case ACTION_ADD: CHAR filename[MAX_PATH];
{ FILE *reg_file;
CHAR filename[MAX_PATH];
FILE *reg_file;
get_file_name(&s, filename);
if (!filename[0])
{
fprintf(stderr,"%s: No file name is specified\n", getAppName());
fprintf(stderr,usage);
exit(1);
}
while(filename[0]) get_file_name(&s, filename);
{ if (!filename[0]) {
reg_file = fopen(filename, "r"); fprintf(stderr,"%s: No file name is specified\n", getAppName());
if (reg_file) fprintf(stderr,usage);
{
processRegLines(reg_file, doSetValue);
} else {
perror("");
fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), filename);
exit(1); exit(1);
} }
get_file_name(&s, filename);
}
break;
}
case ACTION_DELETE:
{
CHAR 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(1);
}
delete_registry_key(reg_key_name);
break;
}
case ACTION_EXPORT:
{
CHAR filename[MAX_PATH];
filename[0] = '\0';
get_file_name(&s, filename);
if (!filename[0])
{
fprintf(stderr,"%s: No file name is specified\n", getAppName());
fprintf(stderr,usage);
exit(1);
}
if (s[0]) while(filename[0]) {
{ reg_file = fopen(filename, "r");
if (reg_file) {
processRegLines(reg_file, doSetValue);
} else {
perror("");
fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), filename);
exit(1);
}
get_file_name(&s, filename);
}
break;
}
case ACTION_DELETE: {
CHAR reg_key_name[KEY_MAX_LEN]; CHAR 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); if (!reg_key_name[0]) {
} else { fprintf(stderr,"%s: No registry key is specified for removal\n",
export_registry_key(filename, NULL); getAppName());
fprintf(stderr,usage);
exit(1);
}
delete_registry_key(reg_key_name);
break;
}
case ACTION_EXPORT: {
CHAR filename[MAX_PATH];
filename[0] = '\0';
get_file_name(&s, filename);
if (!filename[0]) {
fprintf(stderr,"%s: No file name is specified\n", getAppName());
fprintf(stderr,usage);
exit(1);
}
if (s[0]) {
CHAR reg_key_name[KEY_MAX_LEN];
get_file_name(&s, reg_key_name);
export_registry_key(filename, reg_key_name);
} else {
export_registry_key(filename, NULL);
}
break;
} }
break;
}
default: default:
fprintf(stderr,"%s: Unhandled action!\n", getAppName()); fprintf(stderr,"%s: Unhandled action!\n", getAppName());
exit(1); exit(1);
......
...@@ -46,16 +46,16 @@ static BOOL bTheKeyIsOpen = FALSE; ...@@ -46,16 +46,16 @@ static BOOL bTheKeyIsOpen = FALSE;
static CHAR *app_name = "UNKNOWN"; static CHAR *app_name = "UNKNOWN";
static CHAR *reg_class_names[] = { static 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_CURRENT_CONFIG", "HKEY_CURRENT_USER"
}; };
#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]))
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_CURRENT_CONFIG, HKEY_CURRENT_USER
}; };
/* return values */ /* return values */
#define NOT_ENOUGH_MEMORY 1 #define NOT_ENOUGH_MEMORY 1
...@@ -65,12 +65,12 @@ static HKEY reg_class_keys[REG_CLASS_NUMBER] = { ...@@ -65,12 +65,12 @@ static HKEY reg_class_keys[REG_CLASS_NUMBER] = {
/* common check of memory allocation results */ /* common check of memory allocation results */
#define CHECK_ENOUGH_MEMORY(p) \ #define CHECK_ENOUGH_MEMORY(p) \
if (!(p)) \ if (!(p)) \
{ \ { \
fprintf(stderr,"%s: file %s, line %d: Not enough memory", \ fprintf(stderr,"%s: file %s, line %d: Not enough memory", \
getAppName(), __FILE__, __LINE__); \ getAppName(), __FILE__, __LINE__); \
exit(NOT_ENOUGH_MEMORY); \ exit(NOT_ENOUGH_MEMORY); \
} }
/****************************************************************************** /******************************************************************************
* This is a replacement for strsep which is not portable (missing on Solaris). * This is a replacement for strsep which is not portable (missing on Solaris).
...@@ -118,19 +118,15 @@ void get_file_name(CHAR **command_line, CHAR *file_name) ...@@ -118,19 +118,15 @@ void get_file_name(CHAR **command_line, CHAR *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] == '"') if (s[0] == '"') {
{
s++; s++;
(*command_line)++; (*command_line)++;
while(s[0] != '"') while(s[0] != '"') {
{ if (!s[0]) {
if (!s[0])
{
fprintf(stderr,"%s: Unexpected end of file name!\n", fprintf(stderr,"%s: Unexpected end of file name!\n",
getAppName()); getAppName());
exit(1); exit(1);
...@@ -139,28 +135,24 @@ void get_file_name(CHAR **command_line, CHAR *file_name) ...@@ -139,28 +135,24 @@ void get_file_name(CHAR **command_line, CHAR *file_name)
pos++; pos++;
} }
} else { } else {
while(s[0] && !isspace(s[0])) while(s[0] && !isspace(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] == '\\') if (file_name[pos - 1] == '\\') {
{
file_name[pos - 1] = '\0'; file_name[pos - 1] = '\0';
} else { } else {
file_name[pos] = '\0'; file_name[pos] = '\0';
} }
if (s[0]) if (s[0]) {
{
s++; s++;
pos++; pos++;
} }
while(s[0] && isspace(s[0])) while(s[0] && isspace(s[0])) {
{
s++; s++;
pos++; pos++;
} }
...@@ -173,14 +165,14 @@ void get_file_name(CHAR **command_line, CHAR *file_name) ...@@ -173,14 +165,14 @@ void get_file_name(CHAR **command_line, CHAR *file_name)
*/ */
DWORD convertHexToDWord(char *str, BYTE *buf) DWORD convertHexToDWord(char *str, BYTE *buf)
{ {
DWORD dw; DWORD dw;
char xbuf[9]; char xbuf[9];
memcpy(xbuf,str,8); memcpy(xbuf,str,8);
xbuf[8]='\0'; xbuf[8]='\0';
sscanf(xbuf,"%08lx",&dw); sscanf(xbuf,"%08lx",&dw);
memcpy(buf,&dw,sizeof(DWORD)); memcpy(buf,&dw,sizeof(DWORD));
return sizeof(DWORD); return sizeof(DWORD);
} }
/****************************************************************************** /******************************************************************************
...@@ -188,30 +180,29 @@ DWORD convertHexToDWord(char *str, BYTE *buf) ...@@ -188,30 +180,29 @@ DWORD convertHexToDWord(char *str, BYTE *buf)
*/ */
char* convertHexToHexCSV(BYTE *buf, ULONG bufLen) char* convertHexToHexCSV(BYTE *buf, ULONG bufLen)
{ {
char* str; char* str;
char* ptrStr; char* ptrStr;
BYTE* ptrBuf; BYTE* ptrBuf;
ULONG current = 0; ULONG current = 0;
str = HeapAlloc(GetProcessHeap(), 0, (bufLen+1)*2); str = HeapAlloc(GetProcessHeap(), 0, (bufLen+1)*2);
memset(str, 0, (bufLen+1)*2); memset(str, 0, (bufLen+1)*2);
ptrStr = str; /* Pointer to result */ ptrStr = str; /* Pointer to result */
ptrBuf = buf; /* Pointer to current */ ptrBuf = buf; /* Pointer to current */
while (current < bufLen) while (current < bufLen) {
{ BYTE bCur = ptrBuf[current++];
BYTE bCur = ptrBuf[current++]; char res[3];
char res[3];
sprintf(res, "%02x", (unsigned int)*&bCur);
sprintf(res, "%02x", (unsigned int)*&bCur); strcat(str, res);
strcat(str, res); strcat(str, ",");
strcat(str, ","); }
}
/* Get rid of the last comma */
/* Get rid of the last comma */ str[strlen(str)-1] = '\0';
str[strlen(str)-1] = '\0'; return str;
return str;
} }
/****************************************************************************** /******************************************************************************
...@@ -219,18 +210,18 @@ char* convertHexToHexCSV(BYTE *buf, ULONG bufLen) ...@@ -219,18 +210,18 @@ char* convertHexToHexCSV(BYTE *buf, ULONG bufLen)
*/ */
char* convertHexToDWORDStr(BYTE *buf, ULONG bufLen) char* convertHexToDWORDStr(BYTE *buf, ULONG bufLen)
{ {
char* str; char* str;
DWORD dw; DWORD dw;
if ( bufLen != sizeof(DWORD) ) return NULL; if ( bufLen != sizeof(DWORD) ) return NULL;
str = HeapAlloc(GetProcessHeap(), 0, (bufLen*2)+1); str = HeapAlloc(GetProcessHeap(), 0, (bufLen*2)+1);
memcpy(&dw,buf,sizeof(DWORD)); memcpy(&dw,buf,sizeof(DWORD));
sprintf(str, "%08lx", dw); sprintf(str, "%08lx", dw);
/* Get rid of the last comma */ /* Get rid of the last comma */
return str; return str;
} }
/****************************************************************************** /******************************************************************************
...@@ -239,42 +230,41 @@ char* convertHexToDWORDStr(BYTE *buf, ULONG bufLen) ...@@ -239,42 +230,41 @@ char* convertHexToDWORDStr(BYTE *buf, ULONG bufLen)
*/ */
DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen) DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen)
{ {
char *s = str; /* Pointer to current */ char *s = str; /* Pointer to current */
char *b = buf; /* Pointer to result */ char *b = buf; /* Pointer to result */
ULONG strLen = strlen(str); ULONG strLen = strlen(str);
ULONG strPos = 0; ULONG strPos = 0;
DWORD byteCount = 0; DWORD byteCount = 0;
memset(buf, 0, bufLen); memset(buf, 0, bufLen);
/* /*
* warn the user if we are here with a string longer than 2 bytes that does * warn the user if we are here with a string longer than 2 bytes that does
* not contains ",". It is more likely because the data is invalid. * not contains ",". It is more likely because the data is invalid.
*/ */
if ( ( strLen > 2) && ( strchr(str, ',') == NULL) ) if ( ( strLen > 2) && ( strchr(str, ',') == NULL) )
fprintf(stderr,"%s: WARNING converting CSV hex stream with no comma, " fprintf(stderr,"%s: WARNING converting CSV hex stream with no comma, "
"input data seems invalid.\n", getAppName()); "input data seems invalid.\n", getAppName());
if (strLen > 3*bufLen) if (strLen > 3*bufLen)
fprintf(stderr,"%s: ERROR converting CSV hex stream. Too long\n", fprintf(stderr,"%s: ERROR converting CSV hex stream. Too long\n",
getAppName()); getAppName());
while (strPos < strLen) while (strPos < strLen) {
{ char xbuf[3];
char xbuf[3]; UINT wc;
UINT wc;
memcpy(xbuf,s,2); xbuf[2]='\0';
memcpy(xbuf,s,2); xbuf[2]='\0'; sscanf(xbuf,"%02x",&wc);
sscanf(xbuf,"%02x",&wc); if (byteCount < bufLen)
if (byteCount < bufLen) *b++ =(unsigned char)wc;
*b++ =(unsigned char)wc;
s+=3;
s+=3; strPos+=3;
strPos+=3; byteCount++;
byteCount++; }
}
return byteCount;
return byteCount;
} }
/****************************************************************************** /******************************************************************************
...@@ -288,22 +278,20 @@ DWORD getDataType(LPSTR *lpValue, DWORD* parse_type) ...@@ -288,22 +278,20 @@ DWORD getDataType(LPSTR *lpValue, DWORD* parse_type)
{ {
struct data_type { const char *tag; int len; int type; int parse_type; }; struct data_type { const char *tag; int len; int type; int parse_type; };
static const struct data_type data_types[] = static const struct data_type data_types[] = { /* actual type */ /* type to assume for parsing */
{ /* actual type */ /* type to assume for parsing */ { "\"", 1, REG_SZ, REG_SZ },
{ "\"", 1, REG_SZ, REG_SZ }, { "str:\"", 5, REG_SZ, REG_SZ },
{ "str:\"", 5, REG_SZ, REG_SZ }, { "str(2):\"", 8, REG_EXPAND_SZ, REG_SZ },
{ "str(2):\"", 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 }, { "hex(", 4, -1, REG_BINARY },
{ "hex(", 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 (memcmp( ptr->tag, *lpValue, ptr->len )) if (memcmp( ptr->tag, *lpValue, ptr->len ))
continue; continue;
...@@ -332,24 +320,24 @@ DWORD getDataType(LPSTR *lpValue, DWORD* parse_type) ...@@ -332,24 +320,24 @@ DWORD getDataType(LPSTR *lpValue, DWORD* parse_type)
*/ */
LPSTR getArg( LPSTR arg) LPSTR getArg( LPSTR arg)
{ {
LPSTR tmp = NULL; LPSTR tmp = NULL;
ULONG len; ULONG len;
if (arg == NULL) if (arg == NULL)
return NULL; return NULL;
/* /*
* Get rid of surrounding quotes * Get rid of surrounding quotes
*/ */
len = strlen(arg); len = strlen(arg);
if( arg[len-1] == '\"' ) arg[len-1] = '\0'; if( arg[len-1] == '\"' ) arg[len-1] = '\0';
if( arg[0] == '\"' ) arg++; if( arg[0] == '\"' ) arg++;
tmp = HeapAlloc(GetProcessHeap(), 0, strlen(arg)+1); tmp = HeapAlloc(GetProcessHeap(), 0, strlen(arg)+1);
strcpy(tmp, arg); strcpy(tmp, arg);
return tmp; return tmp;
} }
/****************************************************************************** /******************************************************************************
...@@ -360,13 +348,10 @@ void REGPROC_unescape_string(LPSTR str) ...@@ -360,13 +348,10 @@ void REGPROC_unescape_string(LPSTR 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 = strlen(str); int len = strlen(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;
...@@ -397,64 +382,59 @@ void REGPROC_unescape_string(LPSTR str) ...@@ -397,64 +382,59 @@ void REGPROC_unescape_string(LPSTR str)
*/ */
HRESULT setValue(LPSTR val_name, LPSTR val_data) HRESULT setValue(LPSTR val_name, LPSTR val_data)
{ {
HRESULT hRes; HRESULT hRes;
DWORD dwDataType, dwParseType; DWORD dwDataType, dwParseType;
LPBYTE lpbData; LPBYTE lpbData;
BYTE convert[KEY_MAX_LEN]; BYTE convert[KEY_MAX_LEN];
BYTE *bBigBuffer = 0; BYTE *bBigBuffer = 0;
DWORD dwLen; DWORD dwLen;
if ( (val_name == NULL) || (val_data == NULL) ) if ( (val_name == NULL) || (val_data == NULL) )
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
/* Get the data type stored into the value field */ /* Get the data type stored into the value field */
dwDataType = getDataType(&val_data, &dwParseType); dwDataType = getDataType(&val_data, &dwParseType);
if ( dwParseType == REG_SZ) /* no conversion for string */ if ( dwParseType == REG_SZ) /* no conversion for string */
{
dwLen = strlen(val_data);
if (dwLen>0 && val_data[dwLen-1]=='"')
{ {
dwLen--; dwLen = strlen(val_data);
val_data[dwLen]='\0'; if (dwLen>0 && val_data[dwLen-1]=='"')
} {
dwLen++; dwLen--;
REGPROC_unescape_string(val_data); val_data[dwLen]='\0';
lpbData = val_data; }
} dwLen++;
else if (dwParseType == REG_DWORD) /* Convert the dword types */ REGPROC_unescape_string(val_data);
{ lpbData = val_data;
dwLen = convertHexToDWord(val_data, convert); } else if (dwParseType == REG_DWORD) /* Convert the dword types */
lpbData = convert;
}
else /* Convert the hexadecimal types */
{
int b_len = strlen (val_data)+2/3;
if (b_len > KEY_MAX_LEN)
{ {
bBigBuffer = HeapAlloc (GetProcessHeap(), 0, b_len); dwLen = convertHexToDWord(val_data, convert);
CHECK_ENOUGH_MEMORY(bBigBuffer); lpbData = convert;
dwLen = convertHexCSVToHex(val_data, bBigBuffer, b_len); } else /* Convert the hexadecimal types */
lpbData = bBigBuffer;
}
else
{ {
dwLen = convertHexCSVToHex(val_data, convert, KEY_MAX_LEN); int b_len = strlen (val_data)+2/3;
lpbData = convert; if (b_len > KEY_MAX_LEN) {
bBigBuffer = HeapAlloc (GetProcessHeap(), 0, b_len);
CHECK_ENOUGH_MEMORY(bBigBuffer);
dwLen = convertHexCSVToHex(val_data, bBigBuffer, b_len);
lpbData = bBigBuffer;
} else {
dwLen = convertHexCSVToHex(val_data, convert, KEY_MAX_LEN);
lpbData = convert;
}
} }
}
hRes = RegSetValueEx(
hRes = RegSetValueEx( currentKeyHandle,
currentKeyHandle, val_name,
val_name, 0, /* Reserved */
0, /* Reserved */ dwDataType,
dwDataType, lpbData,
lpbData, dwLen);
dwLen);
if (bBigBuffer)
if (bBigBuffer) HeapFree (GetProcessHeap(), 0, bBigBuffer);
HeapFree (GetProcessHeap(), 0, bBigBuffer); return hRes;
return hRes;
} }
...@@ -463,39 +443,39 @@ HRESULT setValue(LPSTR val_name, LPSTR val_data) ...@@ -463,39 +443,39 @@ HRESULT setValue(LPSTR val_name, LPSTR val_data)
*/ */
HRESULT openKey( LPSTR stdInput) HRESULT openKey( LPSTR stdInput)
{ {
DWORD dwDisp; DWORD dwDisp;
HRESULT hRes; HRESULT hRes;
/* Sanity checks */ /* Sanity checks */
if (stdInput == NULL) if (stdInput == NULL)
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
/* Get the registry class */ /* Get the registry class */
currentKeyClass = getRegClass(stdInput); /* Sets global variable */ currentKeyClass = getRegClass(stdInput); /* Sets global variable */
if (currentKeyClass == (HKEY)ERROR_INVALID_PARAMETER) if (currentKeyClass == (HKEY)ERROR_INVALID_PARAMETER)
return (HRESULT)ERROR_INVALID_PARAMETER; return (HRESULT)ERROR_INVALID_PARAMETER;
/* Get the key name */ /* Get the key name */
currentKeyName = getRegKeyName(stdInput); /* Sets global variable */ currentKeyName = getRegKeyName(stdInput); /* Sets global variable */
if (currentKeyName == NULL) if (currentKeyName == NULL)
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
hRes = RegCreateKeyEx( hRes = RegCreateKeyEx(
currentKeyClass, /* Class */ currentKeyClass, /* Class */
currentKeyName, /* Sub Key */ currentKeyName, /* 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 */
&currentKeyHandle, /* result */ &currentKeyHandle, /* result */
&dwDisp); /* disposition, REG_CREATED_NEW_KEY or &dwDisp); /* disposition, REG_CREATED_NEW_KEY or
REG_OPENED_EXISTING_KEY */ REG_OPENED_EXISTING_KEY */
if (hRes == ERROR_SUCCESS) if (hRes == ERROR_SUCCESS)
bTheKeyIsOpen = TRUE; bTheKeyIsOpen = TRUE;
return hRes; return hRes;
} }
...@@ -505,32 +485,30 @@ HRESULT openKey( LPSTR stdInput) ...@@ -505,32 +485,30 @@ HRESULT openKey( LPSTR stdInput)
*/ */
LPSTR getRegKeyName(LPSTR lpLine) LPSTR getRegKeyName(LPSTR lpLine)
{ {
LPSTR keyNameBeg; LPSTR keyNameBeg;
char lpLineCopy[KEY_MAX_LEN]; char lpLineCopy[KEY_MAX_LEN];
if (lpLine == NULL) if (lpLine == NULL)
return NULL; return NULL;
strcpy(lpLineCopy, lpLine); strcpy(lpLineCopy, lpLine);
keyNameBeg = strchr(lpLineCopy, '\\'); /* The key name start by '\' */ keyNameBeg = strchr(lpLineCopy, '\\'); /* The key name start by '\' */
if (keyNameBeg) if (keyNameBeg) {
{ LPSTR keyNameEnd;
LPSTR keyNameEnd;
keyNameBeg++; /* is not part of the name */
keyNameBeg++; /* is not part of the name */ keyNameEnd = strchr(lpLineCopy, ']');
keyNameEnd = strchr(lpLineCopy, ']'); if (keyNameEnd) {
if (keyNameEnd) *keyNameEnd = '\0'; /* remove ']' from the key name */
{ }
*keyNameEnd = '\0'; /* remove ']' from the key name */ } else {
} keyNameBeg = lpLineCopy + strlen(lpLineCopy); /* branch - empty string */
} else { }
keyNameBeg = lpLineCopy + strlen(lpLineCopy); /* branch - empty string */ currentKeyName = HeapAlloc(GetProcessHeap(), 0, strlen(keyNameBeg) + 1);
} CHECK_ENOUGH_MEMORY(currentKeyName);
currentKeyName = HeapAlloc(GetProcessHeap(), 0, strlen(keyNameBeg) + 1); strcpy(currentKeyName, keyNameBeg);
CHECK_ENOUGH_MEMORY(currentKeyName); return currentKeyName;
strcpy(currentKeyName, keyNameBeg);
return currentKeyName;
} }
/****************************************************************************** /******************************************************************************
...@@ -539,42 +517,39 @@ LPSTR getRegKeyName(LPSTR lpLine) ...@@ -539,42 +517,39 @@ LPSTR getRegKeyName(LPSTR lpLine)
*/ */
HKEY getRegClass(LPSTR lpClass) HKEY getRegClass(LPSTR lpClass)
{ {
LPSTR classNameEnd; LPSTR classNameEnd;
LPSTR classNameBeg; LPSTR classNameBeg;
int i; int i;
char lpClassCopy[KEY_MAX_LEN]; char lpClassCopy[KEY_MAX_LEN];
if (lpClass == NULL) if (lpClass == NULL)
return (HKEY)ERROR_INVALID_PARAMETER; return (HKEY)ERROR_INVALID_PARAMETER;
strncpy(lpClassCopy, lpClass, KEY_MAX_LEN);
classNameEnd = strchr(lpClassCopy, '\\'); /* The class name ends by '\' */
if (!classNameEnd) /* or the whole string */
{
classNameEnd = lpClassCopy + strlen(lpClassCopy);
if (classNameEnd[-1] == ']')
{
classNameEnd--;
}
}
*classNameEnd = '\0'; /* Isolate the class name */
if (lpClassCopy[0] == '[') {
classNameBeg = lpClassCopy + 1;
} else {
classNameBeg = lpClassCopy;
}
strncpy(lpClassCopy, lpClass, KEY_MAX_LEN); for (i = 0; i < REG_CLASS_NUMBER; i++) {
if (!strcmp(classNameBeg, reg_class_names[i])) {
classNameEnd = strchr(lpClassCopy, '\\'); /* The class name ends by '\' */ return reg_class_keys[i];
if (!classNameEnd) /* or the whole string */ }
{ }
classNameEnd = lpClassCopy + strlen(lpClassCopy); return (HKEY)ERROR_INVALID_PARAMETER;
if (classNameEnd[-1] == ']')
{
classNameEnd--;
}
}
*classNameEnd = '\0'; /* Isolate the class name */
if (lpClassCopy[0] == '[')
{
classNameBeg = lpClassCopy + 1;
} else {
classNameBeg = lpClassCopy;
}
for (i = 0; i < REG_CLASS_NUMBER; i++)
{
if (!strcmp(classNameBeg, reg_class_names[i]))
{
return reg_class_keys[i];
}
}
return (HKEY)ERROR_INVALID_PARAMETER;
} }
/****************************************************************************** /******************************************************************************
...@@ -582,15 +557,15 @@ HKEY getRegClass(LPSTR lpClass) ...@@ -582,15 +557,15 @@ HKEY getRegClass(LPSTR lpClass)
*/ */
void closeKey() void closeKey()
{ {
RegCloseKey(currentKeyHandle); RegCloseKey(currentKeyHandle);
HeapFree(GetProcessHeap(), 0, currentKeyName); /* Allocated by getKeyName */ HeapFree(GetProcessHeap(), 0, currentKeyName); /* Allocated by getKeyName */
bTheKeyIsOpen = FALSE; bTheKeyIsOpen = FALSE;
currentKeyName = NULL; currentKeyName = NULL;
currentKeyClass = 0; currentKeyClass = 0;
currentKeyHandle = 0; currentKeyHandle = 0;
} }
/****************************************************************************** /******************************************************************************
...@@ -600,38 +575,35 @@ void closeKey() ...@@ -600,38 +575,35 @@ void closeKey()
*/ */
void doSetValue(LPSTR stdInput) void doSetValue(LPSTR stdInput)
{ {
/* /*
* We encoutered the end of the file, make sure we * We encoutered 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) {
{ if (bTheKeyIsOpen != FALSE)
if (bTheKeyIsOpen != FALSE) closeKey();
closeKey();
return;
return; }
}
if ( stdInput[0] == '[') /* We are reading a new key */
if ( stdInput[0] == '[') /* We are reading a new key */ {
{ if ( bTheKeyIsOpen != FALSE )
if ( bTheKeyIsOpen != FALSE ) closeKey(); /* Close the previous key before */
closeKey(); /* Close the previous key before */
if ( openKey(stdInput) != ERROR_SUCCESS )
if ( openKey(stdInput) != ERROR_SUCCESS ) fprintf(stderr,"%s: setValue failed to open key %s\n",
fprintf(stderr,"%s: setValue failed to open key %s\n", getAppName(), stdInput);
getAppName(), stdInput); } else if( ( bTheKeyIsOpen ) &&
} (( stdInput[0] == '@') || /* reading a default @=data pair */
else if( ( bTheKeyIsOpen ) && ( 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);
{ } else /* since we are assuming that the */
processSetValue(stdInput); { /* file format is valid we must */
} if ( bTheKeyIsOpen ) /* be reading a blank line which */
else /* since we are assuming that the */ closeKey(); /* indicate end of this key processing */
{ /* file format is valid we must */ }
if ( bTheKeyIsOpen ) /* be reading a blank line which */
closeKey(); /* indicate end of this key processing */
}
} }
/****************************************************************************** /******************************************************************************
...@@ -639,39 +611,37 @@ void doSetValue(LPSTR stdInput) ...@@ -639,39 +611,37 @@ void doSetValue(LPSTR stdInput)
* receives the currently read line and dispatch the work depending on the * receives the currently read line and dispatch the work depending on the
* context. * context.
*/ */
void doQueryValue(LPSTR stdInput) { void doQueryValue(LPSTR stdInput)
/* {
* We encoutered the end of the file, make sure we /*
* close the opened key and exit * We encoutered the end of the file, make sure we
*/ * close the opened key and exit
if (stdInput == NULL) */
{ if (stdInput == NULL) {
if (bTheKeyIsOpen != FALSE) if (bTheKeyIsOpen != FALSE)
closeKey(); closeKey();
return; return;
} }
if ( stdInput[0] == '[') /* We are reading a new key */ if ( stdInput[0] == '[') /* We are reading a new key */
{ {
if ( bTheKeyIsOpen != FALSE ) if ( bTheKeyIsOpen != FALSE )
closeKey(); /* Close the previous key before */ closeKey(); /* Close the previous key before */
if ( openKey(stdInput) != ERROR_SUCCESS ) if ( openKey(stdInput) != ERROR_SUCCESS )
fprintf(stderr,"%s: queryValue failed to open key %s\n", fprintf(stderr,"%s: queryValue failed to open key %s\n",
getAppName(), stdInput); getAppName(), stdInput);
} } else if( ( bTheKeyIsOpen ) &&
else if( ( bTheKeyIsOpen ) && (( 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 */ {
{ processQueryValue(stdInput);
processQueryValue(stdInput); } else /* since we are assuming that the */
} { /* file format is valid we must */
else /* since we are assuming that the */ if ( bTheKeyIsOpen ) /* be reading a blank line which */
{ /* file format is valid we must */ closeKey(); /* indicate end of this key processing */
if ( bTheKeyIsOpen ) /* be reading a blank line which */ }
closeKey(); /* indicate end of this key processing */
}
} }
/****************************************************************************** /******************************************************************************
...@@ -679,8 +649,9 @@ void doQueryValue(LPSTR stdInput) { ...@@ -679,8 +649,9 @@ void doQueryValue(LPSTR stdInput) {
* receives the currently read line and dispatch the work depending on the * receives the currently read line and dispatch the work depending on the
* context. * context.
*/ */
void doDeleteValue(LPSTR line) { void doDeleteValue(LPSTR line)
fprintf(stderr,"%s: deleteValue not yet implemented\n", getAppName()); {
fprintf(stderr,"%s: deleteValue not yet implemented\n", getAppName());
} }
/****************************************************************************** /******************************************************************************
...@@ -688,8 +659,9 @@ void doDeleteValue(LPSTR line) { ...@@ -688,8 +659,9 @@ void doDeleteValue(LPSTR line) {
* receives the currently read line and dispatch the work depending on the * receives the currently read line and dispatch the work depending on the
* context. * context.
*/ */
void doDeleteKey(LPSTR line) { void doDeleteKey(LPSTR line)
fprintf(stderr,"%s: deleteKey not yet implemented\n", getAppName()); {
fprintf(stderr,"%s: deleteKey not yet implemented\n", getAppName());
} }
/****************************************************************************** /******************************************************************************
...@@ -697,8 +669,9 @@ void doDeleteKey(LPSTR line) { ...@@ -697,8 +669,9 @@ void doDeleteKey(LPSTR line) {
* receives the currently read line and dispatch the work depending on the * receives the currently read line and dispatch the work depending on the
* context. * context.
*/ */
void doCreateKey(LPSTR line) { void doCreateKey(LPSTR line)
fprintf(stderr,"%s: createKey not yet implemented\n", getAppName()); {
fprintf(stderr,"%s: createKey not yet implemented\n", getAppName());
} }
/****************************************************************************** /******************************************************************************
...@@ -711,63 +684,55 @@ void doCreateKey(LPSTR line) { ...@@ -711,63 +684,55 @@ void doCreateKey(LPSTR line) {
*/ */
void processSetValue(LPSTR line) void processSetValue(LPSTR line)
{ {
LPSTR val_name; /* registry value name */ LPSTR val_name; /* registry value name */
LPSTR val_data; /* registry value data */ LPSTR val_data; /* registry value data */
int line_idx = 0; /* current character under analysis */ int line_idx = 0; /* current character under analysis */
HRESULT hRes = 0; HRESULT hRes = 0;
/* get value name */ /* get value name */
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] == '\"') {
} line_idx++;
else if (line[line_idx] == '\"') val_name = line + line_idx;
{ while (TRUE) {
line_idx++; if (line[line_idx] == '\\') /* skip escaped character */
val_name = line + line_idx; {
while (TRUE) line_idx += 2;
{ } else {
if (line[line_idx] == '\\') /* skip escaped character */ if (line[line_idx] == '\"') {
{ line[line_idx] = '\0';
line_idx += 2; line_idx++;
} else { break;
if (line[line_idx] == '\"') } else {
{ line_idx++;
line[line_idx] = '\0'; }
line_idx++; }
break; }
} else { if (line[line_idx] != '=') {
line_idx++; line[line_idx] = '\"';
} fprintf(stderr,"Warning! unrecognized line:\n%s\n", line);
} return;
} }
if (line[line_idx] != '=')
{ } else {
line[line_idx] = '\"'; fprintf(stderr,"Warning! unrecognized line:\n%s\n", line);
fprintf(stderr,"Warning! unrecognized line:\n%s\n", line); return;
return; }
} line_idx++; /* skip the '=' character */
val_data = line + line_idx;
}
else REGPROC_unescape_string(val_name);
{ hRes = setValue(val_name, val_data);
fprintf(stderr,"Warning! unrecognized line:\n%s\n", line); if ( hRes != ERROR_SUCCESS )
return; fprintf(stderr,"%s: ERROR Key %s not created. Value: %s, Data: %s\n",
} getAppName(),
line_idx++; /* skip the '=' character */ currentKeyName,
val_data = line + line_idx; val_name,
val_data);
REGPROC_unescape_string(val_name);
hRes = setValue(val_name, val_data);
if ( hRes != ERROR_SUCCESS )
fprintf(stderr,"%s: ERROR Key %s not created. Value: %s, Data: %s\n",
getAppName(),
currentKeyName,
val_name,
val_data);
} }
/****************************************************************************** /******************************************************************************
...@@ -776,138 +741,128 @@ void processSetValue(LPSTR line) ...@@ -776,138 +741,128 @@ void processSetValue(LPSTR line)
*/ */
void processQueryValue(LPSTR cmdline) void processQueryValue(LPSTR cmdline)
{ {
fprintf(stderr,"ERROR!!! - temporary disabled"); fprintf(stderr,"ERROR!!! - temporary disabled");
exit(1); exit(1);
#if 0 #if 0
LPSTR argv[QUERY_VALUE_MAX_ARGS];/* args storage */ LPSTR argv[QUERY_VALUE_MAX_ARGS];/* args storage */
LPSTR token = NULL; /* current token analyzed */ LPSTR token = NULL; /* current token analyzed */
ULONG argCounter = 0; /* counter of args */ ULONG argCounter = 0; /* counter of args */
INT counter; INT counter;
HRESULT hRes = 0; HRESULT hRes = 0;
LPSTR keyValue = NULL; LPSTR keyValue = NULL;
LPSTR lpsRes = NULL; LPSTR lpsRes = NULL;
/*
* Init storage and parse the line
*/
for (counter=0; counter<QUERY_VALUE_MAX_ARGS; counter++)
argv[counter]=NULL;
while( (token = getToken(&cmdline, queryValueDelim[argCounter])) != NULL )
{
argv[argCounter++] = getArg(token);
if (argCounter == QUERY_VALUE_MAX_ARGS)
break; /* Stop processing args no matter what */
}
/* The value we look for is the first token on the line */
if ( argv[0] == NULL )
return; /* SHOULD NOT HAPPEN */
else
keyValue = argv[0];
if( (keyValue[0] == '@') && (strlen(keyValue) == 1) )
{
LONG lLen = KEY_MAX_LEN;
CHAR* lpsData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN);
/*
* We need to query the key default value
*/
hRes = RegQueryValue(
currentKeyHandle,
currentKeyName,
(LPBYTE)lpsData,
&lLen);
if (hRes==ERROR_MORE_DATA) {
lpsData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpsData,lLen);
hRes = RegQueryValue(currentKeyHandle,currentKeyName,(LPBYTE)lpsData,&lLen);
}
if (hRes == ERROR_SUCCESS)
{
lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen);
strncpy(lpsRes, lpsData, lLen);
lpsRes[lLen-1]='\0';
}
}
else
{
DWORD dwLen = KEY_MAX_LEN;
BYTE* lpbData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN);
DWORD dwType;
/* /*
* We need to query a specific value for the key * Init storage and parse the line
*/ */
hRes = RegQueryValueEx( for (counter=0; counter<QUERY_VALUE_MAX_ARGS; counter++)
currentKeyHandle, argv[counter]=NULL;
keyValue,
0, while( (token = getToken(&cmdline, queryValueDelim[argCounter])) != NULL ) {
&dwType, argv[argCounter++] = getArg(token);
(LPBYTE)lpbData,
&dwLen); if (argCounter == QUERY_VALUE_MAX_ARGS)
break; /* Stop processing args no matter what */
if (hRes==ERROR_MORE_DATA) {
lpbData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpbData,dwLen);
hRes = RegQueryValueEx(currentKeyHandle,keyValue,NULL,&dwType,(LPBYTE)lpbData,&dwLen);
} }
if (hRes == ERROR_SUCCESS) /* The value we look for is the first token on the line */
{ if ( argv[0] == NULL )
/* return; /* SHOULD NOT HAPPEN */
* Convert the returned data to a displayable format else
*/ keyValue = argv[0];
switch ( dwType )
{ if( (keyValue[0] == '@') && (strlen(keyValue) == 1) ) {
case REG_SZ: LONG lLen = KEY_MAX_LEN;
case REG_EXPAND_SZ: CHAR* lpsData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN);
{ /*
lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen); * We need to query the key default value
strncpy(lpsRes, lpbData, dwLen); */
lpsRes[dwLen-1]='\0'; hRes = RegQueryValue(
break; currentKeyHandle,
currentKeyName,
(LPBYTE)lpsData,
&lLen);
if (hRes==ERROR_MORE_DATA) {
lpsData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpsData,lLen);
hRes = RegQueryValue(currentKeyHandle,currentKeyName,(LPBYTE)lpsData,&lLen);
} }
case REG_DWORD:
{ if (hRes == ERROR_SUCCESS) {
lpsRes = convertHexToDWORDStr(lpbData, dwLen); lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen);
break; strncpy(lpsRes, lpsData, lLen);
lpsRes[lLen-1]='\0';
} }
default: } else {
{ DWORD dwLen = KEY_MAX_LEN;
lpsRes = convertHexToHexCSV(lpbData, dwLen); BYTE* lpbData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN);
break; DWORD dwType;
/*
* We need to query a specific value for the key
*/
hRes = RegQueryValueEx(
currentKeyHandle,
keyValue,
0,
&dwType,
(LPBYTE)lpbData,
&dwLen);
if (hRes==ERROR_MORE_DATA) {
lpbData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpbData,dwLen);
hRes = RegQueryValueEx(currentKeyHandle,keyValue,NULL,&dwType,(LPBYTE)lpbData,&dwLen);
}
if (hRes == ERROR_SUCCESS) {
/*
* Convert the returned data to a displayable format
*/
switch ( dwType ) {
case REG_SZ:
case REG_EXPAND_SZ: {
lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen);
strncpy(lpsRes, lpbData, dwLen);
lpsRes[dwLen-1]='\0';
break;
}
case REG_DWORD: {
lpsRes = convertHexToDWORDStr(lpbData, dwLen);
break;
}
default: {
lpsRes = convertHexToHexCSV(lpbData, dwLen);
break;
}
}
} }
}
HeapFree(GetProcessHeap(), 0, lpbData);
} }
HeapFree(GetProcessHeap(), 0, lpbData);
} if ( hRes == ERROR_SUCCESS )
fprintf(stderr,
"%s: Value \"%s\" = \"%s\" in key [%s]\n",
if ( hRes == ERROR_SUCCESS ) getAppName(),
fprintf(stderr, keyValue,
"%s: Value \"%s\" = \"%s\" in key [%s]\n", lpsRes,
getAppName(), currentKeyName);
keyValue,
lpsRes, else
currentKeyName); fprintf(stderr,"%s: ERROR Value \"%s\" not found for key \"%s\".\n",
getAppName(),
else keyValue,
fprintf(stderr,"%s: ERROR Value \"%s\" not found for key \"%s\".\n", currentKeyName);
getAppName(),
keyValue, /*
currentKeyName); * Do some cleanup
*/
/* for (counter=0; counter<argCounter; counter++)
* Do some cleanup if (argv[counter] != NULL)
*/ HeapFree(GetProcessHeap(), 0, argv[counter]);
for (counter=0; counter<argCounter; counter++)
if (argv[counter] != NULL) if (lpsRes != NULL)
HeapFree(GetProcessHeap(), 0, argv[counter]); HeapFree(GetProcessHeap(), 0, lpsRes);
if (lpsRes != NULL)
HeapFree(GetProcessHeap(), 0, lpsRes);
#endif #endif
} }
...@@ -927,12 +882,10 @@ void processRegLines(FILE *in, CommandAPI command) ...@@ -927,12 +882,10 @@ void processRegLines(FILE *in, CommandAPI command)
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 */
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 */
...@@ -959,15 +912,11 @@ void processRegLines(FILE *in, CommandAPI command) ...@@ -959,15 +912,11 @@ void processRegLines(FILE *in, CommandAPI command)
* eof, error, eol or getting the maximum amount. Abort on error. * eof, error, eol or getting the maximum amount. Abort on error.
*/ */
size_to_get = (size_remaining > INT_MAX ? INT_MAX : size_remaining); size_to_get = (size_remaining > INT_MAX ? INT_MAX : size_remaining);
if (NULL == fgets (s, size_to_get, in)) if (NULL == fgets (s, size_to_get, in)) {
{ 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
...@@ -979,40 +928,35 @@ void processRegLines(FILE *in, CommandAPI command) ...@@ -979,40 +928,35 @@ void processRegLines(FILE *in, CommandAPI command)
/* 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;
/* The following error protection could be made more self- /* The following error protection could be made more self-
* correcting but I thought it not worth trying. * correcting but I thought it not worth trying.
*/ */
if ((c = fgetc (in)) == EOF || c != ' ' || if ((c = fgetc (in)) == EOF || c != ' ' ||
(c = fgetc (in)) == EOF || c != ' ') (c = fgetc (in)) == EOF || c != ' ')
fprintf(stderr,"%s: ERROR - invalid continuation.\n", fprintf(stderr,"%s: ERROR - invalid continuation.\n",
getAppName()); getAppName());
continue; continue;
...@@ -1032,70 +976,66 @@ void processRegLines(FILE *in, CommandAPI command) ...@@ -1032,70 +976,66 @@ void processRegLines(FILE *in, CommandAPI command)
* This funtion is the main entry point to the registerDLL action. It * This funtion is the main entry point to the registerDLL action. It
* receives the currently read line, then loads and registers the requested DLLs * receives the currently read line, then loads and registers the requested DLLs
*/ */
void doRegisterDLL(LPSTR stdInput) { void doRegisterDLL(LPSTR stdInput)
HMODULE theLib = 0; {
UINT retVal = 0; HMODULE theLib = 0;
UINT retVal = 0;
/* Check for valid input */
if (stdInput == NULL) /* Check for valid input */
return; if (stdInput == NULL)
return;
/* Load and register the library, then free it */
theLib = LoadLibrary(stdInput); /* Load and register the library, then free it */
if (theLib) theLib = LoadLibrary(stdInput);
{ if (theLib) {
FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllRegisterServer"); FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllRegisterServer");
if (lpfnDLLRegProc) if (lpfnDLLRegProc)
retVal = (*lpfnDLLRegProc)(); retVal = (*lpfnDLLRegProc)();
else else
fprintf(stderr,"%s: Couldn't find DllRegisterServer proc in '%s'.\n", fprintf(stderr,"%s: Couldn't find DllRegisterServer proc in '%s'.\n",
getAppName(), stdInput); getAppName(), stdInput);
if (retVal != S_OK) if (retVal != S_OK)
fprintf(stderr,"%s: DLLRegisterServer error 0x%x in '%s'.\n", fprintf(stderr,"%s: DLLRegisterServer error 0x%x in '%s'.\n",
getAppName(), retVal, stdInput); getAppName(), retVal, stdInput);
FreeLibrary(theLib); FreeLibrary(theLib);
} } else {
else fprintf(stderr,"%s: Could not load DLL '%s'.\n", getAppName(), stdInput);
{ }
fprintf(stderr,"%s: Could not load DLL '%s'.\n", getAppName(), stdInput);
}
} }
/****************************************************************************** /******************************************************************************
* This funtion is the main entry point to the unregisterDLL action. It * This funtion is the main entry point to the unregisterDLL action. It
* receives the currently read line, then loads and unregisters the requested DLLs * receives the currently read line, then loads and unregisters the requested DLLs
*/ */
void doUnregisterDLL(LPSTR stdInput) { void doUnregisterDLL(LPSTR stdInput)
HMODULE theLib = 0; {
UINT retVal = 0; HMODULE theLib = 0;
UINT retVal = 0;
/* Check for valid input */
if (stdInput == NULL) /* Check for valid input */
return; if (stdInput == NULL)
return;
/* Load and unregister the library, then free it */
theLib = LoadLibrary(stdInput); /* Load and unregister the library, then free it */
if (theLib) theLib = LoadLibrary(stdInput);
{ if (theLib) {
FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllUnregisterServer"); FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllUnregisterServer");
if (lpfnDLLRegProc) if (lpfnDLLRegProc)
retVal = (*lpfnDLLRegProc)(); retVal = (*lpfnDLLRegProc)();
else else
fprintf(stderr,"%s: Couldn't find DllUnregisterServer proc in '%s'.\n", fprintf(stderr,"%s: Couldn't find DllUnregisterServer proc in '%s'.\n",
getAppName(), stdInput); getAppName(), stdInput);
if (retVal != S_OK) if (retVal != S_OK)
fprintf(stderr,"%s: DLLUnregisterServer error 0x%x in '%s'.\n", fprintf(stderr,"%s: DLLUnregisterServer error 0x%x in '%s'.\n",
getAppName(), retVal, stdInput); getAppName(), retVal, stdInput);
FreeLibrary(theLib); FreeLibrary(theLib);
} } else {
else fprintf(stderr,"%s: Could not load DLL '%s'.\n", getAppName(), stdInput);
{ }
fprintf(stderr,"%s: Could not load DLL '%s'.\n", getAppName(), stdInput);
}
} }
/**************************************************************************** /****************************************************************************
...@@ -1104,7 +1044,8 @@ void doUnregisterDLL(LPSTR stdInput) { ...@@ -1104,7 +1044,8 @@ void doUnregisterDLL(LPSTR stdInput) {
* Print the message for GetLastError * Print the message for GetLastError
*/ */
void REGPROC_print_error() { void REGPROC_print_error()
{
LPVOID lpMsgBuf; LPVOID lpMsgBuf;
DWORD error_code; DWORD error_code;
int status; int status;
...@@ -1135,12 +1076,11 @@ void REGPROC_print_error() { ...@@ -1135,12 +1076,11 @@ void REGPROC_print_error() {
void REGPROC_resize_char_buffer(CHAR **buffer, DWORD *len, DWORD required_len) void REGPROC_resize_char_buffer(CHAR **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));
else else
*buffer = HeapReAlloc(GetProcessHeap(), 0, *buffer, *len * sizeof(**buffer)); *buffer = HeapReAlloc(GetProcessHeap(), 0, *buffer, *len * sizeof(**buffer));
CHECK_ENOUGH_MEMORY(*buffer); CHECK_ENOUGH_MEMORY(*buffer);
} }
...@@ -1155,11 +1095,9 @@ void REGPROC_export_string(FILE *file, CHAR *str) ...@@ -1155,11 +1095,9 @@ void REGPROC_export_string(FILE *file, CHAR *str)
size_t i; size_t i;
/* escaping characters */ /* escaping characters */
for (i = 0; i < len; i++) for (i = 0; i < len; i++) {
{
CHAR c = str[i]; CHAR c = str[i];
switch (c) switch (c) {
{
case '\\': case '\\':
fputs("\\\\", file); fputs("\\\\", file);
break; break;
...@@ -1209,8 +1147,7 @@ void export_hkey(FILE *file, HKEY key, ...@@ -1209,8 +1147,7 @@ void export_hkey(FILE *file, HKEY key,
if (RegQueryInfoKey(key, NULL, NULL, NULL, NULL, if (RegQueryInfoKey(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 = strlen(*reg_key_name_buf); curr_len = strlen(*reg_key_name_buf);
...@@ -1218,10 +1155,9 @@ void export_hkey(FILE *file, HKEY key, ...@@ -1218,10 +1155,9 @@ void export_hkey(FILE *file, HKEY key,
max_sub_key_len + curr_len + 1); max_sub_key_len + curr_len + 1);
REGPROC_resize_char_buffer(val_name_buf, val_name_len, REGPROC_resize_char_buffer(val_name_buf, val_name_len,
max_val_name_len); max_val_name_len);
if (max_val_size > *val_size) if (max_val_size > *val_size) {
{
*val_size = max_val_size; *val_size = max_val_size;
if (!*val_buf) *val_buf = HeapAlloc(GetProcessHeap(), 0, *val_size); if (!*val_buf) *val_buf = HeapAlloc(GetProcessHeap(), 0, *val_size);
else *val_buf = HeapReAlloc(GetProcessHeap(), 0, *val_buf, *val_size); else *val_buf = HeapReAlloc(GetProcessHeap(), 0, *val_buf, *val_size);
CHECK_ENOUGH_MEMORY(val_buf); CHECK_ENOUGH_MEMORY(val_buf);
} }
...@@ -1233,25 +1169,21 @@ void export_hkey(FILE *file, HKEY key, ...@@ -1233,25 +1169,21 @@ 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_len1 = *val_name_len; DWORD val_name_len1 = *val_name_len;
DWORD val_size1 = *val_size; DWORD val_size1 = *val_size;
ret = RegEnumValue(key, i, *val_name_buf, &val_name_len1, NULL, ret = RegEnumValue(key, i, *val_name_buf, &val_name_len1, NULL,
&value_type, *val_buf, &val_size1); &value_type, *val_buf, &val_size1);
if (ret != ERROR_SUCCESS) 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 {
i++; i++;
if ((*val_name_buf)[0]) if ((*val_name_buf)[0]) {
{
fputs("\"", file); fputs("\"", file);
REGPROC_export_string(file, *val_name_buf); REGPROC_export_string(file, *val_name_buf);
fputs("\"=", file); fputs("\"=", file);
...@@ -1259,8 +1191,7 @@ void export_hkey(FILE *file, HKEY key, ...@@ -1259,8 +1191,7 @@ void export_hkey(FILE *file, HKEY key,
fputs("@=", file); fputs("@=", file);
} }
switch (value_type) switch (value_type) {
{
case REG_SZ: case REG_SZ:
case REG_EXPAND_SZ: case REG_EXPAND_SZ:
fputs("\"", file); fputs("\"", file);
...@@ -1274,53 +1205,48 @@ void export_hkey(FILE *file, HKEY key, ...@@ -1274,53 +1205,48 @@ void export_hkey(FILE *file, HKEY key,
default: default:
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", *reg_key_name_buf); fprintf(stderr,"key name: \"%s\"\n", *reg_key_name_buf);
fprintf(stderr,"value name:\"%s\"\n\n", *val_name_buf); fprintf(stderr,"value name:\"%s\"\n\n", *val_name_buf);
/* falls through */ /* falls through */
case REG_MULTI_SZ: case REG_MULTI_SZ:
/* falls through */ /* falls through */
case REG_BINARY: case REG_BINARY: {
{ DWORD i1;
DWORD i1; CHAR *hex_prefix;
CHAR *hex_prefix; CHAR buf[20];
CHAR buf[20]; int cur_pos;
int cur_pos;
if (value_type == REG_BINARY) {
if (value_type == REG_BINARY) hex_prefix = "hex:";
{ } else {
hex_prefix = "hex:"; hex_prefix = buf;
} else { sprintf(buf, "hex(%ld):", value_type);
hex_prefix = buf;
sprintf(buf, "hex(%ld):", value_type);
}
/* position of where the next character will be printed */
/* NOTE: yes, strlen("hex:") is used even for hex(x): */
cur_pos = strlen("\"\"=") + strlen("hex:") +
strlen(*val_name_buf);
fputs(hex_prefix, file);
for (i1 = 0; i1 < val_size1; i1++)
{
fprintf(file, "%02x", (unsigned int)(*val_buf)[i1]);
if (i1 + 1 < val_size1)
{
fputs(",", file);
} }
cur_pos += 3;
/* wrap the line */ /* position of where the next character will be printed */
if (cur_pos > REG_FILE_HEX_LINE_LEN) /* NOTE: yes, strlen("hex:") is used even for hex(x): */
{ cur_pos = strlen("\"\"=") + strlen("hex:") +
fputs("\\\n ", file); strlen(*val_name_buf);
cur_pos = 2;
fputs(hex_prefix, file);
for (i1 = 0; i1 < val_size1; i1++) {
fprintf(file, "%02x", (unsigned int)(*val_buf)[i1]);
if (i1 + 1 < val_size1) {
fputs(",", file);
}
cur_pos += 3;
/* wrap the line */
if (cur_pos > REG_FILE_HEX_LINE_LEN) {
fputs("\\\n ", file);
cur_pos = 2;
}
} }
fputs("\n", file);
break;
} }
fputs("\n", file);
break;
}
} }
} }
} }
...@@ -1328,17 +1254,14 @@ void export_hkey(FILE *file, HKEY key, ...@@ -1328,17 +1254,14 @@ 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_len = *reg_key_name_len - curr_len; DWORD buf_len = *reg_key_name_len - curr_len;
ret = RegEnumKeyEx(key, i, *reg_key_name_buf + curr_len + 1, &buf_len, ret = RegEnumKeyEx(key, i, *reg_key_name_buf + curr_len + 1, &buf_len,
NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL);
if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA) if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA) {
{
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 {
...@@ -1346,8 +1269,7 @@ void export_hkey(FILE *file, HKEY key, ...@@ -1346,8 +1269,7 @@ void export_hkey(FILE *file, HKEY key,
i++; i++;
if (RegOpenKey(key, *reg_key_name_buf + curr_len + 1, if (RegOpenKey(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_len, export_hkey(file, subkey, reg_key_name_buf, reg_key_name_len,
val_name_buf, val_name_len, val_buf, val_size); val_name_buf, val_name_len, val_buf, val_size);
RegCloseKey(subkey); RegCloseKey(subkey);
...@@ -1365,8 +1287,7 @@ void export_hkey(FILE *file, HKEY key, ...@@ -1365,8 +1287,7 @@ void export_hkey(FILE *file, HKEY key,
FILE *REGPROC_open_export_file(CHAR *file_name) FILE *REGPROC_open_export_file(CHAR *file_name)
{ {
FILE *file = fopen(file_name, "w"); FILE *file = fopen(file_name, "w");
if (!file) if (!file) {
{
perror(""); perror("");
fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), file_name); fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), file_name);
exit(1); exit(1);
...@@ -1402,8 +1323,7 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name) ...@@ -1402,8 +1323,7 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
val_buf = HeapAlloc(GetProcessHeap(), 0, val_size); val_buf = HeapAlloc(GetProcessHeap(), 0, val_size);
CHECK_ENOUGH_MEMORY(reg_key_name_buf && val_name_buf && val_buf); CHECK_ENOUGH_MEMORY(reg_key_name_buf && val_name_buf && val_buf);
if (reg_key_name && reg_key_name[0]) if (reg_key_name && reg_key_name[0]) {
{
CHAR *branch_name; CHAR *branch_name;
HKEY key; HKEY key;
...@@ -1413,25 +1333,21 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name) ...@@ -1413,25 +1333,21 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
/* open the specified key */ /* open the specified key */
reg_key_class = getRegClass(reg_key_name); reg_key_class = getRegClass(reg_key_name);
if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) {
{
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n", fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
getAppName(), reg_key_name); getAppName(), reg_key_name);
exit(1); exit(1);
} }
branch_name = getRegKeyName(reg_key_name); branch_name = getRegKeyName(reg_key_name);
CHECK_ENOUGH_MEMORY(branch_name); CHECK_ENOUGH_MEMORY(branch_name);
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); file = REGPROC_open_export_file(file_name);
export_hkey(file, reg_key_class, export_hkey(file, reg_key_class,
&reg_key_name_buf, &reg_key_name_len, &reg_key_name_buf, &reg_key_name_len,
&val_name_buf, &val_name_len, &val_name_buf, &val_name_len,
&val_buf, &val_size); &val_buf, &val_size);
} } else if (RegOpenKey(reg_key_class, branch_name, &key) == ERROR_SUCCESS) {
else if (RegOpenKey(reg_key_class, branch_name, &key) == ERROR_SUCCESS)
{
file = REGPROC_open_export_file(file_name); file = REGPROC_open_export_file(file_name);
export_hkey(file, key, export_hkey(file, key,
&reg_key_name_buf, &reg_key_name_len, &reg_key_name_buf, &reg_key_name_len,
...@@ -1449,13 +1365,11 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name) ...@@ -1449,13 +1365,11 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
/* export all registry classes */ /* export all registry classes */
file = REGPROC_open_export_file(file_name); file = REGPROC_open_export_file(file_name);
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) {
{
strcpy(reg_key_name_buf, reg_class_names[i]); strcpy(reg_key_name_buf, reg_class_names[i]);
export_hkey(file, reg_class_keys[i], export_hkey(file, reg_class_keys[i],
&reg_key_name_buf, &reg_key_name_len, &reg_key_name_buf, &reg_key_name_len,
...@@ -1465,8 +1379,7 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name) ...@@ -1465,8 +1379,7 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
} }
} }
if (file) if (file) {
{
fclose(file); fclose(file);
} }
HeapFree(GetProcessHeap(), 0, reg_key_name); HeapFree(GetProcessHeap(), 0, reg_key_name);
...@@ -1501,8 +1414,7 @@ void delete_branch(HKEY key, ...@@ -1501,8 +1414,7 @@ void delete_branch(HKEY key,
LONG ret; LONG ret;
long int i; long int i;
if (RegOpenKey(key, *reg_key_name_buf, &branch_key) != ERROR_SUCCESS) if (RegOpenKey(key, *reg_key_name_buf, &branch_key) != ERROR_SUCCESS) {
{
REGPROC_print_error(); REGPROC_print_error();
} }
...@@ -1510,8 +1422,7 @@ void delete_branch(HKEY key, ...@@ -1510,8 +1422,7 @@ void delete_branch(HKEY key,
if (RegQueryInfoKey(branch_key, NULL, NULL, NULL, if (RegQueryInfoKey(branch_key, NULL, NULL, NULL,
&subkeys, &max_sub_key_len, &subkeys, &max_sub_key_len,
NULL, NULL, NULL, NULL, NULL, NULL NULL, NULL, NULL, NULL, NULL, NULL
) != ERROR_SUCCESS) ) != ERROR_SUCCESS) {
{
REGPROC_print_error(); REGPROC_print_error();
} }
curr_len = strlen(*reg_key_name_buf); curr_len = strlen(*reg_key_name_buf);
...@@ -1519,16 +1430,14 @@ void delete_branch(HKEY key, ...@@ -1519,16 +1430,14 @@ void delete_branch(HKEY key,
max_sub_key_len + curr_len + 1); max_sub_key_len + curr_len + 1);
(*reg_key_name_buf)[curr_len] = '\\'; (*reg_key_name_buf)[curr_len] = '\\';
for (i = subkeys - 1; i >= 0; i--) for (i = subkeys - 1; i >= 0; i--) {
{
DWORD buf_len = *reg_key_name_len - curr_len; DWORD buf_len = *reg_key_name_len - curr_len;
ret = RegEnumKeyEx(branch_key, i, *reg_key_name_buf + curr_len + 1, ret = RegEnumKeyEx(branch_key, i, *reg_key_name_buf + curr_len + 1,
&buf_len, NULL, NULL, NULL, NULL); &buf_len, NULL, NULL, NULL, NULL);
if (ret != ERROR_SUCCESS && if (ret != ERROR_SUCCESS &&
ret != ERROR_MORE_DATA && ret != ERROR_MORE_DATA &&
ret != ERROR_NO_MORE_ITEMS) ret != ERROR_NO_MORE_ITEMS) {
{
REGPROC_print_error(); REGPROC_print_error();
} else { } else {
delete_branch(key, reg_key_name_buf, reg_key_name_len); delete_branch(key, reg_key_name_buf, reg_key_name_len);
...@@ -1557,8 +1466,7 @@ void delete_registry_key(CHAR *reg_key_name) ...@@ -1557,8 +1466,7 @@ void delete_registry_key(CHAR *reg_key_name)
return; return;
/* open the specified key */ /* open the specified key */
reg_key_class = getRegClass(reg_key_name); reg_key_class = getRegClass(reg_key_name);
if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) {
{
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n", fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
getAppName(), reg_key_name); getAppName(), reg_key_name);
exit(1); exit(1);
...@@ -1566,14 +1474,12 @@ void delete_registry_key(CHAR *reg_key_name) ...@@ -1566,14 +1474,12 @@ void delete_registry_key(CHAR *reg_key_name)
branch_name = getRegKeyName(reg_key_name); branch_name = getRegKeyName(reg_key_name);
CHECK_ENOUGH_MEMORY(branch_name); CHECK_ENOUGH_MEMORY(branch_name);
branch_name_len = strlen(branch_name); branch_name_len = strlen(branch_name);
if (!branch_name[0]) if (!branch_name[0]) {
{
fprintf(stderr,"%s: Can't delete registry class '%s'\n", fprintf(stderr,"%s: Can't delete registry class '%s'\n",
getAppName(), reg_key_name); getAppName(), reg_key_name);
exit(1); exit(1);
} }
if (RegOpenKey(reg_key_class, branch_name, &branch_key) == ERROR_SUCCESS) if (RegOpenKey(reg_key_class, branch_name, &branch_key) == ERROR_SUCCESS) {
{
/* check whether the key exists */ /* check whether the key exists */
RegCloseKey(branch_key); RegCloseKey(branch_key);
delete_branch(reg_key_class, &branch_name, &branch_name_len); delete_branch(reg_key_class, &branch_name, &branch_name_len);
......
...@@ -49,7 +49,7 @@ void processRegLines(FILE *in, CommandAPI command); ...@@ -49,7 +49,7 @@ void processRegLines(FILE *in, CommandAPI command);
* Generic prototypes * Generic prototypes
*/ */
char* getToken(char** str, const char* delims); char* getToken(char** str, const char* delims);
void get_file_name(CHAR **command_line, CHAR *filename); void get_file_name(CHAR **command_line, CHAR *filename);
DWORD convertHexToDWord(char *str, BYTE *buf); DWORD convertHexToDWord(char *str, BYTE *buf);
DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen); DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen);
LPSTR convertHexToHexCSV( BYTE *buf, ULONG len); LPSTR convertHexToHexCSV( BYTE *buf, ULONG len);
......
...@@ -72,7 +72,7 @@ HKEY FindRegRoot(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, in ...@@ -72,7 +72,7 @@ HKEY FindRegRoot(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, in
hKey = (HKEY)item.lParam; hKey = (HKEY)item.lParam;
item.mask = TVIF_TEXT; item.mask = TVIF_TEXT;
item.hItem = hItem; item.hItem = hItem;
/* item.pszText = &keyPath[*pPathLen]; */ /* item.pszText = &keyPath[*pPathLen]; */
item.pszText = keyPath; item.pszText = keyPath;
item.cchTextMax = max; item.cchTextMax = max;
if (TreeView_GetItem(hwndTV, &item)) { if (TreeView_GetItem(hwndTV, &item)) {
...@@ -150,7 +150,7 @@ static BOOL InitTreeViewImageLists(HWND hwndTV) ...@@ -150,7 +150,7 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
/* Create the image list. */ /* Create the image list. */
if ((himl = ImageList_Create(CX_BITMAP, CY_BITMAP, if ((himl = ImageList_Create(CX_BITMAP, CY_BITMAP,
FALSE, NUM_BITMAPS, 0)) == NULL) FALSE, NUM_BITMAPS, 0)) == NULL)
return FALSE; return FALSE;
/* Add the open file, closed file, and document bitmaps. */ /* Add the open file, closed file, and document bitmaps. */
...@@ -213,7 +213,7 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv) ...@@ -213,7 +213,7 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
if (errCode == ERROR_SUCCESS) { if (errCode == ERROR_SUCCESS) {
TCHAR SubName[MAX_NAME_LEN]; TCHAR SubName[MAX_NAME_LEN];
DWORD cSubName = MAX_NAME_LEN; DWORD cSubName = MAX_NAME_LEN;
/* if (RegEnumKeyEx(hKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { */ /* if (RegEnumKeyEx(hKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { */
while (RegEnumKeyEx(hKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { while (RegEnumKeyEx(hKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
++dwCount; ++dwCount;
} }
...@@ -223,10 +223,9 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv) ...@@ -223,10 +223,9 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
cName = MAX_NAME_LEN; cName = MAX_NAME_LEN;
++dwIndex; ++dwIndex;
} }
/*ShowWindow(hwndTV, SW_SHOWNOACTIVATE); */ /*ShowWindow(hwndTV, SW_SHOWNOACTIVATE); */
RegCloseKey(hNewKey); RegCloseKey(hNewKey);
} }
} else {
} }
expanding = FALSE; expanding = FALSE;
return TRUE; return TRUE;
...@@ -246,9 +245,9 @@ HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id) ...@@ -246,9 +245,9 @@ HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id)
/* Get the dimensions of the parent window's client area, and create the tree view control. */ /* Get the dimensions of the parent window's client area, and create the tree view control. */
GetClientRect(hwndParent, &rcClient); GetClientRect(hwndParent, &rcClient);
hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, _T("Tree View"), hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, _T("Tree View"),
WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT, WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
0, 0, rcClient.right, rcClient.bottom, 0, 0, rcClient.right, rcClient.bottom,
hwndParent, (HMENU)id, hInst, NULL); hwndParent, (HMENU)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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment