ReactOS  0.4.12-dev-18-gf469aca
main.h File Reference
#include "resource.h"
Include dependency graph for main.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ChildWnd
 

Macros

#define STATUS_WINDOW   2001
 
#define TREE_WINDOW   2002
 
#define LIST_WINDOW   2003
 
#define SPLIT_WIDTH   5
 
#define SPLIT_MIN   30
 
#define COUNT_OF(a)   (sizeof(a)/sizeof(a[0]))
 
#define PM_MODIFYVALUE   0
 
#define PM_NEW   1
 
#define PM_TREECONTEXT   2
 
#define PM_HEXEDIT   3
 
#define MAX_NEW_KEY_LEN   128
 

Enumerations

enum  OPTION_FLAGS {
  OPTIONS_AUTO_REFRESH = 0x01, OPTIONS_READ_ONLY_MODE = 0x02, OPTIONS_CONFIRM_ON_DELETE = 0x04, OPTIONS_SAVE_ON_EXIT = 0x08,
  OPTIONS_DISPLAY_BINARY_DATA = 0x10, OPTIONS_VIEW_TREE_ONLY = 0x20, OPTIONS_VIEW_DATA_ONLY = 0x40
}
 

Functions

void ShowAboutBox (HWND hWnd)
 
LRESULT CALLBACK ChildWndProc (HWND, UINT, WPARAM, LPARAM)
 
void ResizeWnd (int cx, int cy)
 
LPCWSTR get_root_key_name (HKEY hRootKey)
 
int ErrorMessageBox (HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode,...)
 
int InfoMessageBox (HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
 
void FindDialog (HWND hWnd)
 
BOOL FindNext (HWND hWnd)
 
LRESULT CALLBACK FrameWndProc (HWND, UINT, WPARAM, LPARAM)
 
void SetupStatusBar (HWND hWnd, BOOL bResize)
 
void UpdateStatusBar (void)
 
BOOL CopyKeyName (HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
 
BOOL ExportRegistryFile (HWND hWnd)
 
HWND CreateListView (HWND hwndParent, HMENU id)
 
BOOL RefreshListView (HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
 
LPCWSTR GetValueName (HWND hwndLV, int iStartAt)
 
BOOL ListWndNotifyProc (HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
 
BOOL IsDefaultValue (HWND hwndLV, int i)
 
LPCWSTR getAppName (void)
 
HWND CreateTreeView (HWND hwndParent, LPWSTR pHostName, HMENU id)
 
BOOL RefreshTreeView (HWND hWndTV)
 
BOOL RefreshTreeItem (HWND hwndTV, HTREEITEM hItem)
 
BOOL OnTreeExpanding (HWND hWnd, NMTREEVIEW *pnmtv)
 
LPCWSTR GetItemPath (HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
 
BOOL DeleteNode (HWND hwndTV, HTREEITEM hItem)
 
HTREEITEM InsertNode (HWND hwndTV, HTREEITEM hItem, LPWSTR name)
 
HWND StartKeyRename (HWND hwndTV)
 
BOOL CreateNewKey (HWND hwndTV, HTREEITEM hItem)
 
BOOL SelectNode (HWND hwndTV, LPCWSTR keyPath)
 
void DestroyTreeView (HWND hwndTV)
 
void DestroyListView (HWND hwndLV)
 
void DestroyMainMenu (void)
 
BOOL ModifyValue (HWND hwnd, HKEY hKey, LPCWSTR valueName, BOOL EditBin)
 
BOOL DeleteKey (HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
 
LONG RenameKey (HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpNewName)
 
LONG RenameValue (HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpDestValue, LPCWSTR lpSrcValue)
 
LONG QueryStringValue (HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR pszBuffer, DWORD dwBufferLen)
 
BOOL GetKeyName (LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
 
BOOL RegKeyEditPermissions (HWND hWndOwner, HKEY hKey, LPCWSTR lpMachine, LPCWSTR lpKeyName)
 
void LoadSettings (void)
 
void SaveSettings (void)
 

Variables

HINSTANCE hInst
 
ChildWndg_pChildWnd
 
HWND hFrameWnd
 
HMENU hMenuFrame
 
HWND hStatusBar
 
HMENU hPopupMenus
 
HFONT hFont
 
enum OPTION_FLAGS Options
 
WCHAR szTitle []
 
WCHAR szFrameClass []
 
WCHAR szChildClass []
 
const WCHAR g_szGeneralRegKey []
 

Macro Definition Documentation

◆ COUNT_OF

◆ LIST_WINDOW

#define LIST_WINDOW   2003

Definition at line 28 of file main.h.

Referenced by ChildWndProc().

◆ MAX_NEW_KEY_LEN

#define MAX_NEW_KEY_LEN   128

Definition at line 40 of file main.h.

Referenced by InsertNode().

◆ PM_HEXEDIT

#define PM_HEXEDIT   3

Definition at line 38 of file main.h.

Referenced by HEXEDIT_WM_CONTEXTMENU().

◆ PM_MODIFYVALUE

#define PM_MODIFYVALUE   0

Definition at line 35 of file main.h.

Referenced by ChildWndProc().

◆ PM_NEW

#define PM_NEW   1

Definition at line 36 of file main.h.

Referenced by ChildWndProc(), and MAIN_MenuCommand().

◆ PM_TREECONTEXT

#define PM_TREECONTEXT   2

Definition at line 37 of file main.h.

Referenced by ChildWndProc().

◆ SPLIT_MIN

#define SPLIT_MIN   30

Definition at line 31 of file main.h.

Referenced by ChildWndProc().

◆ SPLIT_WIDTH

#define SPLIT_WIDTH   5

Definition at line 30 of file main.h.

◆ STATUS_WINDOW

#define STATUS_WINDOW   2001

Definition at line 26 of file main.h.

Referenced by InitInstance().

◆ TREE_WINDOW

#define TREE_WINDOW   2002

Definition at line 27 of file main.h.

Referenced by ChildWndProc().

Enumeration Type Documentation

◆ OPTION_FLAGS

Enumerator
OPTIONS_AUTO_REFRESH 
OPTIONS_READ_ONLY_MODE 
OPTIONS_CONFIRM_ON_DELETE 
OPTIONS_SAVE_ON_EXIT 
OPTIONS_DISPLAY_BINARY_DATA 
OPTIONS_VIEW_TREE_ONLY 
OPTIONS_VIEW_DATA_ONLY 

Definition at line 46 of file main.h.

Function Documentation

◆ ChildWndProc()

LRESULT CALLBACK ChildWndProc ( HWND  ,
UINT  ,
WPARAM  ,
LPARAM   
)

Definition at line 385 of file childwnd.c.

386 {
387  BOOL Result;
388 
389  switch (message)
390  {
391  case WM_CREATE:
392  {
393  WNDPROC oldproc;
394  HFONT hFont;
396 
397  /* Load "My Computer" string */
398  LoadStringW(hInst, IDS_MY_COMPUTER, buffer, COUNT_OF(buffer));
399 
401  if (!g_pChildWnd) return 0;
402 
403  wcsncpy(g_pChildWnd->szPath, buffer, MAX_PATH);
404  g_pChildWnd->nSplitPos = 250;
405  g_pChildWnd->hWnd = hWnd;
408  hWnd, (HMENU)0, hInst, 0);
411  hWnd, (HMENU)0, hInst, 0);
413  g_pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW/*, g_pChildWnd->szPath*/);
415 
416  /* set the address bar and button font */
418  {
421  WM_SETFONT,
422  (WPARAM)hFont,
423  0);
425  WM_SETFONT,
426  (WPARAM)hFont,
427  0);
428  }
429  /* Subclass the AddressBar */
433  break;
434  }
435  case WM_COMMAND:
436  if(HIWORD(wParam) == BN_CLICKED)
437  {
439  }
440 
442  {
443  goto def;
444  }
445  break;
446  case WM_SETCURSOR:
447  if (LOWORD(lParam) == HTCLIENT)
448  {
449  POINT pt;
450  GetCursorPos(&pt);
451  ScreenToClient(hWnd, &pt);
453  {
455  return TRUE;
456  }
457  }
458  goto def;
459  case WM_DESTROY:
462  DestroyMainMenu();
464  g_pChildWnd = NULL;
465  PostQuitMessage(0);
466  break;
467  case WM_LBUTTONDOWN:
468  {
469  RECT rt;
470  int x = (short)LOWORD(lParam);
471  GetClientRect(hWnd, &rt);
472  if (x>=g_pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<g_pChildWnd->nSplitPos+SPLIT_WIDTH/2+1)
473  {
476  SetCapture(hWnd);
477  }
478  break;
479  }
480 
481  case WM_LBUTTONUP:
482  case WM_RBUTTONDOWN:
483  if (GetCapture() == hWnd)
484  {
486  }
487  break;
488 
489  case WM_CAPTURECHANGED:
490  if (GetCapture()==hWnd && last_split>=0)
492  break;
493 
494  case WM_KEYDOWN:
495  if (wParam == VK_ESCAPE)
496  if (GetCapture() == hWnd)
497  {
498  RECT rt;
500  GetClientRect(hWnd, &rt);
501  ResizeWnd(rt.right, rt.bottom);
502  last_split = -1;
503  ReleaseCapture();
505  }
506  break;
507 
508  case WM_MOUSEMOVE:
509  if (GetCapture() == hWnd)
510  {
511  HDC hdc;
512  RECT rt;
513  HGDIOBJ OldObj;
514  int x = LOWORD(lParam);
515  if(!SizingPattern)
516  {
517  const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
518  SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
519  }
520  if(!SizingBrush)
521  {
523  }
524 
525  GetClientRect(hWnd, &rt);
526  x = (SHORT) min(max(x, SPLIT_MIN), rt.right - SPLIT_MIN);
527  if(last_split != x)
528  {
529  rt.left = last_split-SPLIT_WIDTH/2;
530  rt.right = last_split+SPLIT_WIDTH/2+1;
531  hdc = GetDC(hWnd);
532  OldObj = SelectObject(hdc, SizingBrush);
533  PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
534  last_split = x;
535  rt.left = x-SPLIT_WIDTH/2;
536  rt.right = x+SPLIT_WIDTH/2+1;
537  PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
538  SelectObject(hdc, OldObj);
539  ReleaseDC(hWnd, hdc);
540  }
541  }
542  break;
543 
544  case WM_SETFOCUS:
545  if (g_pChildWnd != NULL)
546  {
548  }
549  break;
550 
551  case WM_TIMER:
552  break;
553 
554  case WM_NOTIFY:
555  if ((int)wParam == TREE_WINDOW && g_pChildWnd != NULL)
556  {
557  switch (((LPNMHDR)lParam)->code)
558  {
559  case TVN_ITEMEXPANDING:
560  return !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
561  case TVN_SELCHANGED:
562  {
563  NMTREEVIEW* pnmtv = (NMTREEVIEW*)lParam;
564  /* Get the parent of the current item */
565  HTREEITEM hParentItem = TreeView_GetParent(g_pChildWnd->hTreeWnd, pnmtv->itemNew.hItem);
566 
567  UpdateAddress(pnmtv->itemNew.hItem, NULL, NULL);
568 
569  /*
570  * Disable Delete/Rename menu options for 'My Computer' (first item so doesn't have any parent)
571  * and HKEY_* keys (their parent is 'My Computer' and the previous remark applies).
572  */
573  if (!hParentItem || !TreeView_GetParent(g_pChildWnd->hTreeWnd, hParentItem))
574  {
579  }
580  else
581  {
586  }
587 
588  break;
589  }
590  case NM_SETFOCUS:
592  break;
593  case TVN_BEGINLABELEDIT:
594  {
595  LPNMTVDISPINFO ptvdi;
596  /* cancel label edit for rootkeys */
597  ptvdi = (LPNMTVDISPINFO) lParam;
598  if (!TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem) ||
600  return TRUE;
601  break;
602  }
603  case TVN_ENDLABELEDIT:
604  {
605  LPCWSTR keyPath;
606  HKEY hRootKey;
607  HKEY hKey = NULL;
608  LPNMTVDISPINFO ptvdi;
609  LONG lResult = TRUE;
610  WCHAR szBuffer[MAX_PATH];
611 
612  ptvdi = (LPNMTVDISPINFO) lParam;
613  if (ptvdi->item.pszText)
614  {
615  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey);
616  _snwprintf(szBuffer, COUNT_OF(szBuffer), L"%s\\%s", keyPath, ptvdi->item.pszText);
617  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey);
618  if (RegOpenKeyExW(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
619  {
620  lResult = FALSE;
621  RegCloseKey(hKey);
622  TreeView_EditLabel(g_pChildWnd->hTreeWnd, ptvdi->item.hItem);
623  }
624  else
625  {
626  if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS)
627  lResult = FALSE;
628  else
629  UpdateAddress(ptvdi->item.hItem, hRootKey, szBuffer);
630  }
631  return lResult;
632  }
633  }
634  default:
635  return 0;
636  }
637  }
638  else
639  {
640  if ((int)wParam == LIST_WINDOW && g_pChildWnd != NULL)
641  {
642  switch (((LPNMHDR)lParam)->code)
643  {
644  case NM_SETFOCUS:
646  break;
647  default:
648  if(!ListWndNotifyProc(g_pChildWnd->hListWnd, wParam, lParam, &Result))
649  {
650  goto def;
651  }
652  return Result;
653  break;
654  }
655  }
656  }
657  break;
658 
659  case WM_CONTEXTMENU:
660  {
661  POINT pt;
663  {
664  int i, cnt;
665  BOOL IsDefault;
666  pt.x = (short) LOWORD(lParam);
667  pt.y = (short) HIWORD(lParam);
670  if (pt.x == -1 && pt.y == -1)
671  {
672  RECT rc;
673  if (i != -1)
674  {
675  rc.left = LVIR_BOUNDS;
677  pt.x = rc.left + 8;
678  pt.y = rc.top + 8;
679  }
680  else
681  pt.x = pt.y = 0;
683  }
684  if(i == -1)
685  {
687  }
688  else
689  {
692  IsDefault = IsDefaultValue(g_pChildWnd->hListWnd, i);
693  if(cnt == 1)
695  else
699 
700  TrackPopupMenu(mnu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
701  }
702  }
703  else if ((HWND)wParam == g_pChildWnd->hTreeWnd)
704  {
705  TVHITTESTINFO hti;
706  HMENU hContextMenu;
707  TVITEMW item;
708  MENUITEMINFOW mii;
709  WCHAR resource[256];
710  WCHAR buffer[256];
711  LPWSTR s;
712  LPCWSTR keyPath;
713  HKEY hRootKey;
714  int iLastPos;
715  WORD wID;
716 
717  pt.x = (short) LOWORD(lParam);
718  pt.y = (short) HIWORD(lParam);
719 
720  if (pt.x == -1 && pt.y == -1)
721  {
722  RECT rc;
724  if (hti.hItem != NULL)
725  {
727  pt.x = rc.left + 8;
728  pt.y = rc.top + 8;
730  hti.flags = TVHT_ONITEM;
731  }
732  else
733  hti.flags = 0;
734  }
735  else
736  {
737  hti.pt.x = pt.x;
738  hti.pt.y = pt.y;
741  }
742 
743  if (hti.flags & TVHT_ONITEM)
744  {
745  hContextMenu = GetSubMenu(hPopupMenus, PM_TREECONTEXT);
747 
748  memset(&item, 0, sizeof(item));
749  item.mask = TVIF_STATE | TVIF_CHILDREN;
750  item.hItem = hti.hItem;
752 
753  /* Set the Expand/Collapse menu item appropriately */
754  LoadStringW(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, COUNT_OF(buffer));
755  memset(&mii, 0, sizeof(mii));
756  mii.cbSize = sizeof(mii);
758  mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED;
760  mii.dwTypeData = (LPWSTR) buffer;
761  SetMenuItemInfo(hContextMenu, 0, TRUE, &mii);
762 
763  /* Remove any existing suggestions */
764  memset(&mii, 0, sizeof(mii));
765  mii.cbSize = sizeof(mii);
766  mii.fMask = MIIM_ID;
767  GetMenuItemInfo(hContextMenu, GetMenuItemCount(hContextMenu) - 1, TRUE, &mii);
768  if ((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX))
769  {
770  do
771  {
772  iLastPos = GetMenuItemCount(hContextMenu) - 1;
773  GetMenuItemInfo(hContextMenu, iLastPos, TRUE, &mii);
774  RemoveMenu(hContextMenu, iLastPos, MF_BYPOSITION);
775  }
776  while((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX));
777  }
778 
779  /* Come up with suggestions */
780  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, NULL, &hRootKey);
781  SuggestKeys(hRootKey, keyPath, Suggestions, COUNT_OF(Suggestions));
782  if (Suggestions[0])
783  {
784  AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL);
785 
786  LoadStringW(hInst, IDS_GOTO_SUGGESTED_KEY, resource, COUNT_OF(resource));
787 
788  s = Suggestions;
790  while(*s && (wID <= ID_TREE_SUGGESTION_MAX))
791  {
792  _snwprintf(buffer, COUNT_OF(buffer), resource, s);
793 
794  memset(&mii, 0, sizeof(mii));
795  mii.cbSize = sizeof(mii);
796  mii.fMask = MIIM_STRING | MIIM_ID;
797  mii.wID = wID++;
798  mii.dwTypeData = buffer;
799  InsertMenuItem(hContextMenu, GetMenuItemCount(hContextMenu), TRUE, &mii);
800 
801  s += wcslen(s) + 1;
802  }
803  }
804  TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, g_pChildWnd->hWnd, NULL);
805  }
806  }
807  break;
808  }
809 
810  case WM_SIZE:
811  if (wParam != SIZE_MINIMIZED && g_pChildWnd != NULL)
812  {
813  ResizeWnd(LOWORD(lParam), HIWORD(lParam));
814  }
815  /* fall through */
816  default:
817 def:
818  return DefWindowProcW(hWnd, message, wParam, lParam);
819  }
820  return 0;
821 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define IDC_SIZEWE
Definition: winuser.h:689
#define IDS_GOTO_SUGGESTED_KEY
Definition: resource.h:193
#define ID_TREE_RENAME
Definition: resource.h:154
#define HDC
Definition: msvc.h:22
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
#define max(a, b)
Definition: svc.c:63
Definition: tftpd.h:59
#define MF_DISABLED
Definition: winuser.h:130
#define TRUE
Definition: types.h:120
void DestroyListView(HWND hwndLV)
Definition: listview.c:653
#define ID_TREE_COLLAPSEBRANCH
Definition: resource.h:97
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define TreeView_GetItemRect(hwnd, hitem, prc, code)
Definition: commctrl.h:3396
#define PATINVERT
Definition: wingdi.h:326
#define MF_BYCOMMAND
Definition: winuser.h:202
static void SuggestKeys(HKEY hRootKey, LPCWSTR pszKeyPath, LPWSTR pszSuggestions, size_t iSuggestionsLength)
Definition: childwnd.c:227
long y
Definition: polytest.cpp:48
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WM_CONTEXTMENU
Definition: richedit.h:64
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:298
long x
Definition: polytest.cpp:48
static void finish_splitbar(HWND hWnd, int x)
Definition: childwnd.c:120
HDC WINAPI GetDC(_In_opt_ HWND)
#define PM_MODIFYVALUE
Definition: main.h:35
#define KEY_READ
Definition: nt_native.h:1023
#define pt(x, y)
Definition: drawing.c:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3471
HWND hTreeWnd
Definition: main.h:60
#define BS_TEXT
Definition: winuser.h:276
#define WM_CAPTURECHANGED
Definition: winuser.h:1784
HWND hListWnd
Definition: main.h:61
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:297
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
GLuint buffer
Definition: glext.h:5915
HWND WINAPI SetFocus(_In_opt_ HWND)
static BOOL ChildWnd_CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:140
LPWSTR dwTypeData
Definition: winuser.h:3211
#define LVNI_SELECTED
Definition: commctrl.h:2394
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:296
UINT mask
Definition: commctrl.h:3283
#define MFS_DEFAULT
Definition: winuser.h:743
#define VK_ESCAPE
Definition: winuser.h:2168
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define BS_CENTER
Definition: winuser.h:260
LONG right
Definition: windef.h:298
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define VK_RETURN
Definition: winuser.h:2155
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
#define SPLIT_WIDTH
Definition: eventvwr.c:62
HFONT hFont
Definition: main.c:53
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LONG RenameKey(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpNewName)
Definition: edit.c:1489
HBITMAP SizingPattern
Definition: childwnd.c:25
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
int nSplitPos
Definition: main.h:65
#define TPM_RIGHTBUTTON
Definition: winuser.h:2334
GLenum GLclampf GLint i
Definition: glfuncs.h:14
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2679
#define TVN_ENDLABELEDIT
Definition: commctrl.h:3711
#define TVIF_CHILDREN
Definition: commctrl.h:3239
#define ID_TREE_SUGGESTION_MIN
Definition: resource.h:158
#define MIIM_STATE
Definition: winuser.h:716
long LONG
Definition: pedump.c:60
#define NMTREEVIEW
Definition: commctrl.h:3609
#define ID_EDIT_DELETE
Definition: resource.h:59
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETCURSOR
Definition: winuser.h:1618
short SHORT
Definition: pedump.c:59
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL IsDefaultValue(HWND hwndLV, int i)
Definition: listview.c:107
#define TVN_BEGINLABELEDIT
Definition: commctrl.h:3710
HWND WINAPI GetCapture(void)
Definition: message.c:2855
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define TREE_WINDOW
Definition: main.h:27
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define GWLP_USERDATA
Definition: treelist.c:63
HDC hdc
Definition: msvc.h:53
static void draw_splitbar(HWND hWnd, int x)
Definition: childwnd.c:90
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define WM_KEYDOWN
Definition: winuser.h:1691
#define MF_SEPARATOR
Definition: winuser.h:137
static WCHAR Suggestions[256]
Definition: childwnd.c:27
#define SPLIT_MIN
Definition: main.h:31
#define LVNI_FOCUSED
Definition: commctrl.h:2393
#define ID_EDIT_RENAME
Definition: resource.h:60
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define WS_CHILDWINDOW
Definition: pedump.c:639
int cChildren
Definition: commctrl.h:3291
#define WM_DESTROY
Definition: winuser.h:1591
HTREEITEM hItem
Definition: commctrl.h:3488
#define MIIM_ID
Definition: winuser.h:717
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
#define GetMenuItemInfo
Definition: winuser.h:5654
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)
#define SetMenuItemInfo
Definition: winuser.h:5716
BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
Definition: listview.c:543
WCHAR szPath[MAX_PATH]
Definition: main.h:67
#define ID_TREE_SUGGESTION_MAX
Definition: resource.h:159
#define COUNT_OF(a)
Definition: main.h:33
static VOID DestroyTreeView(HWND hTreeView)
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3440
unsigned int BOOL
Definition: ntddk_ex.h:94
#define AppendMenu
Definition: winuser.h:5597
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TreeView_HitTest(hwnd, lpht)
Definition: commctrl.h:3480
#define WM_SIZE
Definition: winuser.h:1593
static int last_split
Definition: childwnd.c:24
HMENU hPopupMenus
Definition: main.c:33
#define NM_SETFOCUS
Definition: commctrl.h:135
void DestroyMainMenu()
Definition: main.c:156
HWND hWnd
Definition: main.h:59
#define TVN_SELCHANGED
Definition: commctrl.h:3702
#define WM_TIMER
Definition: winuser.h:1718
#define MF_ENABLED
Definition: winuser.h:128
#define MAX_PATH
Definition: compat.h:26
#define PM_TREECONTEXT
Definition: main.h:37
#define WM_KEYUP
Definition: winuser.h:1692
unsigned short WORD
Definition: ntddk_ex.h:93
#define BN_CLICKED
Definition: winuser.h:1886
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDS_MY_COMPUTER
Definition: resource.h:131
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define SIZE_MINIMIZED
Definition: winuser.h:2460
HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, HMENU id)
Definition: treeview.c:634
HWND hAddressBtnWnd
Definition: main.h:63
#define DEFAULT_GUI_FONT
Definition: wingdi.h:907
void ResizeWnd(int cx, int cy)
Definition: childwnd.c:41
static VOID UpdateAddress(HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath)
Definition: childwnd.c:320
static const WCHAR L[]
Definition: oid.c:1087
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define MFS_GRAYED
Definition: winuser.h:746
GLdouble s
Definition: gl.h:2039
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3436
#define WS_TABSTOP
Definition: pedump.c:634
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1716
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define BS_VCENTER
Definition: winuser.h:279
#define LVM_GETITEMRECT
Definition: commctrl.h:2447
#define GWLP_WNDPROC
Definition: treelist.c:66
#define TVIS_EXPANDED
Definition: commctrl.h:3251
#define BS_FLAT
Definition: winuser.h:280
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
#define ID_EDIT_MODIFY
Definition: resource.h:64
#define MIIM_STRING
Definition: winuser.h:722
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND hFrameWnd
Definition: main.c:30
#define TVN_ITEMEXPANDING
Definition: commctrl.h:3705
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define LVIR_BOUNDS
Definition: commctrl.h:2442
HINSTANCE hInst
Definition: dxdiag.c:13
HMENU hMenuFrame
Definition: main.c:32
static ATOM item
Definition: dde.c:856
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
INT x
Definition: msvc.h:62
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3448
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define PM_NEW
Definition: main.h:36
#define ID_TREE_EXPANDBRANCH
Definition: resource.h:95
#define min(a, b)
Definition: monoChain.cc:55
#define WM_MOUSEMOVE
Definition: winuser.h:1751
HTREEITEM hItem
Definition: commctrl.h:3284
BOOL CreateListView(PMAIN_WND_INFO Info)
Definition: listview.c:355
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_SETFONT
Definition: winuser.h:1632
#define LPNMTVDISPINFO
Definition: commctrl.h:3643
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2864
HWND hAddressBarWnd
Definition: main.h:62
Definition: main.h:57
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1590
#define LIST_WINDOW
Definition: main.h:28
#define HIWORD(l)
Definition: typedefs.h:246
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LONG bottom
Definition: windef.h:299
#define TVIF_STATE
Definition: commctrl.h:3236
UINT state
Definition: commctrl.h:3285
#define GetWindowLongPtr
Definition: treelist.c:73
#define ID_TREE_DELETE
Definition: resource.h:153
#define WM_SETFOCUS
Definition: winuser.h:1595
#define MF_GRAYED
Definition: winuser.h:129
#define HTCLIENT
Definition: winuser.h:2429
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
#define IDS_COLLAPSE
Definition: resource.h:190
#define IDS_EXPAND
Definition: resource.h:189
#define TVHT_ONITEM
Definition: commctrl.h:3494
#define WS_VISIBLE
Definition: pedump.c:620
#define ID_EDIT_MODIFY_BIN
Definition: resource.h:124
#define memset(x, y, z)
Definition: compat.h:39
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW *pnmtv)
Definition: treeview.c:503
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3457
#define WM_NOTIFY
Definition: richedit.h:61
#define InsertMenuItem
Definition: winuser.h:5670
int nFocusPanel
Definition: main.h:64
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HBRUSH SizingBrush
Definition: childwnd.c:26

◆ CopyKeyName()

BOOL CopyKeyName ( HWND  hWnd,
HKEY  hRootKey,
LPCWSTR  keyName 
)

Definition at line 790 of file framewnd.c.

Referenced by _CmdWndProc(), and ChildWnd_CmdWndProc().

791 {
792  BOOL bClipboardOpened = FALSE;
793  BOOL bSuccess = FALSE;
794  WCHAR szBuffer[512];
795  HGLOBAL hGlobal;
796  LPWSTR s;
797 
798  if (!OpenClipboard(hWnd))
799  goto done;
800  bClipboardOpened = TRUE;
801 
802  if (!EmptyClipboard())
803  goto done;
804 
805  if (!GetKeyName(szBuffer, COUNT_OF(szBuffer), hRootKey, keyName))
806  goto done;
807 
808  hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
809  if (!hGlobal)
810  goto done;
811 
812  s = GlobalLock(hGlobal);
813  wcscpy(s, szBuffer);
814  GlobalUnlock(hGlobal);
815 
817  bSuccess = TRUE;
818 
819 done:
820  if (bClipboardOpened)
821  CloseClipboard();
822  return bSuccess;
823 }
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
__wchar_t WCHAR
Definition: xmlstorage.h:180
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
static BOOLEAN bSuccess
Definition: drive.cpp:419
#define CF_UNICODETEXT
Definition: constants.h:408
#define COUNT_OF(a)
Definition: main.h:33
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
GLdouble s
Definition: gl.h:2039
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define GMEM_MOVEABLE
Definition: winbase.h:291
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:1588

◆ CreateListView()

HWND CreateListView ( HWND  hwndParent,
HMENU  id 
)

Definition at line 630 of file listview.c.

631 {
632  RECT rcClient;
633  HWND hwndLV;
634 
635  /* Get the dimensions of the parent window's client area, and create the list view control. */
636  GetClientRect(hwndParent, &rcClient);
637  hwndLV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEW, L"List View",
639  0, 0, rcClient.right, rcClient.bottom,
640  hwndParent, id, hInst, NULL);
641  if (!hwndLV) return NULL;
642 
643  /* Initialize the image list, and add items to the control. */
644  if (!CreateListColumns(hwndLV)) goto fail;
645  if (!InitListViewImageLists(hwndLV)) goto fail;
646 
647  return hwndLV;
648 fail:
649  DestroyWindow(hwndLV);
650  return NULL;
651 }
#define LVS_SHOWSELALWAYS
Definition: commctrl.h:2237
#define LVS_REPORT
Definition: commctrl.h:2232
#define WS_CHILD
Definition: pedump.c:617
LONG right
Definition: windef.h:298
BOOL WINAPI DestroyWindow(_In_ HWND)
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1087
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WS_TABSTOP
Definition: pedump.c:634
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HINSTANCE hInst
Definition: dxdiag.c:13
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
static BOOL InitListViewImageLists(HWND hwndLV)
Definition: listview.c:280
#define LVS_EDITLABELS
Definition: commctrl.h:2243
#define WC_LISTVIEW
Definition: commctrl.h:2229
static BOOL CreateListColumns(HWND hWndListView)
Definition: listview.c:258
LONG bottom
Definition: windef.h:299
#define WS_VISIBLE
Definition: pedump.c:620

◆ CreateNewKey()

BOOL CreateNewKey ( HWND  hwndTV,
HTREEITEM  hItem 
)

Definition at line 571 of file treeview.c.

Referenced by _CmdWndProc(), and ChildWnd_CmdWndProc().

572 {
573  WCHAR szNewKeyFormat[128];
574  WCHAR szNewKey[128];
575  LPCWSTR pszKeyPath;
576  int iIndex = 1;
577  LONG nResult;
578  HKEY hRootKey = NULL, hKey = NULL, hNewKey = NULL;
579  BOOL bSuccess = FALSE;
580  DWORD dwDisposition;
581  HTREEITEM hNewItem;
582 
583  pszKeyPath = GetItemPath(hwndTV, hItem, &hRootKey);
584  if (pszKeyPath[0] == L'\0')
585  hKey = hRootKey;
586  else if (RegOpenKeyW(hRootKey, pszKeyPath, &hKey) != ERROR_SUCCESS)
587  goto done;
588 
589  if (LoadStringW(hInst, IDS_NEW_KEY, szNewKeyFormat, COUNT_OF(szNewKeyFormat)) <= 0)
590  goto done;
591 
592  /* Need to create a new key with a unique name */
593  do
594  {
595  wsprintf(szNewKey, szNewKeyFormat, iIndex++);
596  nResult = RegCreateKeyExW(hKey, szNewKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hNewKey, &dwDisposition);
597  if (hNewKey && dwDisposition == REG_OPENED_EXISTING_KEY)
598  {
599  RegCloseKey(hNewKey);
600  hNewKey = NULL;
601  }
602  else if (!hNewKey)
603  {
604  InfoMessageBox(hFrameWnd, MB_OK | MB_ICONERROR, NULL, L"Cannot create new key!\n\nError Code: %d", nResult);
605  goto done;
606  }
607  }
608  while(!hNewKey);
609 
610  /* Insert the new key */
611  hNewItem = InsertNode(hwndTV, hItem, szNewKey);
612  if (!hNewItem)
613  goto done;
614 
615  /* The new key's name is probably not appropriate yet */
616  (void)TreeView_EditLabel(hwndTV, hNewItem);
617 
618  bSuccess = TRUE;
619 
620 done:
621  if (hKey != hRootKey && hKey)
622  RegCloseKey(hKey);
623  if (hNewKey)
624  RegCloseKey(hNewKey);
625  return bSuccess;
626 }
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3471
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
Definition: error.c:51
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1085
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static BOOLEAN bSuccess
Definition: drive.cpp:419
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1094
#define IDS_NEW_KEY
Definition: resource.h:191
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name)
Definition: treeview.c:331
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
#define COUNT_OF(a)
Definition: main.h:33
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
#define MB_ICONERROR
Definition: winuser.h:781
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
HWND hFrameWnd
Definition: main.c:30
HINSTANCE hInst
Definition: dxdiag.c:13
#define MB_OK
Definition: winuser.h:784
#define wsprintf
Definition: winuser.h:5731

◆ CreateTreeView()

HWND CreateTreeView ( HWND  hwndParent,
LPWSTR  pHostName,
HMENU  id 
)

Definition at line 634 of file treeview.c.

Referenced by ChildWndProc(), and CMainWindow::CreateLayout().

635 {
636  RECT rcClient;
637  HWND hwndTV;
638 
639  /* Get the dimensions of the parent window's client area, and create the tree view control. */
640  GetClientRect(hwndParent, &rcClient);
643  0, 0, rcClient.right, rcClient.bottom,
644  hwndParent, id, hInst, NULL);
645  /* Initialize the image list, and add items to the control. */
646  if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName))
647  {
648  DestroyWindow(hwndTV);
649  return NULL;
650  }
651  return hwndTV;
652 }
static BOOL InitTreeViewItems(HWND hwndTV, LPWSTR pHostName)
Definition: treeview.c:391
#define TVS_LINESATROOT
Definition: commctrl.h:3216
#define WS_CHILD
Definition: pedump.c:617
LONG right
Definition: windef.h:298
BOOL WINAPI DestroyWindow(_In_ HWND)
#define TVS_HASBUTTONS
Definition: commctrl.h:3214
smooth NULL
Definition: ftsmooth.c:416
#define WC_TREEVIEW
Definition: commctrl.h:3212
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WS_TABSTOP
Definition: pedump.c:634
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
static BOOL InitTreeViewImageLists(HWND hwndTV)
Definition: treeview.c:438
HINSTANCE hInst
Definition: dxdiag.c:13
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define TVS_SHOWSELALWAYS
Definition: commctrl.h:3219
#define TVS_HASLINES
Definition: commctrl.h:3215
LONG bottom
Definition: windef.h:299
#define WS_VISIBLE
Definition: pedump.c:620
#define TVS_EDITLABELS
Definition: commctrl.h:3217

◆ DeleteKey()

BOOL DeleteKey ( HWND  hwnd,
HKEY  hKeyRoot,
LPCWSTR  keyPath 
)

Definition at line 1456 of file edit.c.

Referenced by _CmdWndProc(), ChildWnd_CmdWndProc(), DECLARE_INTERFACE_(), and CRegistryKey::QueryInterface().

1457 {
1458  WCHAR msg[128], caption[128];
1459  BOOL result = FALSE;
1460  LONG lRet;
1461  HKEY hKey;
1462 
1463  lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ|KEY_SET_VALUE, &hKey);
1464  if (lRet != ERROR_SUCCESS)
1465  {
1466  error_code_messagebox(hwnd, lRet);
1467  return FALSE;
1468  }
1469 
1472 
1473  if (MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) != IDYES)
1474  goto done;
1475 
1476  lRet = SHDeleteKey(hKeyRoot, keyPath);
1477  if (lRet != ERROR_SUCCESS)
1478  {
1479  error(hwnd, IDS_BAD_KEY, keyPath);
1480  goto done;
1481  }
1482  result = TRUE;
1483 
1484 done:
1485  RegCloseKey(hKey);
1486  return result;
1487 }
void error(HWND hwnd, INT resId,...)
Definition: edit.c:42
#define TRUE
Definition: types.h:120
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define IDS_BAD_KEY
Definition: resource.h:144
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDYES
Definition: winuser.h:829
#define KEY_SET_VALUE
Definition: nt_native.h:1017
char caption[64]
Definition: dialog.c:2033
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define MB_YESNO
Definition: winuser.h:811
long LONG
Definition: pedump.c:60
UINT msg
Definition: msvc.h:92
static void error_code_messagebox(HWND hwnd, DWORD error_code)
Definition: edit.c:65
#define MB_ICONQUESTION
Definition: winuser.h:783
#define COUNT_OF(a)
Definition: main.h:33
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define IDS_QUERY_DELETE_KEY_CONFIRM
Definition: resource.h:157
HWND hWnd
Definition: main.h:59
#define IDS_QUERY_DELETE_KEY_ONE
Definition: resource.h:155
HINSTANCE hInst
Definition: dxdiag.c:13
#define SHDeleteKey
Definition: shlwapi.h:44
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
GLuint64EXT * result
Definition: glext.h:11304

◆ DeleteNode()

BOOL DeleteNode ( HWND  hwndTV,
HTREEITEM  hItem 
)

Definition at line 102 of file treeview.c.

Referenced by _CmdWndProc(), ChildWnd_CmdWndProc(), tinyxml2::XMLDocument::RootElement(), and RtlpDeleteAvlTreeNode().

103 {
104  if (!hItem) hItem = TreeView_GetSelection(hwndTV);
105  if (!hItem) return FALSE;
106  return TreeView_DeleteItem(hwndTV, hItem);
107 }
#define TreeView_DeleteItem(hwnd, hitem)
Definition: commctrl.h:3382
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3440

◆ DestroyListView()

void DestroyListView ( HWND  hwndLV)

Definition at line 653 of file listview.c.

Referenced by ChildWndProc(), and RefreshListView().

654 {
655  INT count, i;
656  LVITEMW item;
657 
658  count = ListView_GetItemCount(hwndLV);
659  for (i = 0; i < count; i++)
660  {
661  item.mask = LVIF_PARAM;
662  item.iItem = i;
663  (void)ListView_GetItem(hwndLV, &item);
664  free(((LINE_INFO*)item.lParam)->name);
665  HeapFree(GetProcessHeap(), 0, (void*)item.lParam);
666  }
667 
668 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define free
Definition: debug_ros.c:5
int32_t INT
Definition: typedefs.h:56
GLenum GLclampf GLint i
Definition: glfuncs.h:14
LPARAM lParam
Definition: commctrl.h:2338
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2277
#define GetProcessHeap()
Definition: compat.h:395
UINT mask
Definition: commctrl.h:2330
static ATOM item
Definition: dde.c:856
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2364
#define LVIF_PARAM
Definition: commctrl.h:2281
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ DestroyMainMenu()

void DestroyMainMenu ( void  )

Definition at line 156 of file main.c.

Referenced by ChildWndProc().

157 {
159 }
BOOL WINAPI DestroyMenu(_In_ HMENU)
HMENU hMenuFrame
Definition: main.c:32

◆ DestroyTreeView()

void DestroyTreeView ( HWND  hwndTV)

Definition at line 654 of file treeview.c.

655 {
657 
659 
660  /* Destroy the image list associated with the tree view control */
661  himl = TreeView_GetImageList(hwndTV, TVSIL_NORMAL);
662  if (himl) ImageList_Destroy(himl);
663 }
static LPWSTR pathBuffer
Definition: treeview.c:31
HIMAGELIST himl
#define TreeView_GetImageList(hwnd, iImage)
Definition: commctrl.h:3408
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:893
#define GetProcessHeap()
Definition: compat.h:395
#define TVSIL_NORMAL
Definition: commctrl.h:3410
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ ErrorMessageBox()

int ErrorMessageBox ( HWND  hWnd,
LPCWSTR  lpTitle,
DWORD  dwErrorCode,
  ... 
)

Definition at line 24 of file error.c.

Referenced by error_code_messagebox(), ExportRegistryFile(), ImportRegistryFile(), LoadHive(), and UnloadHive().

25 {
26  int iRet = 0;
27  LPWSTR lpMsgBuf = NULL;
28  DWORD Status = 0;
29  va_list args;
30 
31  va_start(args, dwErrorCode);
32 
34  NULL,
35  dwErrorCode,
37  (LPWSTR)&lpMsgBuf,
38  0,
39  &args);
40 
41  va_end(args);
42 
43  iRet = MessageBoxW(hWnd, (Status && lpMsgBuf ? lpMsgBuf : L"Error displaying error message."), lpTitle, MB_OK | MB_ICONERROR);
44 
45  if (lpMsgBuf) LocalFree(lpMsgBuf);
46 
47  /* Return the MessageBoxW information */
48  return iRet;
49 }
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define va_end(ap)
Definition: acmsvcex.h:90
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
#define MB_ICONERROR
Definition: winuser.h:781
Status
Definition: gdiplustypes.h:24
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define MB_OK
Definition: winuser.h:784
TCHAR lpTitle[80]
Definition: ctm.c:67
#define MAKELANGID(p, s)
Definition: nls.h:15
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define args
Definition: format.c:66

◆ ExportRegistryFile()

BOOL ExportRegistryFile ( HWND  hWnd)

Definition at line 586 of file framewnd.c.

Referenced by _CmdWndProc(), and ChildWnd_CmdWndProc().

587 {
588  BOOL bRet = FALSE;
590  WCHAR ExportKeyPath[_MAX_PATH] = {0};
591  WCHAR Caption[128], szTitle[512], szText[512];
592  HKEY hKeyRoot;
593  LPCWSTR pszKeyPath;
594 
595  /* Figure out which key path we are exporting */
596  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
597  GetKeyName(ExportKeyPath, COUNT_OF(ExportKeyPath), hKeyRoot, pszKeyPath);
598 
599  InitOpenFileName(hWnd, &ofn);
600  LoadStringW(hInst, IDS_EXPORT_REG_FILE, Caption, COUNT_OF(Caption));
601  ofn.lpstrTitle = Caption;
602 
603  /* Only set the path if a key (not the root node) is selected */
604  if (hKeyRoot != 0)
605  {
606  ofn.lCustData = (LPARAM) ExportKeyPath;
607  }
611  if (GetSaveFileName(&ofn))
612  {
613  switch (ofn.nFilterIndex)
614  {
615  case 2: /* Registry Hive Files */
616  {
617  LONG lResult;
618  HKEY hSubKey;
619 
620  /* Open the subkey */
621  lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_READ, &hSubKey);
622  if (lResult == ERROR_SUCCESS)
623  {
624  /* Enable the 'backup' privilege, save the hive then disable the privilege */
626  lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
627  if (lResult == ERROR_ALREADY_EXISTS)
628  {
629  /*
630  * We are here, that means that we already said "yes" to the confirmation dialog.
631  * So we absolutely want to replace the hive file.
632  */
633  if (DeleteFileW(ofn.lpstrFile))
634  {
635  /* Try again */
636  lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
637  }
638  }
640 
641  if (lResult != ERROR_SUCCESS)
642  {
643  /*
644  * If we are here, it's because RegSaveKeyW has failed for any reason.
645  * The problem is that even if it has failed, it has created or
646  * replaced the exported hive file with a new empty file. We don't
647  * want to keep this file, so we delete it.
648  */
649  DeleteFileW(ofn.lpstrFile);
650  }
651 
652  /* Close the subkey */
653  RegCloseKey(hSubKey);
654  }
655 
656  /* Set the return value */
657  bRet = (lResult == ERROR_SUCCESS);
658 
659  /* Display error, if any */
660  if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
661 
662  break;
663  }
664 
665  case 1: /* Windows Registry Editor Version 5.00 */
666  case 3: /* REGEDIT4 */
667  default: /* All files ==> use Windows Registry Editor Version 5.00 */
668  {
669  if (!export_registry_key(ofn.lpstrFile, ExportKeyPath,
670  (ofn.nFilterIndex == 3 ? REG_FORMAT_4
671  : REG_FORMAT_5)))
672  {
673  /* Error creating the file */
674  LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
675  LoadStringW(hInst, IDS_EXPORT_ERROR, szText, COUNT_OF(szText));
676  InfoMessageBox(hWnd, MB_OK | MB_ICONERROR, szTitle, szText, ofn.lpstrFile);
677  bRet = FALSE;
678  }
679  else
680  {
681  bRet = TRUE;
682  }
683 
684  break;
685  }
686  }
687  }
688  else
689  {
690  CheckCommDlgError(hWnd);
691  }
692 
693  return bRet;
694 }
#define OFN_EXPLORER
Definition: commdlg.h:104
#define TRUE
Definition: types.h:120
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode,...)
Definition: error.c:24
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define ERROR_SUCCESS
Definition: deptool.c:10
LPARAM lCustData
Definition: commdlg.h:346
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SE_BACKUP_NAME
HWND hTreeWnd
Definition: main.h:60
OPENFILENAME ofn
Definition: main.cpp:37
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
Definition: error.c:51
LPCSTR lpTemplateName
Definition: commdlg.h:348
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define GetSaveFileName
Definition: commdlg.h:666
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:347
static const WCHAR szText[]
Definition: dialog.c:139
long LONG
Definition: pedump.c:60
#define IDS_EXPORT_REG_FILE
Definition: resource.h:133
#define _MAX_PATH
Definition: utility.h:77
#define OFN_ENABLEHOOK
Definition: commdlg.h:99
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define OFN_ENABLETEMPLATE
Definition: commdlg.h:102
static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:532
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:321
smooth NULL
Definition: ftsmooth.c:416
#define IDD_EXPORTRANGE
Definition: resource.h:41
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define COUNT_OF(a)
Definition: main.h:33
LONG WINAPI RegSaveKeyW(HKEY hKey, LPCWSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: reg.c:4649
unsigned int BOOL
Definition: ntddk_ex.h:94
#define REG_FORMAT_5
Definition: regproc.h:24
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:36
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:197
#define MB_ICONERROR
Definition: winuser.h:781
HINSTANCE hInst
Definition: dxdiag.c:13
LPSTR lpstrFile
Definition: commdlg.h:336
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define REG_FORMAT_4
Definition: regproc.h:25
#define MB_OK
Definition: winuser.h:784
BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
Definition: regproc.c:1310
#define IDS_APP_TITLE
Definition: resource.h:10
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define IDS_EXPORT_ERROR
Definition: resource.h:198
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
DWORD nFilterIndex
Definition: commdlg.h:335
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn)
Definition: framewnd.c:264
#define LPARAM
Definition: msvc.h:38
DWORD Flags
Definition: commdlg.h:342
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:1588

◆ FindDialog()

void FindDialog ( HWND  hWnd)

Definition at line 813 of file find.c.

Referenced by _CmdWndProc(), ChildWnd_CmdWndProc(), and FindNext().

814 {
816  hWnd, FindDialogProc, 0) != 0)
817  {
818  if (!FindNext(hWnd))
819  {
820  WCHAR msg[128], caption[128];
821 
823  LoadStringW(hInst, IDS_APP_TITLE, caption, COUNT_OF(caption));
824  MessageBoxW(0, msg, caption, MB_ICONINFORMATION);
825  }
826  }
827 }
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
char caption[64]
Definition: dialog.c:2033
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL FindNext(HWND hWnd)
Definition: find.c:631
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
UINT msg
Definition: msvc.h:92
smooth NULL
Definition: ftsmooth.c:416
#define COUNT_OF(a)
Definition: main.h:33
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define IDD_FIND
Definition: resource.h:50
static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: find.c:698
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define IDS_FINISHEDFIND
Definition: resource.h:200
HINSTANCE hInst
Definition: dxdiag.c:13
#define GetModuleHandle
Definition: winbase.h:3641
#define IDS_APP_TITLE
Definition: resource.h:10
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

◆ FindNext()

BOOL FindNext ( HWND  hWnd)

Definition at line 631 of file find.c.

Referenced by _CmdWndProc(), and FindDialog().

632 {
633  HKEY hKeyRoot;
634  LPCWSTR pszKeyPath;
635  BOOL fSuccess;
636  WCHAR szFullKey[512];
637  LPCWSTR pszValueName;
638  LPWSTR pszFoundSubKey, pszFoundValueName;
639 
640  if (wcslen(s_szFindWhat) == 0)
641  {
642  FindDialog(hWnd);
643  return TRUE;
644  }
645 
647 
648  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
649  if (pszKeyPath == NULL)
650  {
651  hKeyRoot = HKEY_CLASSES_ROOT;
652  pszKeyPath = s_empty;
653  }
654 
655  /* Create abort find dialog */
658  if (s_hwndAbortDialog)
659  {
662  }
663  s_bAbort = FALSE;
664 
665  pszValueName = GetValueName(g_pChildWnd->hListWnd, -1);
666 
671 
672  fSuccess = RegFindWalk(&hKeyRoot, pszKeyPath, pszValueName,
673  &pszFoundSubKey, &pszFoundValueName);
674 
679 
680  if (s_hwndAbortDialog)
681  {
684  }
685 
686  if (fSuccess)
687  {
688  GetKeyName(szFullKey, COUNT_OF(szFullKey), hKeyRoot, pszFoundSubKey);
689  SelectNode(g_pChildWnd->hTreeWnd, szFullKey);
690  SetValueName(g_pChildWnd->hListWnd, pszFoundValueName);
691  free(pszFoundSubKey);
692  free(pszFoundValueName);
694  }
695  return fSuccess || s_bAbort;
696 }
#define TRUE
Definition: types.h:120
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
static WCHAR s_szFindWhat[256]
Definition: find.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HWND s_hwndAbortDialog
Definition: find.c:30
#define free
Definition: debug_ros.c:5
HWND hTreeWnd
Definition: main.h:60
HWND hListWnd
Definition: main.h:61
BOOL WINAPI UpdateWindow(_In_ HWND)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define IDD_FINDING
Definition: resource.h:51
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI DestroyWindow(_In_ HWND)
static const WCHAR s_empty[]
Definition: find.c:36
VOID SetValueName(HWND hwndLV, LPCWSTR pszValueName)
Definition: listview.c:84
LPCWSTR GetValueName(HWND hwndLV, int iStartAt)
Definition: listview.c:55
static DWORD GetFindFlags(void)
Definition: find.c:556
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define SW_SHOW
Definition: winuser.h:769
static DWORD s_dwFlags
Definition: find.c:33
#define COUNT_OF(a)
Definition: main.h:33
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4150
static BOOL s_bAbort
Definition: find.c:31
void FindDialog(HWND hWnd)
Definition: find.c:813
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND hFrameWnd
Definition: main.c:30
#define GetModuleHandle
Definition: winbase.h:3641
BOOL RegFindWalk(HKEY *phKey, LPCWSTR pszSubKey, LPCWSTR pszValueName, LPWSTR *ppszFoundSubKey, LPWSTR *ppszFoundValueName)
Definition: find.c:356
HWND hAddressBarWnd
Definition: main.h:62
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:665
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static INT_PTR CALLBACK AbortFindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: find.c:603
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:1588

◆ FrameWndProc()

LRESULT CALLBACK FrameWndProc ( HWND  ,
UINT  ,
WPARAM  ,
LPARAM   
)

Definition at line 1304 of file framewnd.c.

1305 {
1306  switch (message)
1307  {
1308  case WM_CREATE:
1309  // For now, the Help dialog item is disabled because of lacking of HTML Help support
1313  hWnd, (HMENU)0, hInst, 0);
1314  break;
1315  case WM_COMMAND:
1318  break;
1319  case WM_ACTIVATE:
1320  if (LOWORD(hWnd) && g_pChildWnd)
1322  break;
1323  case WM_SIZE:
1325  break;
1326  case WM_TIMER:
1327  break;
1328  case WM_INITMENU:
1329  OnInitMenu(hWnd);
1330  break;
1331  case WM_ENTERMENULOOP:
1333  break;
1334  case WM_EXITMENULOOP:
1336  break;
1337  case WM_MENUSELECT:
1339  break;
1340  case WM_SYSCOLORCHANGE:
1341  /* Forward WM_SYSCOLORCHANGE to common controls */
1344  break;
1345  case WM_DESTROY:
1347  SaveSettings();
1348  PostQuitMessage(0);
1349  default:
1351  }
1352  return 0;
1353 }
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1608
Definition: tftpd.h:59
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define MF_BYCOMMAND
Definition: winuser.h:202
static void OnExitMenuLoop(HWND hWnd)
Definition: framewnd.c:135
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:61
#define HELP_QUIT
Definition: winuser.h:2368
HWND hTreeWnd
Definition: main.h:60
HWND hListWnd
Definition: main.h:61
HWND hWnd
Definition: settings.c:17
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
Definition: framewnd.c:143
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WS_CHILD
Definition: pedump.c:617
#define ID_HELP_HELPTOPICS
Definition: resource.h:76
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
void SaveSettings(void)
Definition: settings.c:113
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_ENTERMENULOOP
Definition: winuser.h:1780
#define WM_MENUSELECT
Definition: winuser.h:1723
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WM_EXITMENULOOP
Definition: winuser.h:1781
smooth NULL
Definition: ftsmooth.c:416
#define WM_DESTROY
Definition: winuser.h:1591
static void OnEnterMenuLoop(HWND hWnd)
Definition: framewnd.c:123
#define WM_SIZE
Definition: winuser.h:1593
HWND hWnd
Definition: main.h:59
#define WM_TIMER
Definition: winuser.h:1718
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1029
static void OnInitMenu(HWND hWnd)
Definition: framewnd.c:71
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:40
#define WM_COMMAND
Definition: winuser.h:1716
HINSTANCE hInst
Definition: dxdiag.c:13
#define WM_INITMENU
Definition: winuser.h:1721
#define WM_ACTIVATE
Definition: winuser.h:1594
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPCWSTR getAppName(void)
Definition: regedit.c:61
BOOL WINAPI WinHelpW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_ UINT, _In_ ULONG_PTR)
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
#define MF_GRAYED
Definition: winuser.h:129
#define WS_VISIBLE
Definition: pedump.c:620
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

◆ get_root_key_name()

LPCWSTR get_root_key_name ( HKEY  hRootKey)

Definition at line 29 of file childwnd.c.

Referenced by SaveSettings(), and UpdateAddress().

30 {
31  if (hRootKey == HKEY_CLASSES_ROOT) return L"HKEY_CLASSES_ROOT";
32  if (hRootKey == HKEY_CURRENT_USER) return L"HKEY_CURRENT_USER";
33  if (hRootKey == HKEY_LOCAL_MACHINE) return L"HKEY_LOCAL_MACHINE";
34  if (hRootKey == HKEY_USERS) return L"HKEY_USERS";
35  if (hRootKey == HKEY_CURRENT_CONFIG) return L"HKEY_CURRENT_CONFIG";
36  if (hRootKey == HKEY_DYN_DATA) return L"HKEY_DYN_DATA";
37 
38  return L"UNKNOWN HKEY, PLEASE REPORT";
39 }
#define HKEY_USERS
Definition: winreg.h:13
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_DYN_DATA
Definition: winreg.h:16
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
static const WCHAR L[]
Definition: oid.c:1087
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ getAppName()

◆ GetItemPath()

LPCWSTR GetItemPath ( HWND  hwndTV,
HTREEITEM  hItem,
HKEY phRootKey 
)

Definition at line 83 of file treeview.c.

Referenced by _CmdWndProc(), ChildWnd_CmdWndProc(), ChildWndProc(), CreateNewKey(), ExportRegistryFile(), FindNext(), ImportRegistryFile(), ListWndNotifyProc(), LoadHive(), OnTreeExpanding(), RefreshTreeItem(), SaveSettings(), UnloadHive(), UpdateAddress(), and UpdateStatusBar().

84 {
85  int pathLen = 0, maxLen;
86 
87  *phRootKey = NULL;
88  if (!pathBuffer) pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024);
89  if (!pathBuffer) return NULL;
90  *pathBuffer = 0;
91  maxLen = (int) HeapSize(GetProcessHeap(), 0, pathBuffer);
92  if (maxLen == -1) return NULL;
93  if (!hItem) hItem = TreeView_GetSelection(hwndTV);
94  if (!hItem) return NULL;
95  if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen))
96  {
97  return NULL;
98  }
99  return pathBuffer;
100 }
static LPWSTR pathBuffer
Definition: treeview.c:31
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY *phKey, LPWSTR *pKeyPath, int *pPathLen, int *pMaxLen)
Definition: treeview.c:35
smooth NULL
Definition: ftsmooth.c:416
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3440
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

◆ GetKeyName()

BOOL GetKeyName ( LPWSTR  pszDest,
size_t  iDestLength,
HKEY  hRootKey,
LPCWSTR  lpSubKey 
)

Definition at line 1588 of file edit.c.

Referenced by CopyKeyName(), ExportRegistryFile(), FindNext(), and ScControl().

1589 {
1590  LPCWSTR pszRootKey;
1591 
1592  if (hRootKey == HKEY_CLASSES_ROOT)
1593  pszRootKey = L"HKEY_CLASSES_ROOT";
1594  else if (hRootKey == HKEY_CURRENT_USER)
1595  pszRootKey = L"HKEY_CURRENT_USER";
1596  else if (hRootKey == HKEY_LOCAL_MACHINE)
1597  pszRootKey = L"HKEY_LOCAL_MACHINE";
1598  else if (hRootKey == HKEY_USERS)
1599  pszRootKey = L"HKEY_USERS";
1600  else if (hRootKey == HKEY_CURRENT_CONFIG)
1601  pszRootKey = L"HKEY_CURRENT_CONFIG";
1602  else if (hRootKey == HKEY_DYN_DATA)
1603  pszRootKey = L"HKEY_DYN_DATA";
1604  else
1605  return FALSE;
1606 
1607  if (lpSubKey[0])
1608  _snwprintf(pszDest, iDestLength, L"%s\\%s", pszRootKey, lpSubKey);
1609  else
1610  _snwprintf(pszDest, iDestLength, L"%s", pszRootKey);
1611  return TRUE;
1612 }
#define HKEY_USERS
Definition: winreg.h:13
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define HKEY_DYN_DATA
Definition: winreg.h:16
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
static const WCHAR L[]
Definition: oid.c:1087
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ GetValueName()

LPCWSTR GetValueName ( HWND  hwndLV,
int  iStartAt 
)

Definition at line 55 of file listview.c.

Referenced by _CmdWndProc(), and FindNext().

56 {
57  int item;
58  LVITEMW LVItem;
59  PLINE_INFO lineinfo;
60 
61  /*
62  if a new item is inserted, then no allocation,
63  otherwise the heap block will be lost!
64  */
65  item = ListView_GetNextItem(hwndLV, iStartAt, LVNI_SELECTED);
66  if (item == -1) return NULL;
67 
68  /*
69  Should be always TRUE anyways
70  */
71  LVItem.iItem = item;
72  LVItem.iSubItem = 0;
73  LVItem.mask = LVIF_PARAM;
74  if (ListView_GetItem(hwndLV, &LVItem) == FALSE)
75  return NULL;
76 
77  lineinfo = (PLINE_INFO)LVItem.lParam;
78  if (lineinfo == NULL)
79  return NULL;
80 
81  return lineinfo->name;
82 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
#define LVNI_SELECTED
Definition: commctrl.h:2394
struct tagLINE_INFO * PLINE_INFO
int iSubItem
Definition: commctrl.h:2332
LPARAM lParam
Definition: commctrl.h:2338
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:717
UINT mask
Definition: commctrl.h:2330
LPWSTR name
Definition: listview.c:34
static ATOM item
Definition: dde.c:856
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2364
#define LVIF_PARAM
Definition: commctrl.h:2281

◆ InfoMessageBox()

int InfoMessageBox ( HWND  hWnd,
UINT  uType,
LPCWSTR  lpTitle,
LPCWSTR  lpMessage,
  ... 
)

Definition at line 51 of file error.c.

Referenced by CreateNewKey(), ExportRegistryFile(), ImportRegistryFile(), PerformRegAction(), and ProcessCmdLine().

52 {
53  int iRet = 0;
54  LPWSTR lpMsgBuf = NULL;
55  va_list args;
56 
57  va_start(args, lpMessage);
58 
59  if (lpMessage)
60  {
61  SIZE_T strLen = _vscwprintf(lpMessage, args);
62 
63  /* Create a buffer on the heap and zero it out (LPTR) */
64  lpMsgBuf = (LPWSTR)LocalAlloc(LPTR, (strLen + 1) * sizeof(WCHAR));
65  if (lpMsgBuf)
66  {
67  _vsnwprintf(lpMsgBuf, strLen, lpMessage, args);
68  }
69  }
70 
71  va_end(args);
72 
73  iRet = MessageBoxW(hWnd, (lpMessage && lpMsgBuf ? lpMsgBuf : L"Error displaying info message."), lpTitle, uType);
74 
75  if (lpMsgBuf) LocalFree(lpMsgBuf);
76 
77  /* Return the MessageBoxW information */
78  return iRet;
79 }
#define WCHAR
Definition: msvc.h:43
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
static const WCHAR L[]
Definition: oid.c:1087
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_Check_return_ _CRTIMP int __cdecl _vscwprintf(_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
_CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest, size_t _Count, const wchar_t *_Format, va_list _Args)
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define va_start(ap, A)
Definition: acmsvcex.h:91
TCHAR lpTitle[80]
Definition: ctm.c:67
#define LPTR
Definition: winbase.h:362
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define args
Definition: format.c:66

◆ InsertNode()

HTREEITEM InsertNode ( HWND  hwndTV,
HTREEITEM  hItem,
LPWSTR  name 
)

Definition at line 331 of file treeview.c.

Referenced by CreateNewKey().

332 {
334  HTREEITEM hNewItem = 0;
335  TVITEMEXW item;
336 
337  /* Default to the current selection */
338  if (!hItem)
339  {
340  hItem = TreeView_GetSelection(hwndTV);
341  if (!hItem)
342  return FALSE;
343  }
344 
345  memset(&item, 0, sizeof(item));
346  item.hItem = hItem;
348  if (!TreeView_GetItem(hwndTV, &item))
349  return FALSE;
350 
351  if ((item.state & TVIS_EXPANDEDONCE) && (item.cChildren > 0))
352  {
353  hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
354  SendMessageW(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
355  }
356  else
357  {
358  item.mask = TVIF_CHILDREN | TVIF_HANDLE;
359  item.hItem = hItem;
360  item.cChildren = 1;
361  if (!TreeView_SetItem(hwndTV, &item))
362  return FALSE;
363  }
364 
365  (void)TreeView_Expand(hwndTV, hItem, TVE_EXPAND);
366  if (!hNewItem)
367  {
368  for(hNewItem = TreeView_GetChild(hwndTV, hItem); hNewItem; hNewItem = TreeView_GetNextSibling(hwndTV, hNewItem))
369  {
370  item.mask = TVIF_HANDLE | TVIF_TEXT;
371  item.hItem = hNewItem;
372  item.pszText = buf;
373  item.cchTextMax = COUNT_OF(buf);
374  if (!TreeView_GetItem(hwndTV, &item)) continue;
375  if (wcscmp(name, item.pszText) == 0) break;
376  }
377  }
378  if (hNewItem) (void)TreeView_SelectItem(hwndTV, hNewItem);
379 
380  return hNewItem;
381 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define TVM_SORTCHILDREN
Definition: commctrl.h:3508
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3433
LPWSTR pszText
Definition: commctrl.h:3317
#define TVIS_EXPANDEDONCE
Definition: commctrl.h:3252
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3434
static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPWSTR label, HKEY hKey, DWORD dwChildren)
Definition: treeview.c:110
#define TVIF_CHILDREN
Definition: commctrl.h:3239
LONG_PTR LPARAM
Definition: windef.h:208
HTREEITEM hItem
Definition: treelist.h:37
#define COUNT_OF(a)
Definition: main.h:33
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3440
#define TVE_EXPAND
Definition: commctrl.h:3390
int cchTextMax
Definition: commctrl.h:3318
#define TVIF_HANDLE
Definition: commctrl.h:3237
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
HTREEITEM hItem
Definition: commctrl.h:3314
static ATOM item
Definition: dde.c:856
#define TVIF_TEXT
Definition: commctrl.h:3233
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3448
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3464
Definition: name.c:36
#define TVIF_STATE
Definition: commctrl.h:3236
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3387
#define memset(x, y, z)
Definition: compat.h:39
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3457
#define MAX_NEW_KEY_LEN
Definition: main.h:40

◆ IsDefaultValue()

BOOL IsDefaultValue ( HWND  hwndLV,
int  i 
)

Definition at line 107 of file listview.c.

Referenced by ChildWndProc().

108 {
109  PLINE_INFO lineinfo;
110  LVITEMW Item;
111 
112  Item.mask = LVIF_PARAM;
113  Item.iItem = i;
114  if(ListView_GetItem(hwndLV, &Item))
115  {
116  lineinfo = (PLINE_INFO)Item.lParam;
117  return lineinfo && (!lineinfo->name || !wcscmp(lineinfo->name, L""));
118  }
119  return FALSE;
120 }
struct tagLINE_INFO * PLINE_INFO
GLenum GLclampf GLint i
Definition: glfuncs.h:14
LPARAM lParam
Definition: commctrl.h:2338
UINT mask
Definition: commctrl.h:2330
static const WCHAR L[]
Definition: oid.c:1087
LPWSTR name
Definition: listview.c:34
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2364
#define LVIF_PARAM
Definition: commctrl.h:2281

◆ ListWndNotifyProc()

BOOL ListWndNotifyProc ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam,
BOOL Result 
)

Definition at line 543 of file listview.c.

Referenced by ChildWndProc().

544 {
546  int iSortingColumn;
548  *Result = TRUE;
549  switch (((LPNMHDR)lParam)->code)
550  {
551  case LVN_GETDISPINFO:
552  OnGetDispInfo((NMLVDISPINFO*)lParam);
553  return TRUE;
554  case LVN_COLUMNCLICK:
555  iSortingColumn = ((LPNMLISTVIEW)lParam)->iSubItem;
556  (void)ListView_Sort(hWnd, iSortingColumn, g_iSortedColumn);
557  g_iSortedColumn = iSortingColumn;
558  return TRUE;
559  case NM_DBLCLK:
560  case NM_RETURN:
561  {
563  }
564  return TRUE;
565  case NM_SETFOCUS:
567  break;
568  case LVN_BEGINLABELEDIT:
569  Info = (NMLVDISPINFO*)lParam;
570  if(Info)
571  {
572  PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
573  if(!lineinfo->name || !wcscmp(lineinfo->name, L""))
574  {
575  *Result = TRUE;
576  }
577  else
578  {
579  *Result = FALSE;
580  }
581  }
582  else
583  *Result = TRUE;
584  return TRUE;
585  case LVN_ENDLABELEDIT:
586  Info = (NMLVDISPINFO*)lParam;
587  if(Info && Info->item.pszText)
588  {
589  PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
590  if(!lineinfo->name || !wcscmp(lineinfo->name, L""))
591  {
592  *Result = FALSE;
593  }
594  else
595  {
596  if(wcslen(Info->item.pszText) == 0)
597  {
598  WCHAR msg[128], caption[128];
599 
601  LoadStringW(hInst, IDS_ERR_RENVAL_CAPTION, caption, COUNT_OF(caption));
602  MessageBoxW(0, msg, caption, 0);
603  *Result = TRUE;
604  }
605  else
606  {
607  HKEY hKeyRoot;
608  LPCWSTR keyPath;
609  LONG lResult;
610 
611  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
612  lResult = RenameValue(hKeyRoot, keyPath, Info->item.pszText, lineinfo->name);
613  lineinfo->name = realloc(lineinfo->name, (wcslen(Info->item.pszText)+1)*sizeof(WCHAR));
614  if (lineinfo->name != NULL)
615  wcscpy(lineinfo->name, Info->item.pszText);
616 
617  *Result = TRUE;
618  return (lResult == ERROR_SUCCESS);
619  }
620  }
621  }
622  else
623  *Result = TRUE;
624 
625  return TRUE;
626  }
627  return FALSE;
628 }
#define realloc
Definition: debug_ros.c:6
#define TRUE
Definition: types.h:120
#define LVN_BEGINLABELEDIT
Definition: commctrl.h:3128
#define MAKEWPARAM(l, h)
Definition: winuser.h:3916
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
char caption[64]
Definition: dialog.c:2033
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hTreeWnd
Definition: main.h:60
LONG RenameValue(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpDestValue, LPCWSTR lpSrcValue)
Definition: edit.c:1522
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static void OnGetDispInfo(NMLVDISPINFO *plvdi)
Definition: listview.c:312
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
WPARAM wParam
Definition: combotst.c:138
struct TraceInfo Info
struct tagLINE_INFO * PLINE_INFO
long LONG
Definition: pedump.c:60
UINT msg
Definition: msvc.h:92
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define NMLVDISPINFO
Definition: commctrl.h:3149
#define COUNT_OF(a)
Definition: main.h:33
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define NM_SETFOCUS
Definition: commctrl.h:135
#define IDS_ERR_RENVAL_TOEMPTY
Definition: resource.h:141
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define IDS_ERR_RENVAL_CAPTION
Definition: resource.h:140
static const WCHAR L[]
Definition: oid.c:1087
#define WM_COMMAND
Definition: winuser.h:1716
LPWSTR name
Definition: listview.c:34
#define LVN_GETDISPINFO
Definition: commctrl.h:3130
static INT g_iSortedColumn
Definition: listview.c:49
#define ID_EDIT_MODIFY
Definition: resource.h:64
#define NM_RETURN
Definition: commctrl.h:132
HWND hFrameWnd
Definition: main.c:30
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
HINSTANCE hInst
Definition: dxdiag.c:13
static BOOL ListView_Sort(HWND hListView, int iSortingColumn, int iSortedColumn)
Definition: listview.c:479
#define NM_DBLCLK
Definition: commctrl.h:131
struct tagNMLISTVIEW * LPNMLISTVIEW
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LVN_COLUMNCLICK
Definition: commctrl.h:3109
#define LVN_ENDLABELEDIT
Definition: commctrl.h:3129
LPARAM lParam
Definition: combotst.c:139
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
int nFocusPanel
Definition: main.h:64

◆ LoadSettings()

void LoadSettings ( void  )

Definition at line 53 of file settings.c.

54 {
55  HKEY hKey = NULL;
56  int iItemIndex = -1;
57 
59  {
60  TCHAR szBuffer[MAX_PATH];
61  DWORD dwAdvancedChecked;
62  unsigned long type = REG_DWORD, size = 1024;
63 
64  /* Restore last selected font */
65  if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("Font"), szBuffer, (sizeof(szBuffer)/sizeof(szBuffer[0]))) == ERROR_SUCCESS)
66  {
67  //Get combobox handle
69 
70  //Search for match and return index if match found
71  iItemIndex = ComboBox_FindStringExact(hWnd, -1, szBuffer);
72  if(iItemIndex != CB_ERR)
73  {
74  ComboBox_SetCurSel(hWnd, iItemIndex);
76  }
77  }
78 
79  /* Restore last selected character set */
80  if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("CodePage"), szBuffer, (sizeof(szBuffer)/sizeof(szBuffer[0]))) == ERROR_SUCCESS)
81  {
82  //Get combobox handle
84 
85  iItemIndex = ComboBox_FindStringExact(hWnd, -1, szBuffer);
86  if(iItemIndex != CB_ERR)
87  {
88  ComboBox_SetCurSel(hWnd, iItemIndex);
89  }
90  }
91 
92  RegQueryValueEx(hKey, _T("Advanced"), NULL, &type, (LPBYTE)&dwAdvancedChecked, &size);
93 
94  if(dwAdvancedChecked != FALSE)
96 
97  RegCloseKey(hKey);
98  }
99  else
100  {
101  /* Default font seems to be Arial */
103 
104  iItemIndex = ComboBox_FindStringExact(hWnd, -1, _T("Arial"));
105  if(iItemIndex != CB_ERR)
106  {
107  ComboBox_SetCurSel(hWnd, iItemIndex);
109  }
110  }
111 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDC_CHECK_ADVANCED
Definition: resource.h:26
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HWND hWnd
Definition: settings.c:17
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define SendDlgItemMessage
Definition: winuser.h:5708
#define IDC_COMBO_CHARSET
Definition: resource.h:21
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ComboBox_FindStringExact(hwndCtl, indexStart, lpszFind)
Definition: windowsx.h:22
unsigned char * LPBYTE
Definition: typedefs.h:52
const TCHAR g_szGeneralRegKey[]
Definition: settings.c:16
smooth NULL
Definition: ftsmooth.c:416
#define CB_ERR
Definition: winuser.h:2389
#define MF_CHECKED
Definition: winuser.h:132
char TCHAR
Definition: xmlstorage.h:189
#define BM_CLICK
Definition: winuser.h:1878
#define _T(x)
Definition: vfdio.h:22
GLsizeiptr size
Definition: glext.h:5919
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:41
#define IDC_FONTCOMBO
Definition: resource.h:12
VOID ChangeMapFont(HWND hDlg)
Definition: charmap.c:113
LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen)
Definition: settings.c:19
#define RegOpenKeyEx
Definition: winreg.h:520
HWND hCharmapDlg
Definition: charmap.c:22
#define REG_DWORD
Definition: sdbapi.c:539

◆ ModifyValue()

BOOL ModifyValue ( HWND  hwnd,
HKEY  hKey,
LPCWSTR  valueName,
BOOL  EditBin 
)

Definition at line 1072 of file edit.c.

Referenced by _CmdWndProc().

1073 {
1074  DWORD type;
1075  LONG lRet;
1076  BOOL result = FALSE;
1077 
1078  if (!hKey)
1079  return FALSE;
1080 
1081  editValueName = valueName;
1082 
1083  lRet = RegQueryValueExW(hKey, valueName, 0, &type, 0, &valueDataLen);
1084  if (lRet != ERROR_SUCCESS && (valueName == NULL || !valueName[0]))
1085  {
1086  lRet = ERROR_SUCCESS; /* Allow editing of (Default) values which don't exist */
1087  type = REG_SZ;
1088  valueDataLen = 0;
1090  binValueData = NULL;
1091  }
1092 
1093  if (lRet != ERROR_SUCCESS)
1094  {
1095  error(hwnd, IDS_BAD_VALUE, valueName);
1096  goto done;
1097  }
1098 
1099  if (EditBin == FALSE && ((type == REG_SZ) || (type == REG_EXPAND_SZ)))
1100  {
1101  if (valueDataLen > 0)
1102  {
1104  {
1106  goto done;
1107  }
1108  lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)stringValueData, &valueDataLen);
1109  if (lRet != ERROR_SUCCESS)
1110  {
1111  error(hwnd, IDS_BAD_VALUE, valueName);
1112  goto done;
1113  }
1114  }
1115  else
1116  {
1118  }
1119 
1121  {
1122  if (stringValueData)
1123  {
1124  lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)stringValueData, (DWORD) (wcslen(stringValueData) + 1) * sizeof(WCHAR));
1125  }
1126  else
1127  {
1128  lRet = RegSetValueExW(hKey, valueName, 0, type, NULL, 0);
1129  }
1130  if (lRet == ERROR_SUCCESS)
1131  result = TRUE;
1132  }
1133  }
1134  else if (EditBin == FALSE && type == REG_MULTI_SZ)
1135  {
1136  if (valueDataLen > 0)
1137  {
1138  size_t llen, listlen, nl_len;
1139  LPWSTR src, lines = NULL;
1140 
1141  if (!(stringValueData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, valueDataLen + sizeof(WCHAR))))
1142  {
1144  goto done;
1145  }
1146  lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)stringValueData, &valueDataLen);
1147  if (lRet != ERROR_SUCCESS)
1148  {
1149  error(hwnd, IDS_BAD_VALUE, valueName);
1150  goto done;
1151  }
1152 
1153  /* convert \0 to \r\n */
1154  src = stringValueData;
1155  nl_len = wcslen(L"\r\n") * sizeof(WCHAR);
1156  listlen = sizeof(WCHAR);
1157  lines = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, listlen + sizeof(WCHAR));
1158  while(*src != L'\0')
1159  {
1160  llen = wcslen(src);
1161  if(llen == 0)
1162  break;
1163  listlen += (llen * sizeof(WCHAR)) + nl_len;
1164  lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, listlen);
1165  wcscat(lines, src);
1166  wcscat(lines, L"\r\n");
1167  src += llen + 1;
1168  }
1169  HeapFree(GetProcessHeap(), 0, stringValueData);
1170  stringValueData = lines;
1171  }
1172  else
1173  {
1174  stringValueData = NULL;
1175  }
1176 
1178  {
1179  if (stringValueData)
1180  {
1181  /* convert \r\n to \0 */
1182  BOOL EmptyLines = FALSE;
1183  LPWSTR src, lines, nl;
1184  size_t linechars, buflen, c_nl, dest;
1185 
1186  src = stringValueData;
1187  buflen = sizeof(WCHAR);
1188  lines = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen + sizeof(WCHAR));
1189  c_nl = wcslen(L"\r\n");
1190  dest = 0;
1191  while(*src != L'\0')
1192  {
1193  if((nl = wcsstr(src, L"\r\n")))
1194  {
1195  linechars = nl - src;
1196  if(nl == src)
1197  {
1198  EmptyLines = TRUE;
1199  src = nl + c_nl;
1200  continue;
1201  }
1202  }
1203  else
1204  {
1205  linechars = wcslen(src);
1206  }
1207  if(linechars > 0)
1208  {
1209  buflen += ((linechars + 1) * sizeof(WCHAR));
1210  lines = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lines, buflen);
1211  memcpy((lines + dest), src, linechars * sizeof(WCHAR));
1212  dest += linechars;
1213  lines[dest++] = L'\0';
1214  }
1215  else
1216  {
1217  EmptyLines = TRUE;
1218  }
1219  src += linechars + (nl != NULL ? c_nl : 0);
1220  }
1221  lines[++dest] = L'\0';
1222 
1223  if(EmptyLines)
1224  {
1226  }
1227 
1228  lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)lines, (DWORD) buflen);
1229  HeapFree(GetProcessHeap(), 0, lines);
1230  }
1231  else
1232  {
1233  lRet = RegSetValueExW(hKey, valueName, 0, type, NULL, 0);
1234  }
1235  if (lRet == ERROR_SUCCESS)
1236  result = TRUE;
1237  }
1238  }
1239  else if (EditBin == FALSE && type == REG_DWORD)
1240  {
1241  lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)&dwordValueData, &valueDataLen);
1242  if (lRet != ERROR_SUCCESS)
1243  {
1244  error(hwnd, IDS_BAD_VALUE, valueName);
1245  goto done;
1246  }
1247 
1249  {
1250  lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)&dwordValueData, sizeof(DWORD));
1251  if (lRet == ERROR_SUCCESS)
1252  result = TRUE;
1253  }
1254  }
1255  else if (EditBin == FALSE && type == REG_RESOURCE_LIST)
1256  {
1257  if (valueDataLen > 0)
1258  {
1260  if (resourceValueData == NULL)
1261  {
1263  goto done;
1264  }
1265 
1266  lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)resourceValueData, &valueDataLen);
1267  if (lRet != ERROR_SUCCESS)
1268  {
1269  error(hwnd, IDS_BAD_VALUE, valueName);
1270  goto done;
1271  }
1272  }
1273  else
1274  {
1276  }
1277 
1279  {
1280  }
1281  }
1282  else if (EditBin == FALSE && type == REG_FULL_RESOURCE_DESCRIPTOR)
1283  {
1284  if (valueDataLen > 0)
1285  {
1287  if (resourceValueData == NULL)
1288  {
1290  goto done;
1291  }
1292 
1293  lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)&resourceValueData->List[0], &valueDataLen);
1294  if (lRet != ERROR_SUCCESS)
1295  {
1296  error(hwnd, IDS_BAD_VALUE, valueName);
1297  goto done;
1298  }
1299 
1300  resourceValueData->Count = 1;
1301  fullResourceIndex = 0;
1302  }
1303  else
1304  {
1306  }
1307 
1309  {
1310  }
1311  }
1312  else if ((EditBin != FALSE) || (type == REG_NONE) || (type == REG_BINARY))
1313  {
1314  if(valueDataLen > 0)
1315  {
1317  {
1319  goto done;
1320  }
1321 
1322  /* Use the unicode version, so editing strings in binary mode is correct */
1323  lRet = RegQueryValueExW(hKey, valueName,
1324  0, 0, (LPBYTE)binValueData, &valueDataLen);
1325  if (lRet != ERROR_SUCCESS)
1326  {
1328  error(hwnd, IDS_BAD_VALUE, valueName);
1329  goto done;
1330  }
1331  }
1332  else
1333  {
1334  binValueData = NULL;
1335  }
1336 
1338  {
1339  /* Use the unicode version, so editing strings in binary mode is correct */
1340  lRet = RegSetValueExW(hKey, valueName,
1341  0, type, (LPBYTE)binValueData, valueDataLen);
1342  if (lRet == ERROR_SUCCESS)
1343  result = TRUE;
1344  }
1345  if(binValueData != NULL)
1347  }
1348  else
1349  {
1350  error(hwnd, IDS_UNSUPPORTED_TYPE, type);
1351  }
1352 
1353 done:
1354  if (resourceValueData)
1357 
1358  if (stringValueData)
1359  HeapFree(GetProcessHeap(), 0, stringValueData);
1360  stringValueData = NULL;
1361 
1362  return result;
1363 }
static INT_PTR CALLBACK modify_resource_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: edit.c:918
void error(HWND hwnd, INT resId,...)
Definition: edit.c:42
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDD_EDIT_BIN_DATA
Definition: resource.h:257
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: hwresource.cpp:165
#define REG_BINARY
Definition: nt_native.h:1496
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define IDD_EDIT_RESOURCE
Definition: resource.h:279
static INT fullResourceIndex
Definition: edit.c:38
#define IDD_EDIT_STRING
Definition: resource.h:248
INT_PTR CALLBACK modify_multi_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: edit.c:165
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static const WCHAR * editValueName
Definition: edit.c:33
#define WCHAR
Definition: msvc.h:43
static DWORD valueDataLen
Definition: edit.c:39
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
static PVOID binValueData
Definition: edit.c:35
static INT_PTR CALLBACK modify_resource_list_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: edit.c:1039
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
#define IDS_MULTI_SZ_EMPTY_STRING
Definition: resource.h:126
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define IDD_EDIT_RESOURCE_LIST
Definition: resource.h:275
smooth NULL
Definition: ftsmooth.c:416
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
#define REG_FULL_RESOURCE_DESCRIPTOR
Definition: nt_native.h:1503
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4268
static PCM_RESOURCE_LIST resourceValueData
Definition: edit.c:37
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
#define IDS_TOO_BIG_VALUE
Definition: resource.h:123
GLfloat CONST GLvector4f CONST GLfloat GLvector4f * dest
Definition: m_xform.h:122
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_BAD_VALUE
Definition: resource.h:11
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: edit.c:96
INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: edit.c:388
#define IDD_EDIT_MULTI_STRING
Definition: resource.h:256
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define HeapReAlloc
Definition: compat.h:393
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static WCHAR * stringValueData
Definition: edit.c:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define IDS_UNSUPPORTED_TYPE
Definition: resource.h:122
unsigned int ULONG
Definition: retypes.h:1
INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: edit.c:274
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define REG_NONE
Definition: nt_native.h:1492
void warning(HWND hwnd, INT resId,...)
Definition: edit.c:73
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDD_EDIT_DWORD
Definition: resource.h:252
GLuint64EXT * result
Definition: glext.h:11304
#define REG_DWORD
Definition: sdbapi.c:539
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
static DWORD dwordValueData
Definition: edit.c:36
#define REG_SZ
Definition: layer.c:22

◆ OnTreeExpanding()

BOOL OnTreeExpanding ( HWND  hWnd,
NMTREEVIEW pnmtv 
)

Definition at line 503 of file treeview.c.

Referenced by ChildWndProc().

504 {
505  DWORD dwCount, dwIndex, dwMaxSubKeyLen;
506  HKEY hRoot, hNewKey, hKey;
507  LPCWSTR keyPath;
508  LPWSTR Name;
509  LONG errCode;
510  HCURSOR hcursorOld;
511 
512  static int expanding;
513  if (expanding) return FALSE;
514  if (pnmtv->itemNew.state & TVIS_EXPANDEDONCE )
515  {
516  return TRUE;
517  }
518  expanding = TRUE;
519  hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
520  SendMessageW(hwndTV, WM_SETREDRAW, FALSE, 0);
521 
522  keyPath = GetItemPath(hwndTV, pnmtv->itemNew.hItem, &hRoot);
523  if (!keyPath) goto done;
524 
525  if (*keyPath)
526  {
527  errCode = RegOpenKeyExW(hRoot, keyPath, 0, KEY_READ, &hNewKey);
528  if (errCode != ERROR_SUCCESS) goto done;
529  }
530  else
531  {
532  hNewKey = hRoot;
533  }
534 
535  errCode = RegQueryInfoKeyW(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
536  if (errCode != ERROR_SUCCESS) goto done;
537  dwMaxSubKeyLen++; /* account for the \0 terminator */
538  Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR));
539  if (!Name) goto done;
540 
541  for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
542  {
543  DWORD cName = dwMaxSubKeyLen, dwSubCount;
544 
545  errCode = RegEnumKeyExW(hNewKey, dwIndex, Name, &cName, 0, 0, 0, 0);
546  if (errCode != ERROR_SUCCESS) continue;
547  errCode = RegOpenKeyExW(hNewKey, Name, 0, KEY_QUERY_VALUE, &hKey);
548  if (errCode == ERROR_SUCCESS)
549  {
550  errCode = RegQueryInfoKeyW(hKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0);
551  RegCloseKey(hKey);
552  }
553  if (errCode != ERROR_SUCCESS) dwSubCount = 0;
554  AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwSubCount);
555  }
556 
557  SendMessageW(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM)pnmtv->itemNew.hItem);
558 
559  RegCloseKey(hNewKey);
560  HeapFree(GetProcessHeap(), 0, Name);
561 
562 done:
563  SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
564  SetCursor(hcursorOld);
565  expanding = FALSE;
566 
567  return TRUE;
568 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TVM_SORTCHILDREN
Definition: commctrl.h:3508
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WM_SETREDRAW
Definition: winuser.h:1598
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TVIS_EXPANDEDONCE
Definition: commctrl.h:3252
HICON HCURSOR
Definition: windef.h:289
static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPWSTR label, HKEY hKey, DWORD dwChildren)
Definition: treeview.c:110
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
LONG_PTR LPARAM
Definition: windef.h:208
static HTREEITEM hRoot
Definition: treeview.c:381
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
#define IDC_WAIT
Definition: winuser.h:684
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3704
#define LoadCursor
Definition: winuser.h:5678
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ QueryStringValue()

LONG QueryStringValue ( HKEY  hKey,
LPCWSTR  lpSubKey,
LPCWSTR  lpValueName,
LPWSTR  pszBuffer,
DWORD  dwBufferLen 
)

Definition at line 1554 of file edit.c.

1555 {
1556  LONG lResult;
1557  HKEY hSubKey = NULL;
1558  DWORD cbData, dwType;
1559 
1560  if (lpSubKey)
1561  {
1562  lResult = RegOpenKeyW(hKey, lpSubKey, &hSubKey);
1563  if (lResult != ERROR_SUCCESS)
1564  goto done;
1565  hKey = hSubKey;
1566  }
1567 
1568  cbData = (dwBufferLen - 1) * sizeof(*pszBuffer);
1569  lResult = RegQueryValueExW(hKey, lpValueName, NULL, &dwType, (LPBYTE) pszBuffer, &cbData);
1570  if (lResult != ERROR_SUCCESS)
1571  goto done;
1572  if (dwType != REG_SZ)
1573  {
1574  lResult = -1;
1575  goto done;
1576  }
1577 
1578  pszBuffer[cbData / sizeof(*pszBuffer)] = L'\0';
1579 
1580 done:
1581  if (lResult != ERROR_SUCCESS)
1582  pszBuffer[0] = L'\0';
1583  if (hSubKey)
1584  RegCloseKey(hSubKey);
1585  return lResult;
1586 }
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
#define REG_SZ
Definition: layer.c:22

◆ RefreshListView()

BOOL RefreshListView ( HWND  hwndLV,
HKEY  hKey,
LPCWSTR  keyPath 
)

Definition at line 670 of file listview.c.

Referenced by _CmdWndProc(), CreateNewValue(), ImportRegistryFile(), LoadHive(), UnloadHive(), and UpdateAddress().

671 {
672  DWORD max_sub_key_len;
673  DWORD max_val_name_len;
674  DWORD max_val_size;
675  DWORD val_count;
676  HKEY hNewKey;
677  LONG errCode;
678  INT i, c;
679  BOOL AddedDefault = FALSE;
680 
681  if (!hwndLV) return FALSE;
682 
683  (void)ListView_EditLabel(hwndLV, -1);
684 
685  SendMessageW(hwndLV, WM_SETREDRAW, FALSE, 0);
686  DestroyListView(hwndLV);
687 
688  (void)ListView_DeleteAllItems(hwndLV);
689 
690  if(!hKey) return FALSE;
691 
692  errCode = RegOpenKeyExW(hKey, keyPath, 0, KEY_READ, &hNewKey);
693  if (errCode != ERROR_SUCCESS) return FALSE;
694 
695  /* get size information and resize the buffers if necessary */
696  errCode = RegQueryInfoKeyW(hNewKey, NULL, NULL, NULL, NULL, &max_sub_key_len, NULL,
697  &val_count, &max_val_name_len, &max_val_size, NULL, NULL);
698 
699  if (errCode == ERROR_SUCCESS)
700  {
701  WCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(WCHAR));
702  DWORD dwValNameLen = max_val_name_len;
703  BYTE* ValBuf = HeapAlloc(GetProcessHeap(), 0, max_val_size + sizeof(WCHAR));
704  DWORD dwValSize = max_val_size;
705  DWORD dwIndex = 0L;
706  DWORD dwValType;
707  /* if (RegQueryValueExW(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
708  /* AddEntryToList(hwndLV, L"(Default)", dwValType, ValBuf, dwValSize); */
709  /* } */
710  /* dwValSize = max_val_size; */
711  while (RegEnumValueW(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS)
712  {
713  /* Add a terminating 0 character. Usually this is only necessary for strings. */
714  ValBuf[dwValSize] = ValBuf[dwValSize + 1] = 0;
715 
716  AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize, -1, TRUE);
717  dwValNameLen = max_val_name_len;
718  dwValSize = max_val_size;
719  dwValType = 0L;
720  ++dwIndex;
721  if(!wcscmp(ValName, L""))
722  {
723  AddedDefault = TRUE;
724  }
725  }
726  HeapFree(GetProcessHeap(), 0, ValBuf);
727  HeapFree(GetProcessHeap(), 0, ValName);
728  }
729  RegCloseKey(hNewKey);
730 
731  if(!AddedDefault)
732  {
733  AddEntryToList(hwndLV, L"", REG_SZ, NULL, 0, 0, FALSE);
734  }
735  c = ListView_GetItemCount(hwndLV);
736  for(i = 0; i < c; i++)
737  {
739  }
743  (void)ListView_Sort(hwndLV, g_iSortedColumn, -1);
744  SendMessageW(hwndLV, WM_SETREDRAW, TRUE, 0);
745 
746  return TRUE;
747 }
#define TRUE
Definition: types.h:120
void DestroyListView(HWND hwndLV)
Definition: listview.c:653
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
INT iListViewSelect
Definition: listview.c:29
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WM_SETREDRAW
Definition: winuser.h:1598
static void AddEntryToList(HWND hwndLV, LPWSTR Name, DWORD dwValType, void *ValBuf, DWORD dwCount, int Position, BOOL ValExists)
Definition: listview.c:125
int32_t INT
Definition: typedefs.h:56
GLenum GLclampf GLint i
Definition: glfuncs.h:14
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2643
long LONG
Definition: pedump.c:60
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2867
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2289
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2277
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3704
static const WCHAR L[]
Definition: oid.c:1087
unsigned char BYTE
Definition: ntddk_ex.h:96
static INT g_iSortedColumn
Definition: listview.c:49
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static BOOL ListView_Sort(HWND hListView, int iSortingColumn, int iSortedColumn)
Definition: listview.c:479
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define c
Definition: ke_i.h:80
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define HeapFree(x, y, z)
Definition: compat.h:394
#define LVIS_FOCUSED
Definition: commctrl.h:2288
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2510
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2384
#define REG_SZ
Definition: layer.c:22

◆ RefreshTreeItem()

BOOL RefreshTreeItem ( HWND  hwndTV,
HTREEITEM  hItem 
)

Definition at line 136 of file treeview.c.

Referenced by RefreshTreeView().

137 {
138  HKEY hRoot, hKey, hSubKey;
139  HTREEITEM childItem;
140  LPCWSTR KeyPath;
141  DWORD dwCount, dwIndex, dwMaxSubKeyLen;
142  LPWSTR Name = NULL;
143  TVITEMW tvItem;
144  LPWSTR pszNodes = NULL;
145  BOOL bSuccess = FALSE;
146  LPWSTR s;
147  BOOL bAddedAny;
148 
149  KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
150 
151  if (*KeyPath)
152  {
153  if (RegOpenKeyExW(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
154  {
155  goto done;
156  }
157  }
158  else
159  {
160  hKey = hRoot;
161  }
162 
163  if (RegQueryInfoKeyW(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
164  {
165  goto done;
166  }
167 
168  /* Set the number of children again */
169  tvItem.mask = TVIF_CHILDREN;
170  tvItem.hItem = hItem;
171  tvItem.cChildren = dwCount;
172  if (!TreeView_SetItem(hwndTV, &tvItem))
173  {
174  goto done;
175  }
176 
177  /* We don't have to bother with the rest if it's not expanded. */
178  if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDED) == 0)
179  {
180  RegCloseKey(hKey);
181  bSuccess = TRUE;
182  goto done;
183  }
184 
185  dwMaxSubKeyLen++; /* account for the \0 terminator */
186  if (!(Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR))))
187  {
188  goto done;
189  }
190  tvItem.cchTextMax = dwMaxSubKeyLen;
191  /*if (!(tvItem.pszText = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR)))) {
192  goto done;
193  }*/
194 
195  /* Get all of the tree node siblings in one contiguous block of memory */
196  {
197  DWORD dwPhysicalSize = 0;
198  DWORD dwActualSize = 0;
199  DWORD dwNewPhysicalSize;
200  LPWSTR pszNewNodes;
201  DWORD dwStep = 10000;
202 
203  for (childItem = TreeView_GetChild(hwndTV, hItem); childItem;
204  childItem = TreeView_GetNextSibling(hwndTV, childItem))
205  {
206 
207  if (dwActualSize + dwMaxSubKeyLen + 1 > dwPhysicalSize)
208  {
209  dwNewPhysicalSize = dwActualSize + dwMaxSubKeyLen + 1 + dwStep;
210 
211  if (pszNodes)
212  pszNewNodes = (LPWSTR) HeapReAlloc(GetProcessHeap(), 0, pszNodes, dwNewPhysicalSize * sizeof(WCHAR));
213  else
214  pszNewNodes = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, dwNewPhysicalSize * sizeof(WCHAR));
215  if (!pszNewNodes)
216  goto done;
217 
218  dwPhysicalSize = dwNewPhysicalSize;
219  pszNodes = pszNewNodes;
220  }
221 
222  tvItem.mask = TVIF_TEXT;
223  tvItem.hItem = childItem;
224  tvItem.pszText = &pszNodes[dwActualSize];
225  tvItem.cchTextMax = dwPhysicalSize - dwActualSize;
226  if (!TreeView_GetItem(hwndTV, &tvItem))
227  goto done;
228 
229  dwActualSize += (DWORD) wcslen(&pszNodes[dwActualSize]) + 1;
230  }
231 
232  if (pszNodes)
233  pszNodes[dwActualSize] = L'\0';
234  }
235 
236  /* Now go through all the children in the tree, and check if any have to be removed. */
237  childItem = TreeView_GetChild(hwndTV, hItem);
238  while (childItem)
239  {
240  HTREEITEM nextItem = TreeView_GetNextSibling(hwndTV, childItem);
241  if (RefreshTreeItem(hwndTV, childItem) == FALSE)
242  {
243  (void)TreeView_DeleteItem(hwndTV, childItem);
244  }
245  childItem = nextItem;
246  }
247 
248  /* Now go through all the children in the registry, and check if any have to be added. */
249  bAddedAny = FALSE;
250  for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
251  {
252  DWORD cName = dwMaxSubKeyLen, dwSubCount;
253  BOOL found;
254 
255  found = FALSE;
256  if (RegEnumKeyExW(hKey, dwIndex, Name, &cName, 0, 0, 0, NULL) != ERROR_SUCCESS)
257  {
258  continue;
259  }
260 
261  /* Check if the node is already in there. */
262  if (pszNodes)
263  {
264  for (s = pszNodes; *s; s += wcslen(s) + 1)
265  {
266  if (!wcscmp(s, Name))
267  {
268  found = TRUE;
269  break;
270  }
271  }
272  }
273 
274  if (found == FALSE)
275  {
276  /* Find the number of children of the node. */
277  dwSubCount = 0;
278  if (RegOpenKeyExW(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
279  {
280  if (RegQueryInfoKeyW(hSubKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
281  {
282  dwSubCount = 0;
283  }
284  RegCloseKey(hSubKey);
285  }
286 
287  AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
288  bAddedAny = TRUE;
289  }
290  }
291  RegCloseKey(hKey);
292 
293  if (bAddedAny)
294  SendMessageW(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
295 
296  bSuccess = TRUE;
297 
298 done:
299  if (pszNodes)
300  HeapFree(GetProcessHeap(), 0, pszNodes);
301  if (Name)
302  HeapFree(GetProcessHeap(), 0, Name);
303  return bSuccess;
304 }
int cchTextMax
Definition: commctrl.h:3288
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TVM_SORTCHILDREN
Definition: commctrl.h:3508
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DWORD
Definition: msvc.h:34
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3433
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3434
UINT mask
Definition: commctrl.h:3283
#define WCHAR
Definition: msvc.h:43
LPWSTR pszText
Definition: commctrl.h:3287
static BOOLEAN bSuccess
Definition: drive.cpp:419
static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPWSTR label, HKEY hKey, DWORD dwChildren)
Definition: treeview.c:110
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define TVIF_CHILDREN
Definition: commctrl.h:3239
LONG_PTR LPARAM
Definition: windef.h:208
static HTREEITEM hRoot
Definition: treeview.c:381
HTREEITEM hItem
Definition: treelist.h:37
smooth NULL
Definition: ftsmooth.c:416
int cChildren
Definition: commctrl.h:3291
#define TreeView_DeleteItem(hwnd, hitem)
Definition: commctrl.h:3382
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TreeView_GetItemState(hwndTV, hti, mask)
Definition: commctrl.h:3562
BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
Definition: treeview.c:136
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3704
static const WCHAR L[]
Definition: oid.c:1087
GLdouble s
Definition: gl.h:2039
#define TVIS_EXPANDED
Definition: commctrl.h:3251
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define TVIF_TEXT
Definition: commctrl.h:3233
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HeapReAlloc
Definition: compat.h:393
HTREEITEM hItem
Definition: commctrl.h:3284
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3464
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3457

◆ RefreshTreeView()

BOOL RefreshTreeView ( HWND  hWndTV)

Definition at line 306 of file treeview.c.

Referenced by _CmdWndProc(), ImportRegistryFile(), LoadHive(), and UnloadHive().

307 {
309  HTREEITEM hSelectedItem;
310  HCURSOR hcursorOld;
311 
312  hSelectedItem = TreeView_GetSelection(hwndTV);
313  hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
314  SendMessageW(hwndTV, WM_SETREDRAW, FALSE, 0);
315 
316  hItem = TreeView_GetChild(hwndTV, TreeView_GetRoot(hwndTV));
317  while (hItem)
318  {
319  RefreshTreeItem(hwndTV, hItem);
320  hItem = TreeView_GetNextSibling(hwndTV, hItem);
321  }
322 
323  SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
324  SetCursor(hcursorOld);
325 
326  /* We reselect the currently selected node, this will prompt a refresh of the listview. */
327  (void)TreeView_SelectItem(hwndTV, hSelectedItem);
328  return TRUE;
329 }
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3433
#define WM_SETREDRAW
Definition: winuser.h:1598
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3434
HICON HCURSOR
Definition: windef.h:289
HTREEITEM hItem
Definition: treelist.h:37
smooth NULL
Definition: ftsmooth.c:416
#define IDC_WAIT
Definition: winuser.h:684
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3440
BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
Definition: treeview.c:136
#define LoadCursor
Definition: winuser.h:5678
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3442
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3448
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ RegKeyEditPermissions()

BOOL RegKeyEditPermissions ( HWND  hWndOwner,
HKEY  hKey,
LPCWSTR  lpMachine,
LPCWSTR  lpKeyName 
)

Definition at line 839 of file security.c.

Referenced by _CmdWndProc().

843 {
844  BOOL Result = FALSE;
845  LPCWSTR lphKey = NULL;
846  LPWSTR lpKeyPath = NULL;
847  PCRegKeySecurity RegKeySecurity;
848  SI_OBJECT_INFO ObjectInfo;
849  size_t lnMachine = 0, lnKeyName = 0;
850 
851  if (pfnEditSecurity == NULL)
852  {
853  return FALSE;
854  }
855 
856  if (lpMachine != NULL)
857  lnMachine = wcslen(lpMachine);
858  if (lpKeyName != NULL)
859  lnKeyName = wcslen(lpKeyName);
860 
861  /* build registry path */
862  if (lpMachine != NULL &&
863  (lpMachine[0] == L'\0' ||
864  (lpMachine[0] == L'.' && lpMachine[1] == L'.')))
865  {
866  lnMachine = 0;
867  }
868 
869  if (hKey == HKEY_CLASSES_ROOT)
870  lphKey = L"CLASSES_ROOT";
871  else if (hKey == HKEY_CURRENT_USER)
872  lphKey = L"CURRENT_USER";
873  else if (hKey == HKEY_LOCAL_MACHINE)
874  lphKey = L"MACHINE";
875  else if (hKey == HKEY_USERS)
876  lphKey = L"USERS";
877  else if (hKey == HKEY_CURRENT_CONFIG)
878  lphKey = L"CONFIG";
879  else
880  goto Cleanup;
881 
882  lpKeyPath = HeapAlloc(GetProcessHeap(),
883  0,
884  (2 + lnMachine + 1 + wcslen(lphKey) + 1 + lnKeyName) * sizeof(WCHAR));
885  if (lpKeyPath == NULL)
886  {
888  goto Cleanup;
889  }
890  lpKeyPath[0] = L'\0';
891 
892  if (lnMachine != 0)
893  {
894  wcscat(lpKeyPath,
895  L"\\\\");
896  wcscat(lpKeyPath,
897  lpMachine);
898  wcscat(lpKeyPath,
899  L"\\");
900  }
901 
902  wcscat(lpKeyPath,
903  lphKey);
904  if (lpKeyName != NULL && lpKeyName[0] != L'\0')
905  {
906  if (lpKeyName[0] != L'\\')
907  {
908  wcscat(lpKeyPath,
909  L"\\");
910  }
911 
912  wcscat(lpKeyPath,
913  lpKeyName);
914  }
915 
918  ObjectInfo.hInstance = hInst;
919  ObjectInfo.pszServerName = (LPWSTR)lpMachine;
920  ObjectInfo.pszObjectName = (LPWSTR)lpKeyName; /* FIXME */
921  ObjectInfo.pszPageTitle = (LPWSTR)lpKeyName; /* FIXME */
922 
923  if (!(RegKeySecurity = CRegKeySecurity_fnConstructor(lpKeyPath,
924  hKey,
925  &ObjectInfo,
926  &Result)))
927  {
928  goto Cleanup;
929  }
930 
931  /* display the security editor dialog */
932  pfnEditSecurity(hWndOwner,
933  impl_to_interface(RegKeySecurity,
934  ISecurityInformation));
935 
936  /* dereference the interface, it should be destroyed here */
937  CRegKeySecurity_fnRelease(RegKeySecurity);
938 
939 Cleanup:
940  if (lpKeyPath != NULL)
941  {
943  0,
944  lpKeyPath);
945  }
946 
947  return Result;
948 }
#define HKEY_USERS
Definition: winreg.h:13
LPWSTR pszServerName
Definition: accctrl.h:390
#define SI_CONTAINER
Definition: accctrl.h:116
#define impl_to_interface(impl, iface)
Definition: security.c:76
#define SI_RESET_SACL_TREE
Definition: accctrl.h:128
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SI_EDIT_ALL
Definition: accctrl.h:136
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define SI_EDIT_PERMS
Definition: accctrl.h:113
LPWSTR pszPageTitle
Definition: accctrl.h:392
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define SI_ADVANCED
Definition: accctrl.h:118
DWORD dwFlags
Definition: accctrl.h:388
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LPWSTR pszObjectName
Definition: accctrl.h:391
#define SI_RESET_DACL_TREE
Definition: accctrl.h:127
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static __inline ULONG CRegKeySecurity_fnRelease(PCRegKeySecurity obj)
Definition: security.c:85
#define SetLastError(x)
Definition: compat.h:409
HINSTANCE hInstance
Definition: accctrl.h:389
static const WCHAR L[]
Definition: oid.c:1087
static const WCHAR Cleanup[]
Definition: register.c:80
HINSTANCE hInst
Definition: dxdiag.c:13
#define SI_EDIT_EFFECTIVE
Definition: accctrl.h:130
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SI_OWNER_RECURSE
Definition: accctrl.h:122
static PCRegKeySecurity CRegKeySecurity_fnConstructor(LPWSTR lpRegKey, HKEY hRootKey, SI_OBJECT_INFO *ObjectInfo, BOOL *Btn)
Definition: security.c:762
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static PEDITSECURITY pfnEditSecurity
Definition: security.c:807
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ RenameKey()

LONG RenameKey ( HKEY  hKey,
LPCWSTR  lpSubKey,
LPCWSTR  lpNewName 
)

Definition at line 1489 of file edit.c.

Referenced by ChildWndProc().

1490 {
1491  LPCWSTR s;
1492  LPWSTR lpNewSubKey = NULL;
1493  LONG Ret = 0;
1494 
1495  if (!lpSubKey)
1496  return Ret;
1497 
1498  s = wcsrchr(lpSubKey, L'\\');
1499  if (s)
1500  {
1501  s++;
1502  lpNewSubKey = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (s - lpSubKey + wcslen(lpNewName) + 1) * sizeof(WCHAR));
1503  if (lpNewSubKey != NULL)
1504  {
1505  memcpy(lpNewSubKey, lpSubKey, (s - lpSubKey) * sizeof(WCHAR));
1506  wcscpy(lpNewSubKey + (s - lpSubKey), lpNewName);
1507  lpNewName = lpNewSubKey;
1508  }
1509  else
1510  return ERROR_NOT_ENOUGH_MEMORY;
1511  }
1512 
1513  Ret = MoveKey(hKey, lpNewName, hKey, lpSubKey);
1514 
1515  if (lpNewSubKey)
1516  {
1517  HeapFree(GetProcessHeap(), 0, lpNewSubKey);
1518  }
1519  return Ret;
1520 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLdouble s
Definition: gl.h:2039
static LONG MoveKey(HKEY hDestKey, LPCWSTR lpDestSubKey, HKEY hSrcKey, LPCWSTR lpSrcSubKey)
Definition: edit.c:1436
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ RenameValue()

LONG RenameValue ( HKEY  hKey,
LPCWSTR  lpSubKey,
LPCWSTR  lpDestValue,
LPCWSTR  lpSrcValue 
)

Definition at line 1522 of file edit.c.

Referenced by ListWndNotifyProc().

1523 {
1524  LONG lResult;
1525  HKEY hSubKey = NULL;
1526  DWORD dwType, cbData;
1527  BYTE data[512];
1528 
1529  if (lpSubKey)
1530  {
1531  lResult = RegOpenKeyW(hKey, lpSubKey, &hSubKey);
1532  if (lResult != ERROR_SUCCESS)
1533  goto done;
1534  hKey = hSubKey;
1535  }
1536 
1537  cbData = sizeof(data);
1538  lResult = RegQueryValueExW(hKey, lpSrcValue, NULL, &dwType, data, &cbData);
1539  if (lResult != ERROR_SUCCESS)
1540  goto done;
1541 
1542  lResult = RegSetValueExW(hKey, lpDestValue, 0, dwType, data, cbData);
1543  if (lResult != ERROR_SUCCESS)
1544  goto done;
1545 
1546  RegDeleteValue(hKey, lpSrcValue);
1547 
1548 done:
1549  if (hSubKey)
1550  RegCloseKey(hSubKey);
1551  return lResult;
1552 }
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
#define RegDeleteValue
Definition: winreg.h:508
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned char BYTE
Definition: ntddk_ex.h:96

◆ ResizeWnd()

void ResizeWnd ( int  cx,
int  cy 
)

Definition at line 41 of file childwnd.c.

Referenced by ChildWndProc(), and finish_splitbar().

42 {
43  HDWP hdwp = BeginDeferWindowPos(4);
44  RECT rt, rs, rb;
45  const int nButtonWidth = 44;
46  const int nButtonHeight = 22;
47  int cyEdge = GetSystemMetrics(SM_CYEDGE);
49  SetRect(&rt, 0, 0, cx, cy);
50  cy = 0;
51  if (hStatusBar != NULL)
52  {
54  cy = rs.bottom - rs.top;
55  }
58  if (hdwp)
60  rt.left, rt.top,
61  rt.right - rt.left - nButtonWidth, nButtonHeight,
62  uFlags);
63  if (hdwp)
65  rt.right - nButtonWidth, rt.top,
66  nButtonWidth, nButtonHeight,
67  uFlags);
68  if (hdwp)
69  hdwp = DeferWindowPos(hdwp, g_pChildWnd->hTreeWnd, NULL,
70  rt.left,
71  rt.top + nButtonHeight + cyEdge,
73  rt.bottom - rt.top - cy - 2 * cyEdge,
74  uFlags);
75  if (hdwp)
76  hdwp = DeferWindowPos(hdwp, g_pChildWnd->hListWnd, NULL,
77  rt.left + cx,
78  rt.top + nButtonHeight + cyEdge,
79  rt.right - cx,
80  rt.bottom - rt.top - cy - 2 * cyEdge,
81  uFlags);
82  if (hdwp)
83  EndDeferWindowPos(hdwp);
84 }
HDWP WINAPI BeginDeferWindowPos(_In_ int)
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
HWND hTreeWnd
Definition: main.h:60
HWND hListWnd
Definition: main.h:61
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
#define SWP_NOZORDER
Definition: winuser.h:1232
UINT uFlags
Definition: api.c:60
LONG right
Definition: windef.h:298
#define SPLIT_WIDTH
Definition: eventvwr.c:62
int nSplitPos
Definition: main.h:65
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
smooth NULL
Definition: ftsmooth.c:416
#define SM_CYEDGE
Definition: winuser.h:999
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOACTIVATE
Definition: winuser.h:1227
unsigned int UINT
Definition: ndis.h:50
int WINAPI GetSystemMetrics(_In_ int)
HWND hStatusBar
Definition: main.cpp:35
HWND hAddressBtnWnd
Definition: main.h:63
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
_Out_opt_ int * cx
Definition: commctrl.h:570
HWND hAddressBarWnd
Definition: main.h:62
LONG bottom
Definition: windef.h:299
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

◆ SaveSettings()

void SaveSettings (