ReactOS  0.4.15-dev-449-g64abd9f
framewnd.c File Reference
#include "regedit.h"
#include <commdlg.h>
#include <cderr.h>
#include <objsel.h>
Include dependency graph for framewnd.c:

Go to the source code of this file.

Classes

struct  FILTERPAIR
 

Macros

#define FAVORITES_MENU_POSITION   3
 
#define LOADHIVE_KEYNAMELENGTH   128
 

Typedefs

typedef struct FILTERPAIRPFILTERPAIR
 

Functions

static void resize_frame_rect (HWND hWnd, PRECT prect)
 
static void resize_frame_client (HWND hWnd)
 
static void OnInitMenu (HWND hWnd)
 
static void OnEnterMenuLoop (HWND hWnd)
 
static void OnExitMenuLoop (HWND hWnd)
 
static void OnMenuSelect (HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
 
void SetupStatusBar (HWND hWnd, BOOL bResize)
 
void UpdateStatusBar (void)
 
static void toggle_child (HWND hWnd, UINT cmd, HWND hchild)
 
static BOOL CheckCommDlgError (HWND hWnd)
 
void BuildFilterStrings (WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
 
static BOOL InitOpenFileName (HWND hWnd, OPENFILENAME *pofn)
 
static INT_PTR CALLBACK LoadHive_KeyNameInHookProc (HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL EnablePrivilege (LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
 
static BOOL LoadHive (HWND hWnd)
 
static BOOL UnloadHive (HWND hWnd)
 
static BOOL ImportRegistryFile (HWND hWnd)
 
static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
 
BOOL ExportRegistryFile (HWND hWnd)
 
BOOL PrintRegistryHive (HWND hWnd, LPWSTR path)
 
static void ChooseFavorite (LPCWSTR pszFavorite)
 
BOOL CopyKeyName (HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
 
static BOOL CreateNewValue (HKEY hRootKey, LPCWSTR pszKeyPath, DWORD dwType)
 
static HRESULT InitializeRemoteRegistryPicker (OUT IDsObjectPicker **pDsObjectPicker)
 
static HRESULT InvokeRemoteRegistryPickerDialog (IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, OUT LPWSTR lpBuffer, IN UINT uSize)
 
static VOID FreeObjectPicker (IN IDsObjectPicker *pDsObjectPicker)
 
static BOOL _CmdWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
LRESULT CALLBACK FrameWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

static WCHAR s_szFavoritesRegKey [] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites"
 
static BOOL bInMenuLoop = FALSE
 
WCHAR Suggestions [256]
 
WCHAR FileNameBuffer [_MAX_PATH]
 
WCHAR FileTitleBuffer [_MAX_PATH]
 

Macro Definition Documentation

◆ FAVORITES_MENU_POSITION

#define FAVORITES_MENU_POSITION   3

Definition at line 31 of file framewnd.c.

◆ LOADHIVE_KEYNAMELENGTH

#define LOADHIVE_KEYNAMELENGTH   128

Definition at line 296 of file framewnd.c.

Typedef Documentation

◆ PFILTERPAIR

Function Documentation

◆ _CmdWndProc()

static BOOL _CmdWndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1030 of file framewnd.c.

1031 {
1032  HKEY hKeyRoot = 0, hKey = 0;
1033  LPCWSTR keyPath;
1034  LPCWSTR valueName;
1035  BOOL result = TRUE;
1036  REGSAM regsam = KEY_READ;
1037  int item;
1038 
1041 
1042  switch (LOWORD(wParam))
1043  {
1044  case ID_REGISTRY_LOADHIVE:
1045  LoadHive(hWnd);
1046  return TRUE;
1048  UnloadHive(hWnd);
1049  return TRUE;
1052  return TRUE;
1055  return TRUE;
1057  {
1058  IDsObjectPicker *ObjectPicker;
1059  WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
1060  HRESULT hRet;
1061 
1062  hRet = CoInitialize(NULL);
1063  if (SUCCEEDED(hRet))
1064  {
1065  hRet = InitializeRemoteRegistryPicker(&ObjectPicker);
1066  if (SUCCEEDED(hRet))
1067  {
1068  hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker,
1069  hWnd,
1070  szComputerName,
1071  COUNT_OF(szComputerName));
1072  if (hRet == S_OK)
1073  {
1074  /* FIXME - connect to the registry */
1075  }
1076 
1077  FreeObjectPicker(ObjectPicker);
1078  }
1079 
1080  CoUninitialize();
1081  }
1082 
1083  return TRUE;
1084  }
1086  return TRUE;
1087  case ID_REGISTRY_PRINT:
1088  PrintRegistryHive(hWnd, L"");
1089  return TRUE;
1090  case ID_REGISTRY_EXIT:
1092  return TRUE;
1093  case ID_VIEW_STATUSBAR:
1095  return TRUE;
1096  case ID_HELP_HELPTOPICS:
1098  return TRUE;
1099  case ID_HELP_ABOUT:
1100  ShowAboutBox(hWnd);
1101  return TRUE;
1102  case ID_VIEW_SPLIT:
1103  {
1104  RECT rt;
1105  POINT pt, pts;
1107  pt.x = rt.left + g_pChildWnd->nSplitPos;
1108  pt.y = (rt.bottom / 2);
1109  pts = pt;
1110  if(ClientToScreen(g_pChildWnd->hWnd, &pts))
1111  {
1112  SetCursorPos(pts.x, pts.y);
1115  }
1116  return TRUE;
1117  }
1118  case ID_EDIT_RENAME:
1119  case ID_EDIT_MODIFY:
1120  case ID_EDIT_MODIFY_BIN:
1121  case ID_EDIT_DELETE:
1122  regsam |= KEY_WRITE;
1123  break;
1124  }
1125 
1126  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1127  valueName = GetValueName(g_pChildWnd->hListWnd, -1);
1128  if (keyPath)
1129  {
1130  if (RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey) != ERROR_SUCCESS)
1131  hKey = 0;
1132  }
1133 
1134  switch (LOWORD(wParam))
1135  {
1136  case ID_EDIT_MODIFY:
1137  if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
1138  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1139  break;
1140  case ID_EDIT_MODIFY_BIN:
1141  if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
1142  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1143  break;
1144  case ID_EDIT_RENAME:
1145  if (GetFocus() == g_pChildWnd->hListWnd)
1146  {
1148  {
1150  if(item > -1)
1151  {
1153  }
1154  }
1155  }
1156  else if (GetFocus() == g_pChildWnd->hTreeWnd)
1157  {
1158  /* Get focused entry of treeview (if any) */
1160  if (hItem != NULL)
1162  }
1163  break;
1164  case ID_EDIT_DELETE:
1165  {
1166  if (GetFocus() == g_pChildWnd->hListWnd && hKey)
1167  {
1169  if(nSelected >= 1)
1170  {
1171  WCHAR msg[128], caption[128];
1172  LoadStringW(hInst, IDS_QUERY_DELETE_CONFIRM, caption, COUNT_OF(caption));
1175  {
1176  int ni, errs;
1177 
1178  item = -1;
1179  errs = 0;
1181  {
1182  valueName = GetValueName(g_pChildWnd->hListWnd, item);
1183  if(RegDeleteValueW(hKey, valueName) != ERROR_SUCCESS)
1184  {
1185  errs++;
1186  }
1187  item = ni;
1188  }
1189 
1190  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1191  if(errs > 0)
1192  {
1193  LoadStringW(hInst, IDS_ERR_DELVAL_CAPTION, caption, COUNT_OF(caption));
1196  }
1197  }
1198  }
1199  }
1200  else if (GetFocus() == g_pChildWnd->hTreeWnd)
1201  {
1202  if (keyPath == NULL || *keyPath == UNICODE_NULL)
1203  {
1205  }
1206  else if (DeleteKey(hWnd, hKeyRoot, keyPath))
1207  {
1210  }
1211  }
1212  break;
1213  }
1215  CreateNewValue(hKeyRoot, keyPath, REG_SZ);
1216  break;
1218  CreateNewValue(hKeyRoot, keyPath, REG_BINARY);
1219  break;
1221  CreateNewValue(hKeyRoot, keyPath, REG_DWORD);
1222  break;
1224  CreateNewValue(hKeyRoot, keyPath, REG_MULTI_SZ);
1225  break;
1227  CreateNewValue(hKeyRoot, keyPath, REG_EXPAND_SZ);
1228  break;
1229  case ID_EDIT_FIND:
1230  FindDialog(hWnd);
1231  break;
1232  case ID_EDIT_FINDNEXT:
1233  FindNext(hWnd);
1234  break;
1235  case ID_EDIT_COPYKEYNAME:
1236  CopyKeyName(hWnd, hKeyRoot, keyPath);
1237  break;
1238  case ID_EDIT_PERMISSIONS:
1239  RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
1240  break;
1242  /*PRINTDLG pd;*/
1243  /*PrintDlg(&pd);*/
1244  /*PAGESETUPDLG psd;*/
1245  /*PageSetupDlg(&psd);*/
1246  break;
1247  case ID_REGISTRY_OPENLOCAL:
1248  break;
1249 
1250  case ID_VIEW_REFRESH:
1252  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1253  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1254  break;
1255  /*case ID_OPTIONS_TOOLBAR:*/
1256  /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
1257  /* break;*/
1258  case ID_EDIT_NEW_KEY:
1260  break;
1261 
1262  case ID_TREE_EXPANDBRANCH:
1264  break;
1267  break;
1268  case ID_TREE_RENAME:
1271  break;
1272  case ID_TREE_DELETE:
1274  if (keyPath == 0 || *keyPath == 0)
1275  {
1277  }
1278  else if (DeleteKey(hWnd, hKeyRoot, keyPath))
1280  break;
1281  case ID_TREE_EXPORT:
1283  break;
1284  case ID_TREE_PERMISSIONS:
1286  RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
1287  break;
1288  case ID_SWITCH_PANELS:
1291  break;
1292 
1293  default:
1295  {
1296  HMENU hMenu;
1297  MENUITEMINFOW mii;
1298  WCHAR szFavorite[512];
1299 
1301 
1302  memset(&mii, 0, sizeof(mii));
1303  mii.cbSize = sizeof(mii);
1304  mii.fMask = MIIM_TYPE;
1305  mii.fType = MFT_STRING;
1306  mii.dwTypeData = szFavorite;
1307  mii.cch = COUNT_OF(szFavorite);
1308 
1309  if (GetMenuItemInfo(hMenu, LOWORD(wParam) - ID_FAVORITES_MIN, TRUE, &mii))
1310  {
1311  ChooseFavorite(szFavorite);
1312  }
1313  }
1315  {
1316  WORD wID = LOWORD(wParam);
1317  LPCWSTR s = Suggestions;
1318  while(wID > ID_TREE_SUGGESTION_MIN)
1319  {
1320  if (*s)
1321  s += wcslen(s) + 1;
1322  wID--;
1323  }
1325  }
1326  else
1327  {
1328  result = FALSE;
1329  }
1330  break;
1331  }
1332 
1333  if(hKey)
1334  RegCloseKey(hKey);
1335  return result;
1336 }
#define IDC_SIZEWE
Definition: winuser.h:689
#define MB_ICONHAND
Definition: winuser.h:782
#define ID_REGISTRY_IMPORTREGISTRYFILE
Definition: resource.h:71
#define ID_TREE_RENAME
Definition: resource.h:155
#define ID_SWITCH_PANELS
Definition: resource.h:152
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2430
Definition: tftpd.h:59
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
#define ID_TREE_COLLAPSEBRANCH
Definition: resource.h:98
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:49
long y
Definition: polytest.cpp:48
#define ID_REGISTRY_LOADHIVE
Definition: resource.h:107
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
BOOL ExportRegistryFile(HWND hWnd)
Definition: framewnd.c:587
#define IDYES
Definition: winuser.h:829
#define ID_EDIT_COPYKEYNAME
Definition: resource.h:62
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
void ShowAboutBox(HWND hWnd)
Definition: about.c:25
long x
Definition: polytest.cpp:48
#define REG_BINARY
Definition: nt_native.h:1496
#define ID_TREE_EXPORT
Definition: resource.h:161
#define ID_EDIT_NEW_EXPANDABLESTRINGVALUE
Definition: resource.h:150
#define ID_FAVORITES_MAX
Definition: resource.h:297
#define KEY_READ
Definition: nt_native.h:1023
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define pt(x, y)
Definition: drawing.c:79
static struct netconfig_info ni
Definition: getnetconfig.c:158
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3500
HWND hTreeWnd
Definition: main.h:61
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
#define ID_EDIT_FIND
Definition: resource.h:63
HWND hListWnd
Definition: main.h:62
HWND hWnd
Definition: settings.c:17
HWND WINAPI SetFocus(_In_opt_ HWND)
LPWSTR dwTypeData
Definition: winuser.h:3244
#define ID_EDIT_FINDNEXT
Definition: resource.h:64
#define LVNI_SELECTED
Definition: commctrl.h:2420
#define MB_ICONSTOP
Definition: winuser.h:797
BOOL FindNext(HWND hWnd)
Definition: find.c:631
LONG left
Definition: windef.h:306
#define IDS_QUERY_DELETE_MORE
Definition: resource.h:137
static HRESULT InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
Definition: framewnd.c:901
#define ID_HELP_HELPTOPICS
Definition: resource.h:77
static void ChooseFavorite(LPCWSTR pszFavorite)
Definition: framewnd.c:769
BOOL WINAPI DestroyWindow(_In_ HWND)
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
static BOOL LoadHive(HWND hWnd)
Definition: framewnd.c:352
#define ID_EDIT_NEW_BINARYVALUE
Definition: resource.h:68
#define HELP_FINDER
Definition: winuser.h:2394
int nSplitPos
Definition: main.h:67
static VOID FreeObjectPicker(IN IDsObjectPicker *pDsObjectPicker)
Definition: framewnd.c:1018
#define ID_REGISTRY_EXIT
Definition: resource.h:54
#define ID_VIEW_STATUSBAR
Definition: resource.h:57
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2705
#define MB_YESNO
Definition: winuser.h:811
#define UNICODE_NULL
static BOOL UnloadHive(HWND hWnd)
Definition: framewnd.c:409
#define ID_TREE_SUGGESTION_MIN
Definition: resource.h:159
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ID_EDIT_DELETE
Definition: resource.h:60
#define REG_MULTI_SZ
Definition: nt_native.h:1501
LPCWSTR GetValueName(HWND hwndLV, int iStartAt)
Definition: listview.c:55
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
Definition: framewnd.c:791
#define ID_HELP_ABOUT
Definition: resource.h:78
#define ID_REGISTRY_CONNECTNETWORKREGISTRY
Definition: resource.h:73
#define ID_EDIT_PERMISSIONS
Definition: resource.h:153
WCHAR Suggestions[256]
Definition: childwnd.c:27
smooth NULL
Definition: ftsmooth.c:416
#define TVE_COLLAPSE
Definition: commctrl.h:3418
#define MB_ICONQUESTION
Definition: winuser.h:783
static HRESULT InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: framewnd.c:960
#define IDS_QUERY_DELETE_ONE
Definition: resource.h:136
#define ID_EDIT_RENAME
Definition: resource.h:61
BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem)
Definition: treeview.c:102
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCWSTR valueName, BOOL EditBin)
Definition: edit.c:1072
#define IDS_ERR_DELVAL_CAPTION
Definition: resource.h:139
#define GetMenuItemInfo
Definition: winuser.h:5763
#define KEY_WRITE
Definition: nt_native.h:1031
#define ID_VIEW_REFRESH
Definition: resource.h:59
#define ID_TREE_SUGGESTION_MAX
Definition: resource.h:160
#define COUNT_OF(a)
Definition: main.h:33
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3469
static BOOL ImportRegistryFile(HWND hWnd)
Definition: framewnd.c:441
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define ID_REGISTRY_UNLOADHIVE
Definition: resource.h:108
HWND hWnd
Definition: main.h:60
#define ID_TREE_PERMISSIONS
Definition: resource.h:162
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
unsigned short WORD
Definition: ntddk_ex.h:93
HWND hStatusBar
Definition: main.cpp:35
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define TVE_EXPAND
Definition: commctrl.h:3419
#define ID_REGISTRY_DISCONNECTNETWORKREGISTRY
Definition: resource.h:74
#define ID_FAVORITES_MIN
Definition: resource.h:296
#define ID_EDIT_NEW_KEY
Definition: resource.h:66
static const WCHAR L[]
Definition: oid.c:1250
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:670
#define ID_REGISTRY_OPENLOCAL
Definition: resource.h:105
#define MIIM_TYPE
Definition: winuser.h:720
#define FAVORITES_MENU_POSITION
Definition: framewnd.c:31
#define ID_REGISTRY_EXPORTREGISTRYFILE
Definition: resource.h:72
GLdouble s
Definition: gl.h:2039
void FindDialog(HWND hWnd)
Definition: find.c:813
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define ID_EDIT_NEW_DWORDVALUE
Definition: resource.h:69
BOOL WINAPI MessageBeep(_In_ UINT)
#define ID_EDIT_MODIFY
Definition: resource.h:65
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define ID_EDIT_NEW_STRINGVALUE
Definition: resource.h:67
#define S_OK
Definition: intsafe.h:59
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL PrintRegistryHive(HWND hWnd, LPWSTR path)
Definition: framewnd.c:697
static ATOM item
Definition: dde.c:856
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2355
#define ID_VIEW_SPLIT
Definition: resource.h:58
#define ID_REGISTRY_PRINT
Definition: resource.h:75
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define ID_REGISTRY_PRINTERSETUP
Definition: resource.h:113
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
Definition: framewnd.c:188
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
Definition: edit.c:1456
#define IDS_ERR_DELETEVALUE
Definition: resource.h:140
ACCESS_MASK REGSAM
Definition: winreg.h:69
#define ID_TREE_EXPANDBRANCH
Definition: resource.h:96
unsigned int UINT
Definition: ndis.h:50
LPCWSTR getAppName(void)
Definition: regedit.c:61
BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem)
Definition: treeview.c:571
BOOL WINAPI WinHelpW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_ UINT, _In_ ULONG_PTR)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
#define msg(x)
Definition: auth_time.c:54
HWND WINAPI GetFocus(void)
Definition: window.c:1909
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:771
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LONG bottom
Definition: windef.h:309
BOOL RegKeyEditPermissions(HWND hWndOwner, HKEY hKey, LPCWSTR lpMachine, LPCWSTR lpKeyName)
Definition: security.c:839
#define ID_TREE_DELETE
Definition: resource.h:154
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3416
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:306
#define ID_EDIT_MODIFY_BIN
Definition: resource.h:125
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
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
static BOOL CreateNewValue(HKEY hRootKey, LPCWSTR pszKeyPath, DWORD dwType)
Definition: framewnd.c:826
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ID_EDIT_NEW_MULTISTRINGVALUE
Definition: resource.h:149
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2536
#define IDS_QUERY_DELETE_CONFIRM
Definition: resource.h:138
#define SUCCEEDED(hr)
Definition: intsafe.h:57
int nFocusPanel
Definition: main.h:66
#define REG_SZ
Definition: layer.c:22

Referenced by FrameWndProc().

◆ BuildFilterStrings()

void BuildFilterStrings ( WCHAR Filter,
PFILTERPAIR  Pairs,
int  PairCount 
)

Definition at line 250 of file framewnd.c.

251 {
252  int i, c;
253 
254  c = 0;
255  for(i = 0; i < PairCount; i++)
256  {
257  c += LoadStringW(hInst, Pairs[i].DisplayID, &Filter[c], 255);
258  Filter[++c] = L'\0';
259  c += LoadStringW(hInst, Pairs[i].FilterID, &Filter[c], 255);
260  Filter[++c] = L'\0';
261  }
262  Filter[++c] = L'\0';
263 }
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
const GLubyte * c
Definition: glext.h:8905
static const WCHAR L[]
Definition: oid.c:1250
HINSTANCE hInst
Definition: dxdiag.c:13
#define c
Definition: ke_i.h:80

Referenced by InitOpenFileName(), and LoadHive().

◆ CheckCommDlgError()

static BOOL CheckCommDlgError ( HWND  hWnd)
static

Definition at line 198 of file framewnd.c.

199 {
200  DWORD dwErrorCode = CommDlgExtendedError();
202  switch (dwErrorCode)
203  {
204  case CDERR_DIALOGFAILURE:
205  break;
207  break;
208  case CDERR_NOHINSTANCE:
209  break;
211  break;
212  case CDERR_NOHOOK:
213  break;
215  break;
216  case CDERR_NOTEMPLATE:
217  break;
219  break;
220  case CDERR_STRUCTSIZE:
221  break;
223  break;
225  break;
227  break;
229  break;
231  break;
233  break;
234  default:
235  break;
236  }
237  return TRUE;
238 }
#define TRUE
Definition: types.h:120
#define CDERR_LOADRESFAILURE
Definition: cderr.h:12
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CDERR_NOHINSTANCE
Definition: cderr.h:9
HWND hWnd
Definition: settings.c:17
#define FNERR_SUBCLASSFAILURE
Definition: cderr.h:35
#define CDERR_STRUCTSIZE
Definition: cderr.h:6
#define CDERR_FINDRESFAILURE
Definition: cderr.h:11
#define CDERR_LOADSTRFAILURE
Definition: cderr.h:10
#define CDERR_LOCKRESFAILURE
Definition: cderr.h:13
#define CDERR_INITIALIZATION
Definition: cderr.h:7
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CDERR_NOHOOK
Definition: cderr.h:16
#define CDERR_NOTEMPLATE
Definition: cderr.h:8
#define CDERR_MEMLOCKFAILURE
Definition: cderr.h:15
#define FNERR_BUFFERTOOSMALL
Definition: cderr.h:37
#define CDERR_MEMALLOCFAILURE
Definition: cderr.h:14
#define CDERR_DIALOGFAILURE
Definition: cderr.h:4
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:139
#define FNERR_INVALIDFILENAME
Definition: cderr.h:36

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

◆ ChooseFavorite()

static void ChooseFavorite ( LPCWSTR  pszFavorite)
static

Definition at line 769 of file framewnd.c.

770 {
771  HKEY hKey = NULL;
772  WCHAR szFavoritePath[512];
773  DWORD cbData, dwType;
774 
776  goto done;
777 
778  cbData = sizeof(szFavoritePath);
779  memset(szFavoritePath, 0, sizeof(szFavoritePath));
780  if (RegQueryValueExW(hKey, pszFavorite, NULL, &dwType, (LPBYTE) szFavoritePath, &cbData) != ERROR_SUCCESS)
781  goto done;
782 
783  if (dwType == REG_SZ)
784  SelectNode(g_pChildWnd->hTreeWnd, szFavoritePath);
785 
786 done:
787  if (hKey)
788  RegCloseKey(hKey);
789 }
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HWND hTreeWnd
Definition: main.h:61
static WCHAR s_szFavoritesRegKey[]
Definition: framewnd.c:33
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
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:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:771
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define memset(x, y, z)
Definition: compat.h:39
#define REG_SZ
Definition: layer.c:22

Referenced by _CmdWndProc().

◆ CopyKeyName()

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

Definition at line 791 of file framewnd.c.

792 {
793  BOOL bClipboardOpened = FALSE;
794  BOOL bSuccess = FALSE;
795  WCHAR szBuffer[512];
796  HGLOBAL hGlobal;
797  LPWSTR s;
798 
799  if (!OpenClipboard(hWnd))
800  goto done;
801  bClipboardOpened = TRUE;
802 
803  if (!EmptyClipboard())
804  goto done;
805 
806  if (!GetKeyName(szBuffer, COUNT_OF(szBuffer), hRootKey, keyName))
807  goto done;
808 
809  hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
810  if (!hGlobal)
811  goto done;
812 
813  s = GlobalLock(hGlobal);
814  wcscpy(s, szBuffer);
815  GlobalUnlock(hGlobal);
816 
818  bSuccess = TRUE;
819 
820 done:
821  if (bClipboardOpened)
822  CloseClipboard();
823  return bSuccess;
824 }
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HWND hWnd
Definition: settings.c:17
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
static BOOLEAN bSuccess
Definition: drive.cpp:419
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CF_UNICODETEXT
Definition: constants.h:408
#define COUNT_OF(a)
Definition: main.h:33
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
__wchar_t WCHAR
Definition: xmlstorage.h:180
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

Referenced by _CmdWndProc().

◆ CreateNewValue()

static BOOL CreateNewValue ( HKEY  hRootKey,
LPCWSTR  pszKeyPath,
DWORD  dwType 
)
static

Definition at line 826 of file framewnd.c.

827 {
828  WCHAR szNewValueFormat[128];
829  WCHAR szNewValue[128];
830  int iIndex = 1;
831  BYTE data[128];
832  DWORD dwExistingType, cbData;
833  LONG lResult;
834  HKEY hKey;
835  LVFINDINFO lvfi;
836 
837  if (RegOpenKeyExW(hRootKey, pszKeyPath, 0, KEY_QUERY_VALUE | KEY_SET_VALUE,
838  &hKey) != ERROR_SUCCESS)
839  return FALSE;
840 
841  LoadStringW(hInst, IDS_NEW_VALUE, szNewValueFormat, COUNT_OF(szNewValueFormat));
842 
843  do
844  {
845  wsprintf(szNewValue, szNewValueFormat, iIndex++);
846  cbData = sizeof(data);
847  lResult = RegQueryValueExW(hKey, szNewValue, NULL, &dwExistingType, data, &cbData);
848  }
849  while(lResult == ERROR_SUCCESS);
850 
851  switch(dwType)
852  {
853  case REG_DWORD:
854  cbData = sizeof(DWORD);
855  break;
856  case REG_SZ:
857  case REG_EXPAND_SZ:
858  cbData = sizeof(WCHAR);
859  break;
860  case REG_MULTI_SZ:
861  /*
862  * WARNING: An empty multi-string has only one null char.
863  * Indeed, multi-strings are built in the following form:
864  * str1\0str2\0...strN\0\0
865  * where each strI\0 is a null-terminated string, and it
866  * ends with a terminating empty string.
867  * Therefore an empty multi-string contains only the terminating
868  * empty string, that is, one null char.
869  */
870  cbData = sizeof(WCHAR);
871  break;
872  case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
873  cbData = sizeof(DWORDLONG); // == sizeof(DWORD) * 2;
874  break;
875  default:
876  cbData = 0;
877  break;
878  }
879  memset(data, 0, cbData);
880  lResult = RegSetValueExW(hKey, szNewValue, 0, dwType, data, cbData);
881  RegCloseKey(hKey);
882  if (lResult != ERROR_SUCCESS)
883  {
884  return FALSE;
885  }
886 
887  RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
888 
889  /* locate the newly added value, and get ready to rename it */
890  memset(&lvfi, 0, sizeof(lvfi));
891  lvfi.flags = LVFI_STRING;
892  lvfi.psz = szNewValue;
893  iIndex = ListView_FindItem(g_pChildWnd->hListWnd, -1, &lvfi);
894  if (iIndex >= 0)
896 
897  return TRUE;
898 }
#define TRUE
Definition: types.h:120
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:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
HWND hListWnd
Definition: main.h:62
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define REG_MULTI_SZ
Definition: nt_native.h:1501
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:4895
#define COUNT_OF(a)
Definition: main.h:33
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:670
unsigned char BYTE
Definition: xxhash.c:193
HINSTANCE hInst
Definition: dxdiag.c:13
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define LVFINDINFO
Definition: commctrl.h:2459
unsigned long long DWORDLONG
Definition: intsafe.h:99
#define LVFI_STRING
Definition: commctrl.h:2433
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2466
#define REG_QWORD
Definition: sdbapi.c:597
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define IDS_NEW_VALUE
Definition: resource.h:193
#define wsprintf
Definition: winuser.h:5840
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2536
#define REG_SZ
Definition: layer.c:22

Referenced by _CmdWndProc().

◆ EnablePrivilege()

static BOOL EnablePrivilege ( LPCWSTR  lpszPrivilegeName,
LPCWSTR  lpszSystemName,
BOOL  bEnablePrivilege 
)
static

Definition at line 322 of file framewnd.c.

323 {
324  BOOL bRet = FALSE;
325  HANDLE hToken = NULL;
326 
329  &hToken))
330  {
332 
333  tp.PrivilegeCount = 1;
334  tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
335 
336  if (LookupPrivilegeValueW(lpszSystemName,
337  lpszPrivilegeName,
338  &tp.Privileges[0].Luid))
339  {
340  bRet = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
341 
343  bRet = FALSE;
344  }
345 
346  CloseHandle(hToken);
347  }
348 
349  return bRet;
350 }
#define CloseHandle
Definition: compat.h:407
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2930
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define ERROR_NOT_ALL_ASSIGNED
Definition: winerror.h:782
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876

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

◆ ExportRegistryFile()

BOOL ExportRegistryFile ( HWND  hWnd)

Definition at line 587 of file framewnd.c.

588 {
589  BOOL bRet = FALSE;
591  WCHAR ExportKeyPath[_MAX_PATH] = {0};
592  WCHAR Caption[128], szTitle[512], szText[512];
593  HKEY hKeyRoot;
594  LPCWSTR pszKeyPath;
595 
596  /* Figure out which key path we are exporting */
597  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
598  GetKeyName(ExportKeyPath, COUNT_OF(ExportKeyPath), hKeyRoot, pszKeyPath);
599 
601  LoadStringW(hInst, IDS_EXPORT_REG_FILE, Caption, COUNT_OF(Caption));
602  ofn.lpstrTitle = Caption;
603 
604  /* Only set the path if a key (not the root node) is selected */
605  if (hKeyRoot != 0)
606  {
607  ofn.lCustData = (LPARAM) ExportKeyPath;
608  }
612  if (GetSaveFileName(&ofn))
613  {
614  switch (ofn.nFilterIndex)
615  {
616  case 2: /* Registry Hive Files */
617  {
618  LONG lResult;
619  HKEY hSubKey;
620 
621  /* Open the subkey */
622  lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_READ, &hSubKey);
623  if (lResult == ERROR_SUCCESS)
624  {
625  /* Enable the 'backup' privilege, save the hive then disable the privilege */
627  lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
628  if (lResult == ERROR_ALREADY_EXISTS)
629  {
630  /*
631  * We are here, that means that we already said "yes" to the confirmation dialog.
632  * So we absolutely want to replace the hive file.
633  */
635  {
636  /* Try again */
637  lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
638  }
639  }
641 
642  if (lResult != ERROR_SUCCESS)
643  {
644  /*
645  * If we are here, it's because RegSaveKeyW has failed for any reason.
646  * The problem is that even if it has failed, it has created or
647  * replaced the exported hive file with a new empty file. We don't
648  * want to keep this file, so we delete it.
649  */
651  }
652 
653  /* Close the subkey */
654  RegCloseKey(hSubKey);
655  }
656 
657  /* Set the return value */
658  bRet = (lResult == ERROR_SUCCESS);
659 
660  /* Display error, if any */
661  if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
662 
663  break;
664  }
665 
666  case 1: /* Windows Registry Editor Version 5.00 */
667  case 3: /* REGEDIT4 */
668  default: /* All files ==> use Windows Registry Editor Version 5.00 */
669  {
670  if (!export_registry_key(ofn.lpstrFile, ExportKeyPath,
672  : REG_FORMAT_5)))
673  {
674  /* Error creating the file */
678  bRet = FALSE;
679  }
680  else
681  {
682  bRet = TRUE;
683  }
684 
685  break;
686  }
687  }
688  }
689  else
690  {
692  }
693 
694  return bRet;
695 }
#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
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LPARAM lCustData
Definition: commdlg.h:346
#define KEY_READ
Definition: nt_native.h:1023
#define SE_BACKUP_NAME
HWND hTreeWnd
Definition: main.h:61
HWND hWnd
Definition: settings.c:17
OPENFILENAME ofn
Definition: main.cpp:37
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
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define IDS_EXPORT_REG_FILE
Definition: resource.h:134
#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:533
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:322
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define IDD_EXPORTRANGE
Definition: resource.h:42
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:4630
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define REG_FORMAT_5
Definition: regproc.h:24
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:198
#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:199
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#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:265
DWORD Flags
Definition: commdlg.h:342
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:1588

Referenced by _CmdWndProc().

◆ ExportRegistryFile_OFNHookProc()

static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc ( HWND  hdlg,
UINT  uiMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 533 of file framewnd.c.

534 {
535  HWND hwndExportAll;
536  HWND hwndExportBranch;
537  HWND hwndExportBranchText;
538  UINT_PTR iResult = 0;
539  OPENFILENAME *pOfn;
540  LPWSTR pszSelectedKey;
541  OFNOTIFY *pOfnNotify;
542 
544 
545  switch(uiMsg)
546  {
547  case WM_INITDIALOG:
548  pOfn = (OPENFILENAME *) lParam;
549  pszSelectedKey = (LPWSTR) pOfn->lCustData;
550 
551  hwndExportAll = GetDlgItem(hdlg, IDC_EXPORT_ALL);
552  if (hwndExportAll)
553  SendMessageW(hwndExportAll, BM_SETCHECK, pszSelectedKey ? BST_UNCHECKED : BST_CHECKED, 0);
554 
555  hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
556  if (hwndExportBranch)
557  SendMessageW(hwndExportBranch, BM_SETCHECK, pszSelectedKey ? BST_CHECKED : BST_UNCHECKED, 0);
558 
559  hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
560  if (hwndExportBranchText)
561  SetWindowTextW(hwndExportBranchText, pszSelectedKey);
562  break;
563 
564  case WM_NOTIFY:
565  if (((NMHDR *) lParam)->code == CDN_FILEOK)
566  {
567  pOfnNotify = (OFNOTIFY *) lParam;
568  pszSelectedKey = (LPWSTR) pOfnNotify->lpOFN->lCustData;
569 
570  hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
571  hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
572  if (hwndExportBranch && hwndExportBranchText
573  && (SendMessageW(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED))
574  {
575  GetWindowTextW(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
576  }
577  else
578  {
579  pszSelectedKey[0] = L'\0';
580  }
581  }
582  break;
583  }
584  return iResult;
585 }
LPARAM lCustData
Definition: commdlg.h:346
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define IDC_EXPORT_ALL
Definition: resource.h:260
#define IDC_EXPORT_BRANCH
Definition: resource.h:261
WPARAM wParam
Definition: combotst.c:138
#define IDC_EXPORT_BRANCH_TEXT
Definition: resource.h:262
#define _MAX_PATH
Definition: utility.h:77
#define BM_GETCHECK
Definition: winuser.h:1900
LPOPENFILENAMEA lpOFN
Definition: commdlg.h:407
#define BM_SETCHECK
Definition: winuser.h:1903
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CDN_FILEOK
Definition: commdlg.h:38
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
static const WCHAR L[]
Definition: oid.c:1250
#define BST_UNCHECKED
Definition: winuser.h:199
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by ExportRegistryFile().

◆ FrameWndProc()

static LRESULT CALLBACK FrameWndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1349 of file framewnd.c.

1350 {
1351  RECT rc;
1352  switch (message)
1353  {
1354  case WM_CREATE:
1355  // For now, the Help dialog item is disabled because of lacking of HTML Help support
1357  GetClientRect(hWnd, &rc);
1359  rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
1360  hWnd, (HMENU)0, hInst, 0);
1361  break;
1362  case WM_COMMAND:
1365  break;
1366  case WM_ACTIVATE:
1367  if (LOWORD(hWnd) && g_pChildWnd)
1369  break;
1370  case WM_SIZE:
1372  break;
1373  case WM_TIMER:
1374  break;
1375  case WM_INITMENU:
1376  OnInitMenu(hWnd);
1377  break;
1378  case WM_ENTERMENULOOP:
1380  break;
1381  case WM_EXITMENULOOP:
1383  break;
1384  case WM_MENUSELECT:
1386  break;
1387  case WM_SYSCOLORCHANGE:
1388  /* Forward WM_SYSCOLORCHANGE to common controls */
1391  break;
1392  case WM_DESTROY:
1394  SaveSettings();
1395  PostQuitMessage(0);
1396  default:
1398  }
1399  return 0;
1400 }
#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:136
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:62
#define HELP_QUIT
Definition: winuser.h:2389
HWND hTreeWnd
Definition: main.h:61
HWND hListWnd
Definition: main.h:62
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
Definition: framewnd.c:144
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:306
#define ID_HELP_HELPTOPICS
Definition: resource.h:77
LONG right
Definition: windef.h:308
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
void SaveSettings(void)
Definition: settings.c:115
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_ENTERMENULOOP
Definition: winuser.h:1786
#define WM_MENUSELECT
Definition: winuser.h:1729
#define WM_EXITMENULOOP
Definition: winuser.h:1787
smooth NULL
Definition: ftsmooth.c:416
#define WM_DESTROY
Definition: winuser.h:1591
static void OnEnterMenuLoop(HWND hWnd)
Definition: framewnd.c:124
#define WM_SIZE
Definition: winuser.h:1593
HWND hWnd
Definition: main.h:60
#define WM_TIMER
Definition: winuser.h:1724
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1030
static void OnInitMenu(HWND hWnd)
Definition: framewnd.c:72
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:1722
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HINSTANCE hInst
Definition: dxdiag.c:13
#define WM_INITMENU
Definition: winuser.h:1727
#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
LONG bottom
Definition: windef.h:309
#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)

Referenced by InitInstance().

◆ FreeObjectPicker()

static VOID FreeObjectPicker ( IN IDsObjectPicker *  pDsObjectPicker)
static

Definition at line 1018 of file framewnd.c.

1019 {
1020  pDsObjectPicker->lpVtbl->Release(pDsObjectPicker);
1021 }

Referenced by _CmdWndProc(), and SecurityPageProc().

◆ ImportRegistryFile()

static BOOL ImportRegistryFile ( HWND  hWnd)
static

Definition at line 441 of file framewnd.c.

442 {
443  BOOL bRet = FALSE;
445  WCHAR Caption[128], szTitle[512], szText[512];
446  HKEY hKeyRoot;
447  LPCWSTR pszKeyPath;
448 
449  /* Figure out in which key path we are importing */
450  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
451 
453  LoadStringW(hInst, IDS_IMPORT_REG_FILE, Caption, COUNT_OF(Caption));
454  ofn.lpstrTitle = Caption;
456  /* ofn.lCustData = ;*/
457  if (GetOpenFileName(&ofn))
458  {
459  /* Look at the extension of the file to determine its type */
460  if (ofn.nFileExtension >= 1 &&
461  _wcsicmp(ofn.lpstrFile + ofn.nFileExtension, L"reg") == 0) /* REGEDIT4 or Windows Registry Editor Version 5.00 */
462  {
463  /* Open the file */
464  FILE* fp = _wfopen(ofn.lpstrFile, L"r");
465 
466  /* Import it */
467  if (fp == NULL || !import_registry_file(fp))
468  {
469  /* Error opening the file */
473  bRet = FALSE;
474  }
475  else
476  {
477  /* Show successful import */
481  bRet = TRUE;
482  }
483 
484  /* Close the file */
485  if (fp) fclose(fp);
486  }
487  else /* Registry Hive Files */
488  {
491 
492  /* Display a confirmation message */
494  {
495  LONG lResult;
496  HKEY hSubKey;
497 
498  /* Open the subkey */
499  lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_WRITE, &hSubKey);
500  if (lResult == ERROR_SUCCESS)
501  {
502  /* Enable the 'restore' privilege, restore the hive then disable the privilege */
504  lResult = RegRestoreKey(hSubKey, ofn.lpstrFile, REG_FORCE_RESTORE);
506 
507  /* Flush the subkey and close it */
508  RegFlushKey(hSubKey);
509  RegCloseKey(hSubKey);
510  }
511 
512  /* Set the return value */
513  bRet = (lResult == ERROR_SUCCESS);
514 
515  /* Display error, if any */
516  if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
517  }
518  }
519  }
520  else
521  {
523  }
524 
525  /* refresh tree and list views */
527  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
528  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, pszKeyPath);
529 
530  return bRet;
531 }
#define TRUE
Definition: types.h:120
#define RegRestoreKey
Definition: winreg.h:526
WORD nFileExtension
Definition: commdlg.h:344
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
#define IDYES
Definition: winuser.h:829
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
HWND hTreeWnd
Definition: main.h:61
#define IDS_QUERY_IMPORT_HIVE_MSG
Definition: resource.h:144
HWND hListWnd
Definition: main.h:62
HWND hWnd
Definition: settings.c:17
OPENFILENAME ofn
Definition: main.cpp:37
#define IDS_QUERY_IMPORT_HIVE_CAPTION
Definition: resource.h:143
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
Definition: error.c:51
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2974
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define GetOpenFileName
Definition: commdlg.h:665
#define MB_ICONWARNING
Definition: winuser.h:780
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define MB_YESNO
Definition: winuser.h:811
static const WCHAR szText[]
Definition: dialog.c:139
#define IDS_IMPORT_REG_FILE
Definition: resource.h:133
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:322
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define KEY_WRITE
Definition: nt_native.h:1031
#define COUNT_OF(a)
Definition: main.h:33
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hWnd
Definition: main.h:60
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:198
#define MB_ICONINFORMATION
Definition: winuser.h:796
static const WCHAR L[]
Definition: oid.c:1250
#define SE_RESTORE_NAME
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:670
#define MB_ICONERROR
Definition: winuser.h:781
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define IDS_IMPORT_ERROR
Definition: resource.h:198
#define REG_FORCE_RESTORE
Definition: cmtypes.h:109
HINSTANCE hInst
Definition: dxdiag.c:13
LPSTR lpstrFile
Definition: commdlg.h:336
#define IDS_IMPORT_OK
Definition: resource.h:197
#define MB_OK
Definition: winuser.h:784
#define IDS_APP_TITLE
Definition: resource.h:10
LPCSTR lpstrTitle
Definition: commdlg.h:341
BOOL import_registry_file(FILE *reg_file)
Definition: regproc.c:1405
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define OFN_ENABLESIZING
Definition: commdlg.h:101
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:306
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn)
Definition: framewnd.c:265
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
DWORD Flags
Definition: commdlg.h:342

Referenced by _CmdWndProc(), main(), and UpdateRegistry().

◆ InitializeRemoteRegistryPicker()

static HRESULT InitializeRemoteRegistryPicker ( OUT IDsObjectPicker **  pDsObjectPicker)
static

Definition at line 901 of file framewnd.c.

902 {
903  HRESULT hRet;
904 
905  *pDsObjectPicker = NULL;
906 
907  hRet = CoCreateInstance(&CLSID_DsObjectPicker,
908  NULL,
909  CLSCTX_INPROC_SERVER,
910  &IID_IDsObjectPicker,
911  (LPVOID*)pDsObjectPicker);
912  if (SUCCEEDED(hRet))
913  {
914  DSOP_INIT_INFO InitInfo;
915  static DSOP_SCOPE_INIT_INFO Scopes[] =
916  {
917  {
918  sizeof(DSOP_SCOPE_INIT_INFO),
923  0,
924  {
925  {
927  0,
928  0
929  },
931  },
932  NULL,
933  NULL,
934  S_OK
935  },
936  };
937 
938  InitInfo.cbSize = sizeof(InitInfo);
939  InitInfo.pwzTargetComputer = NULL;
940  InitInfo.cDsScopeInfos = COUNT_OF(Scopes);
941  InitInfo.aDsScopeInfos = Scopes;
942  InitInfo.flOptions = 0;
943  InitInfo.cAttributesToFetch = 0;
944  InitInfo.apwzAttributeNames = NULL;
945 
946  hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
947  &InitInfo);
948 
949  if (FAILED(hRet))
950  {
951  /* delete the object picker in case initialization failed! */
952  (*pDsObjectPicker)->lpVtbl->Release(*pDsObjectPicker);
953  }
954  }
955 
956  return hRet;
957 }
#define DSOP_SCOPE_TYPE_GLOBAL_CATALOG
Definition: objsel.h:125
ULONG cAttributesToFetch
Definition: objsel.h:114
PCWSTR * apwzAttributeNames
Definition: objsel.h:115
PCWSTR pwzTargetComputer
Definition: objsel.h:110
ULONG cDsScopeInfos
Definition: objsel.h:111
ULONG cbSize
Definition: objsel.h:109
smooth NULL
Definition: ftsmooth.c:416
struct _DSOP_SCOPE_INIT_INFO DSOP_SCOPE_INIT_INFO
#define COUNT_OF(a)
Definition: main.h:33
LONG HRESULT
Definition: typedefs.h:78
PDSOP_SCOPE_INIT_INFO aDsScopeInfos
Definition: objsel.h:112
#define DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN
Definition: objsel.h:126
#define DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN
Definition: objsel.h:123
#define DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE
Definition: objsel.h:130
ULONG flOptions
Definition: objsel.h:113
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define DSOP_SCOPE_TYPE_WORKGROUP
Definition: objsel.h:128
#define S_OK
Definition: intsafe.h:59
#define DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN
Definition: objsel.h:122
#define DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN
Definition: objsel.h:127
#define DSOP_FILTER_COMPUTERS
Definition: objsel.h:41
#define DSOP_DOWNLEVEL_FILTER_COMPUTERS
Definition: objsel.h:54
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE
Definition: objsel.h:129

Referenced by _CmdWndProc().

◆ InitOpenFileName()

static BOOL InitOpenFileName ( HWND  hWnd,
OPENFILENAME pofn 
)
static

Definition at line 265 of file framewnd.c.

266 {
267  FILTERPAIR FilterPairs[4];
268  static WCHAR Filter[1024];
269 
270  memset(pofn, 0, sizeof(OPENFILENAME));
271  pofn->lStructSize = sizeof(OPENFILENAME);
272  pofn->hwndOwner = hWnd;
273  pofn->hInstance = hInst;
274 
275  /* create filter string */
276  FilterPairs[0].DisplayID = IDS_FLT_REGFILES;
277  FilterPairs[0].FilterID = IDS_FLT_REGFILES_FLT;
278  FilterPairs[1].DisplayID = IDS_FLT_HIVFILES;
279  FilterPairs[1].FilterID = IDS_FLT_HIVFILES_FLT;
280  FilterPairs[2].DisplayID = IDS_FLT_REGEDIT4;
281  FilterPairs[2].FilterID = IDS_FLT_REGEDIT4_FLT;
282  FilterPairs[3].DisplayID = IDS_FLT_ALLFILES;
283  FilterPairs[3].FilterID = IDS_FLT_ALLFILES_FLT;
284  BuildFilterStrings(Filter, FilterPairs, COUNT_OF(FilterPairs));
285 
286  pofn->lpstrFilter = Filter;
287  pofn->lpstrFile = FileNameBuffer;
288  pofn->nMaxFile = _MAX_PATH;
290  pofn->nMaxFileTitle = _MAX_PATH;
291  pofn->Flags = OFN_HIDEREADONLY;
292  pofn->lpstrDefExt = L"reg";
293  return TRUE;
294 }
#define TRUE
Definition: types.h:120
WCHAR FileTitleBuffer[_MAX_PATH]
Definition: framewnd.c:241
#define IDS_FLT_HIVFILES
Definition: resource.h:167
UINT FilterID
Definition: framewnd.c:246
LPSTR lpstrFileTitle
Definition: commdlg.h:338
HWND hwndOwner
Definition: commdlg.h:330
HWND hWnd
Definition: settings.c:17
LPCSTR lpstrDefExt
Definition: commdlg.h:345
DWORD nMaxFile
Definition: commdlg.h:337
UINT DisplayID
Definition: framewnd.c:245
#define IDS_FLT_ALLFILES
Definition: resource.h:171
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
#define _MAX_PATH
Definition: utility.h:77
HINSTANCE hInstance
Definition: commdlg.h:331
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define COUNT_OF(a)
Definition: main.h:33
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD lStructSize
Definition: commdlg.h:329
#define IDS_FLT_REGEDIT4_FLT
Definition: resource.h:170
static const WCHAR L[]
Definition: oid.c:1250
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
void BuildFilterStrings(WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
Definition: framewnd.c:250
#define IDS_FLT_ALLFILES_FLT
Definition: resource.h:172
#define IDS_FLT_HIVFILES_FLT
Definition: resource.h:168
HINSTANCE hInst
Definition: dxdiag.c:13
#define IDS_FLT_REGEDIT4
Definition: resource.h:169
LPSTR lpstrFile
Definition: commdlg.h:336
#define IDS_FLT_REGFILES_FLT
Definition: resource.h:166
LPCSTR lpstrFilter
Definition: commdlg.h:332
WCHAR FileNameBuffer[_MAX_PATH]
Definition: framewnd.c:240
#define memset(x, y, z)
Definition: compat.h:39
DWORD nMaxFileTitle
Definition: commdlg.h:339
DWORD Flags
Definition: commdlg.h:342
#define IDS_FLT_REGFILES
Definition: resource.h:165

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

◆ InvokeRemoteRegistryPickerDialog()

static HRESULT InvokeRemoteRegistryPickerDialog ( IN IDsObjectPicker *  pDsObjectPicker,
IN HWND hwndParent  OPTIONAL,
OUT LPWSTR  lpBuffer,
IN UINT  uSize 
)
static

Definition at line 960 of file framewnd.c.

964 {
965  IDataObject *pdo = NULL;
966  HRESULT hRet;
967 
968  hRet = pDsObjectPicker->lpVtbl->InvokeDialog(pDsObjectPicker,
969  hwndParent,
970  &pdo);
971  if (hRet == S_OK)
972  {
973  STGMEDIUM stm;
974  FORMATETC fe;
975 
976  fe.cfFormat = (CLIPFORMAT) RegisterClipboardFormatW(CFSTR_DSOP_DS_SELECTION_LIST);
977  fe.ptd = NULL;
978  fe.dwAspect = DVASPECT_CONTENT;
979  fe.lindex = -1;
980  fe.tymed = TYMED_HGLOBAL;
981 
982  hRet = pdo->lpVtbl->GetData(pdo,
983  &fe,
984  &stm);
985  if (SUCCEEDED(hRet))
986  {
987  PDS_SELECTION_LIST SelectionList = (PDS_SELECTION_LIST)GlobalLock(stm.hGlobal);
988  if (SelectionList != NULL)
989  {
990  if (SelectionList->cItems == 1)
991  {
992  size_t nlen = wcslen(SelectionList->aDsSelection[0].pwzName);
993  if (nlen >= uSize)
994  {
995  nlen = uSize - 1;
996  }
997 
999  SelectionList->aDsSelection[0].pwzName,
1000  nlen * sizeof(WCHAR));
1001 
1002  lpBuffer[nlen] = L'\0';
1003  }
1004 
1005  GlobalUnlock(stm.hGlobal);
1006  }
1007 
1008  ReleaseStgMedium(&stm);
1009  }
1010 
1011  pdo->lpVtbl->Release(pdo);
1012  }
1013 
1014  return hRet;
1015 }
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
struct _DS_SELECTION_LIST * PDS_SELECTION_LIST
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
#define CFSTR_DSOP_DS_SELECTION_LIST
Definition: objsel.h:27
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
ULONG Release()
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
static const WCHAR L[]
Definition: oid.c:1250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DS_SELECTION aDsSelection[ANYSIZE_ARRAY]
Definition: objsel.h:146
#define S_OK
Definition: intsafe.h:59
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PWSTR pwzName
Definition: objsel.h:134
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by _CmdWndProc().

◆ LoadHive()

static BOOL LoadHive ( HWND  hWnd)
static

Definition at line 352 of file framewnd.c.

353 {
355  WCHAR Caption[128];
356  LPCWSTR pszKeyPath;
358  HKEY hRootKey;
359  WCHAR Filter[1024];
361  /* get the item key to load the hive in */
362  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
363  /* initialize the "open file" dialog */
365  /* build the "All Files" filter up */
366  filter.DisplayID = IDS_FLT_ALLFILES;
367  filter.FilterID = IDS_FLT_ALLFILES_FLT;
370  /* load and set the caption and flags for dialog */
371  LoadStringW(hInst, IDS_LOAD_HIVE, Caption, COUNT_OF(Caption));
372  ofn.lpstrTitle = Caption;
374  /* ofn.lCustData = ;*/
375  /* now load the hive */
376  if (GetOpenFileName(&ofn))
377  {
380  {
381  LONG regLoadResult;
382 
383  /* Enable the 'restore' privilege, load the hive, disable the privilege */
385  regLoadResult = RegLoadKeyW(hRootKey, xPath, ofn.lpstrFile);
387 
388  if(regLoadResult == ERROR_SUCCESS)
389  {
390  /* refresh tree and list views */
392  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
393  RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
394  }
395  else
396  {
397  ErrorMessageBox(hWnd, Caption, regLoadResult);
398  return FALSE;
399  }
400  }
401  }
402  else
403  {
405  }
406  return TRUE;
407 }
#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
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HWND hTreeWnd
Definition: main.h:61
HWND hListWnd
Definition: main.h:62
HWND hWnd
Definition: settings.c:17
OPENFILENAME ofn
Definition: main.cpp:37
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define GetOpenFileName
Definition: commdlg.h:665
#define IDS_FLT_ALLFILES
Definition: resource.h:171
long LONG
Definition: pedump.c:60
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:322
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define IDD_LOADHIVE
Definition: resource.h:264
#define COUNT_OF(a)
Definition: main.h:33
static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:298
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:198
#define IDS_LOAD_HIVE
Definition: resource.h:146
#define SE_RESTORE_NAME
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:670
void BuildFilterStrings(WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
Definition: framewnd.c:250
#define IDS_FLT_ALLFILES_FLT
Definition: resource.h:172
HINSTANCE hInst
Definition: dxdiag.c:13
LPSTR lpstrFile
Definition: commdlg.h:336
#define LOADHIVE_KEYNAMELENGTH
Definition: framewnd.c:296
LPCSTR lpstrFilter
Definition: commdlg.h:332
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define OFN_ENABLESIZING
Definition: commdlg.h:101
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:306
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn)
Definition: framewnd.c:265
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
LONG WINAPI RegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile)
Definition: reg.c:3102
DWORD Flags
Definition: commdlg.h:342

Referenced by _CmdWndProc().

◆ LoadHive_KeyNameInHookProc()

static INT_PTR CALLBACK LoadHive_KeyNameInHookProc ( HWND  hWndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 298 of file framewnd.c.

299 {
300  static LPWSTR sKey = NULL;
301  switch(uMsg)
302  {
303  case WM_INITDIALOG:
304  sKey = (LPWSTR)lParam;
305  break;
306  case WM_COMMAND:
307  switch(LOWORD(wParam))
308  {
309  case IDOK:
311  return EndDialog(hWndDlg, -1);
312  else
313  return EndDialog(hWndDlg, 0);
314  case IDCANCEL:
315  return EndDialog(hWndDlg, 0);
316  }
317  break;
318  }
319  return FALSE;
320 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
#define IDOK
Definition: winuser.h:824
#define IDC_EDIT_KEY
Definition: resource.h:265
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
#define WM_COMMAND
Definition: winuser.h:1722
#define LOADHIVE_KEYNAMELENGTH
Definition: framewnd.c:296
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by LoadHive().

◆ OnEnterMenuLoop()

static void OnEnterMenuLoop ( HWND  hWnd)
static

Definition at line 124 of file framewnd.c.

125 {
126  int nParts;
128 
129  /* Update the status bar pane sizes */
130  nParts = -1;
131  SendMessageW(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
132  bInMenuLoop = TRUE;
134 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
HWND hWnd
Definition: settings.c:17
UINT_PTR WPARAM
Definition: windef.h:207
LONG_PTR LPARAM
Definition: windef.h:208
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXTW
Definition: commctrl.h:1938
static const WCHAR L[]
Definition: oid.c:1250
static BOOL bInMenuLoop
Definition: framewnd.c:35
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_SETPARTS
Definition: commctrl.h:1950

Referenced by FrameWndProc().

◆ OnExitMenuLoop()

static void OnExitMenuLoop ( HWND  hWnd)
static

Definition at line 136 of file framewnd.c.

137 {
138  bInMenuLoop = FALSE;
139  /* Update the status bar pane sizes*/
141  UpdateStatusBar();
142 }
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:168
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
void UpdateStatusBar(void)
Definition: framewnd.c:180
static BOOL bInMenuLoop
Definition: framewnd.c:35

Referenced by FrameWndProc().

◆ OnInitMenu()

static void OnInitMenu ( HWND  hWnd)
static

Definition at line 72 of file framewnd.c.

73 {
74  LONG lResult;
75  HKEY hKey = NULL;
76  DWORD dwIndex, cbValueName, cbValueData, dwType;
77  WCHAR szValueName[256];
78  BYTE abValueData[256];
79  static int s_nFavoriteMenuSubPos = -1;
80  HMENU hMenu;
81  BOOL bDisplayedAny = FALSE;
82 
83  /* Find Favorites menu and clear it out */
85  if (!hMenu)
86  goto done;
87  if (s_nFavoriteMenuSubPos < 0)
88  {
89  s_nFavoriteMenuSubPos = GetMenuItemCount(hMenu);
90  }
91  else
92  {
93  while(RemoveMenu(hMenu, s_nFavoriteMenuSubPos, MF_BYPOSITION)) ;
94  }
95 
97  if (lResult != ERROR_SUCCESS)
98  goto done;
99 
100  dwIndex = 0;
101  do
102  {
103  cbValueName = COUNT_OF(szValueName);
104  cbValueData = sizeof(abValueData);
105  lResult = RegEnumValueW(hKey, dwIndex, szValueName, &cbValueName, NULL, &dwType, abValueData, &cbValueData);
106  if ((lResult == ERROR_SUCCESS) && (dwType == REG_SZ))
107  {
108  if (!bDisplayedAny)
109  {
110  AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
111  bDisplayedAny = TRUE;
112  }
113  AppendMenu(hMenu, 0, ID_FAVORITES_MIN + GetMenuItemCount(hMenu), szValueName);
114  }
115  dwIndex++;
116  }
117  while(lResult == ERROR_SUCCESS);
118 
119 done:
120  if (hKey)
121  RegCloseKey(hKey);
122 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static WCHAR s_szFavoritesRegKey[]
Definition: framewnd.c:33
HWND hWnd
Definition: settings.c:17
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define MF_BYPOSITION
Definition: winuser.h:203
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
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:2853
smooth NULL
Definition: ftsmooth.c:416
#define MF_SEPARATOR
Definition: winuser.h:137
#define COUNT_OF(a)
Definition: main.h:33
#define AppendMenu
Definition: winuser.h:5706
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ID_FAVORITES_MIN
Definition: resource.h:296
#define FAVORITES_MENU_POSITION
Definition: framewnd.c:31
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
unsigned char BYTE
Definition: xxhash.c:193
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define REG_SZ
Definition: layer.c:22

Referenced by FrameWndProc().

◆ OnMenuSelect()

static void OnMenuSelect ( HWND  hWnd,
UINT  nItemID,
UINT  nFlags,
HMENU  hSysMenu 
)
static

Definition at line 144 of file framewnd.c.

145 {
146  WCHAR str[100];
147 
148  wcscpy(str, L"");
149  if (nFlags & MF_POPUP)
150  {
151  if (hSysMenu != GetMenu(hWnd))
152  {
153  if (nItemID == 2) nItemID = 5;
154  }
155  }
156  if (LoadStringW(hInst, nItemID, str, 100))
157  {
158  /* load appropriate string*/
159  LPWSTR lpsz = str;
160  /* first newline terminates actual string*/
161  lpsz = wcschr(lpsz, L'\n');
162  if (lpsz != NULL)
163  *lpsz = L'\0';
164  }
166 }
HWND hWnd
Definition: settings.c:17
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXTW
Definition: commctrl.h:1938
#define MF_POPUP
Definition: winuser.h:136
_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:1250
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HMENU WINAPI GetMenu(_In_ HWND)

Referenced by FrameWndProc().

◆ PrintRegistryHive()

BOOL PrintRegistryHive ( HWND  hWnd,
LPWSTR  path 
)

Definition at line 697 of file framewnd.c.

698 {
699 #if 1
700  PRINTDLG pd;
702 
703  ZeroMemory(&pd, sizeof(PRINTDLG));
704  pd.lStructSize = sizeof(PRINTDLG);
705  pd.hwndOwner = hWnd;
706  pd.hDevMode = NULL; /* Don't forget to free or store hDevMode*/
707  pd.hDevNames = NULL; /* Don't forget to free or store hDevNames*/
709  pd.nCopies = 1;
710  pd.nFromPage = 0xFFFF;
711  pd.nToPage = 0xFFFF;
712  pd.nMinPage = 1;
713  pd.nMaxPage = 0xFFFF;
714  if (PrintDlg(&pd))
715  {
716  /* GDI calls to render output. */
717  DeleteDC(pd.hDC); /* Delete DC when done.*/
718  }
719 #else
720  HRESULT hResult;
721  PRINTDLGEX pd;
722 
723  hResult = PrintDlgEx(&pd);
724  if (hResult == S_OK)
725  {
726  switch (pd.dwResultAction)
727  {
728  case PD_RESULT_APPLY:
729  /*The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked. */
730  break;
731  case PD_RESULT_CANCEL:
732  /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */
733  break;
734  case PD_RESULT_PRINT:
735  /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */
736  break;
737  default:
738  break;
739  }
740  }
741  else
742  {
743  switch (hResult)
744  {
745  case E_OUTOFMEMORY:
746  /*Insufficient memory. */
747  break;
748  case E_INVALIDARG:
749  /* One or more arguments are invalid. */
750  break;
751  case E_POINTER:
752  /*Invalid pointer. */
753  break;
754  case E_HANDLE:
755  /*Invalid handle. */
756  break;
757  case E_FAIL:
758  /*Unspecified error. */
759  break;
760  default:
761  break;
762  }
763  return FALSE;
764  }
765 #endif
766  return TRUE;
767 }
#define TRUE
Definition: types.h:120
WORD nMaxPage
Definition: commdlg.h:474
#define E_HANDLE
Definition: winerror.h:2850
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
HWND hWnd
Definition: settings.c:17
#define ZeroMemory
Definition: winbase.h:1648
WORD nCopies
Definition: commdlg.h:475
#define E_FAIL
Definition: ddrawi.h:102
WORD nMinPage
Definition: commdlg.h:473
#define PrintDlg
Definition: commdlg.h:668
#define PD_USEDEVMODECOPIESANDCOLLATE
Definition: commdlg.h:166
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
WORD nFromPage
Definition: commdlg.h:471
smooth NULL
Definition: ftsmooth.c:416
#define PD_RETURNDC
Definition: commdlg.h:155
LONG HRESULT
Definition: typedefs.h:78
#define PD_RESULT_PRINT
Definition: commdlg.h:202
HGLOBAL hDevMode
Definition: commdlg.h:467
#define PD_RESULT_APPLY
Definition: commdlg.h:203
HWND hwndOwner
Definition: commdlg.h:466
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI DeleteDC(_In_ HDC)
HGLOBAL hDevNames
Definition: commdlg.h:468
#define PD_RESULT_CANCEL
Definition: commdlg.h:201
DWORD lStructSize
Definition: commdlg.h:465
WORD nToPage
Definition: commdlg.h:472
PRINTDLGA PRINTDLG
Definition: commdlg.h:660
DWORD Flags
Definition: commdlg.h:470
#define E_POINTER
Definition: winerror.h:2365
HDC hDC
Definition: commdlg.h:469

Referenced by _CmdWndProc().

◆ resize_frame_client()

static void resize_frame_client ( HWND  hWnd)
static

Definition at line 62 of file framewnd.c.

63 {
64  RECT rect;
65 
68 }
static void resize_frame_rect(HWND hWnd, PRECT prect)
Definition: framewnd.c:42
HWND hWnd
Definition: settings.c:17
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by FrameWndProc(), and toggle_child().

◆ resize_frame_rect()

static void resize_frame_rect ( HWND  hWnd,
PRECT  prect 
)
static

Definition at line 42 of file framewnd.c.

43 {
44  RECT rt;
45  /*
46  if (IsWindowVisible(hToolBar)) {
47  SendMessageW(hToolBar, WM_SIZE, 0, 0);
48  GetClientRect(hToolBar, &rt);
49  prect->top = rt.bottom+3;
50  prect->bottom -= rt.bottom+3;
51  }
52  */
54  {
57  prect->bottom -= rt.bottom - rt.top;
58  }
59  MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
60 }
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:168
#define TRUE
Definition: types.h:120
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HWND hWnd
Definition: main.h:60
HWND hStatusBar
Definition: main.cpp:35
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI IsWindowVisible(_In_ HWND)
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by resize_frame_client().

◆ SetupStatusBar()

void SetupStatusBar ( HWND  hWnd,
BOOL  bResize 
)

Definition at line 168 of file framewnd.c.

169 {
170  RECT rc;
171  int nParts;
172  GetClientRect(hWnd, &rc);
173  nParts = rc.right;
174  /* nParts = -1;*/
175  if (bResize)
177  SendMessageW(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
178 }
HWND hWnd
Definition: settings.c:17
LONG right
Definition: windef.h:308
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SIZE
Definition: winuser.h:1593
HWND hStatusBar
Definition: main.cpp:35
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_SETPARTS
Definition: commctrl.h:1950

Referenced by InitInstance(), OnExitMenuLoop(), and resize_frame_rect().

◆ toggle_child()

static void toggle_child ( HWND  hWnd,
UINT  cmd,
HWND  hchild 
)
static

Definition at line 188 of file framewnd.c.

189 {
190  BOOL vis = IsWindowVisible(hchild);
191  HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
192 
194  ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
196 }
#define MF_BYCOMMAND
Definition: winuser.h:202
Definition: ftp_var.h:139
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:62
#define SW_HIDE
Definition: winuser.h:762
HWND hWnd
Definition: settings.c:17
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SW_SHOW
Definition: winuser.h:769
#define MF_CHECKED
Definition: winuser.h:132
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ID_VIEW_MENU
Definition: resource.h:25
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
HMENU hMenuFrame
Definition: main.c:32
BOOL WINAPI IsWindowVisible(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by _CmdWndProc().

◆ UnloadHive()

static BOOL UnloadHive ( HWND  hWnd)
static

Definition at line 409 of file framewnd.c.

410 {
411  WCHAR Caption[128];
412  LPCWSTR pszKeyPath;
413  HKEY hRootKey;
414  LONG regUnloadResult;
415 
416  /* get the item key to unload */
417  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
418  /* load and set the caption and flags for dialog */
419  LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption));
420 
421  /* Enable the 'restore' privilege, unload the hive, disable the privilege */
423  regUnloadResult = RegUnLoadKeyW(hRootKey, pszKeyPath);
425 
426  if(regUnloadResult == ERROR_SUCCESS)
427  {
428  /* refresh tree and list views */
430  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
431  RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
432  }
433  else
434  {
435  ErrorMessageBox(hWnd, Caption, regUnloadResult);
436  return FALSE;
437  }
438  return TRUE;
439 }
#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
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HWND hTreeWnd
Definition: main.h:61
HWND hListWnd
Definition: main.h:62
HWND hWnd
Definition: settings.c:17
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
long LONG
Definition: pedump.c:60
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:322
#define IDS_UNLOAD_HIVE
Definition: resource.h:147
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define COUNT_OF(a)
Definition: main.h:33
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG WINAPI RegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey)
Definition: reg.c:5092
#define SE_RESTORE_NAME
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:670
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:306

Referenced by _CmdWndProc().

◆ UpdateStatusBar()

void UpdateStatusBar ( void  )

Definition at line 180 of file framewnd.c.

181 {
182  HKEY hKeyRoot;
183  LPCWSTR pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
184 
185  SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)pszKeyPath);
186 }
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HWND hTreeWnd
Definition: main.h:61
LONG_PTR LPARAM
Definition: windef.h:208
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXTW
Definition: commctrl.h:1938
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by OnExitMenuLoop().

Variable Documentation

◆ bInMenuLoop

BOOL bInMenuLoop = FALSE
static

Definition at line 35 of file framewnd.c.

Referenced by OnEnterMenuLoop(), and OnExitMenuLoop().

◆ FileNameBuffer

◆ FileTitleBuffer

WCHAR FileTitleBuffer[_MAX_PATH]

Definition at line 241 of file framewnd.c.

Referenced by InitOpenFileName().

◆ s_szFavoritesRegKey

WCHAR s_szFavoritesRegKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites"
static

Definition at line 33 of file framewnd.c.

Referenced by ChooseFavorite(), and OnInitMenu().

◆ Suggestions

WCHAR Suggestions[256]

Definition at line 27 of file childwnd.c.

Referenced by _CmdWndProc(), and ChildWndProc().