regedit: new value support
Dimitrie O. Paun
dpaun at rogers.com
Tue Jan 6 00:47:44 CST 2004
ChangeLog
Add new value support. Misc improvements and cleanups.
Index: programs/regedit/En.rc
===================================================================
RCS file: /var/cvs/wine/programs/regedit/En.rc,v
retrieving revision 1.5
diff -u -r1.5 En.rc
--- programs/regedit/En.rc 5 Jan 2004 21:14:19 -0000 1.5
+++ programs/regedit/En.rc 6 Jan 2004 06:26:52 -0000
@@ -218,7 +218,8 @@
IDS_TOO_BIG_VALUE "Value is too big (%ld)"
IDS_DELETE_BOX_TITLE "Confirm Value Delete"
IDS_DELETE_BOX_TEXT "Are you sure you want to delete value '%s'?"
- IDS_NEWKEY "New Key"
+ IDS_NEWKEY "New Key #%d"
+ IDS_NEWVALUE "New Value #%d"
END
/*****************************************************************/
Index: programs/regedit/edit.c
===================================================================
RCS file: /var/cvs/wine/programs/regedit/edit.c,v
retrieving revision 1.5
diff -u -r1.5 edit.c
--- programs/regedit/edit.c 5 Jan 2004 21:14:19 -0000 1.5
+++ programs/regedit/edit.c 6 Jan 2004 06:43:13 -0000
@@ -130,33 +130,28 @@
LONG lRet;
HKEY retKey;
TCHAR keyName[32];
- static TCHAR newKey[28] = ""; /* should be max keyName len - 4 */
- HINSTANCE hInstance;
- unsigned int keyNum = 1;
+ TCHAR newKey[COUNT_OF(keyName) - 4];
+ int keyNum;
/* If we have illegal parameter return with operation failure */
if (!hKey) return FALSE;
- /* Load localized "new key" string. -4 is because we need max 4 character
- to numbering. */
- if (newKey[0] == 0) {
- hInstance = GetModuleHandle(0);
- if (!LoadString(hInstance, IDS_NEWKEY, newKey, COUNT_OF(newKey)))
- lstrcpy(newKey, "New Key");
- }
- lstrcpy(keyName, newKey);
-
- /* try to find out a name for the newly create key.
- We try it max 100 times. */
- lRet = RegOpenKey(hKey, keyName, &retKey);
- while (lRet == ERROR_SUCCESS && keyNum < 100) {
- wsprintf(keyName, "%s %u", newKey, ++keyNum);
+ if (!LoadString(GetModuleHandle(0), IDS_NEWKEY, newKey, COUNT_OF(newKey))) return FALSE;
+
+ /* try to find out a name for the newly create key (max 100 times) */
+ for (keyNum = 1; keyNum < 100; keyNum++) {
+ wsprintf(keyName, newKey, keyNum);
lRet = RegOpenKey(hKey, keyName, &retKey);
+ if (lRet != ERROR_SUCCESS) break;
+ RegCloseKey(retKey);
}
if (lRet == ERROR_SUCCESS) return FALSE;
lRet = RegCreateKey(hKey, keyName, &retKey);
- return lRet == ERROR_SUCCESS;
+ if (lRet != ERROR_SUCCESS) return FALSE;
+
+ RegCloseKey(retKey);
+ return TRUE;
}
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
@@ -225,4 +220,31 @@
error(hwnd, IDS_BAD_VALUE, valueName);
}
return lRet == ERROR_SUCCESS;
+}
+
+BOOL CreateValue(HWND hwnd, HKEY hKey, DWORD valueType)
+{
+ LONG lRet;
+ TCHAR valueName[32];
+ TCHAR newValue[COUNT_OF(valueName) - 4];
+ DWORD valueDword = 0;
+ int valueNum;
+
+ /* If we have illegal parameter return with operation failure */
+ if (!hKey) return FALSE;
+
+ if (!LoadString(GetModuleHandle(0), IDS_NEWVALUE, newValue, COUNT_OF(newValue))) return FALSE;
+
+ /* try to find out a name for the newly create key (max 100 times) */
+ for (valueNum = 1; valueNum < 100; valueNum++) {
+ wsprintf(valueName, newValue, valueNum);
+ lRet = RegQueryValueEx(hKey, valueName, 0, 0, 0, 0);
+ if (lRet != ERROR_SUCCESS) break;
+ }
+ if (lRet == ERROR_SUCCESS) return FALSE;
+
+ lRet = RegSetValueEx(hKey, valueName, 0, valueType, (BYTE*)&valueDword, sizeof(DWORD));
+ if (lRet != ERROR_SUCCESS) return FALSE;
+
+ return TRUE;
}
Index: programs/regedit/framewnd.c
===================================================================
RCS file: /var/cvs/wine/programs/regedit/framewnd.c,v
retrieving revision 1.7
diff -u -r1.7 framewnd.c
--- programs/regedit/framewnd.c 5 Jan 2004 21:14:19 -0000 1.7
+++ programs/regedit/framewnd.c 6 Jan 2004 06:22:44 -0000
@@ -440,6 +440,7 @@
LPCTSTR valueName;
BOOL result = TRUE;
LONG lRet;
+ DWORD valueType;
if ((keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot))) {
lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_ALL_ACCESS, &hKey);
@@ -475,6 +476,19 @@
case ID_EDIT_NEW_KEY:
CreateKey(hKey);
break;
+ case ID_EDIT_NEW_STRINGVALUE:
+ valueType = REG_SZ;
+ goto create_value;
+ case ID_EDIT_NEW_BINARYVALUE:
+ valueType = REG_BINARY;
+ goto create_value;
+ case ID_EDIT_NEW_DWORDVALUE:
+ valueType = REG_DWORD;
+ /* fall through */
+ create_value:
+ if (CreateValue(hWnd, hKey, valueType))
+ RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+ break;
case ID_REGISTRY_PRINTERSETUP:
/*PRINTDLG pd;*/
/*PrintDlg(&pd);*/
Index: programs/regedit/main.h
===================================================================
RCS file: /var/cvs/wine/programs/regedit/main.h,v
retrieving revision 1.10
diff -u -r1.10 main.h
--- programs/regedit/main.h 5 Jan 2004 21:14:19 -0000 1.10
+++ programs/regedit/main.h 6 Jan 2004 06:00:25 -0000
@@ -94,6 +94,7 @@
/* edit.c */
extern BOOL CreateKey(HKEY hKey);
+extern BOOL CreateValue(HWND hwnd, HKEY hKey, DWORD valueType);
extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
extern BOOL DeleteValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
Index: programs/regedit/resource.h
===================================================================
RCS file: /var/cvs/wine/programs/regedit/resource.h,v
retrieving revision 1.4
diff -u -r1.4 resource.h
--- programs/regedit/resource.h 5 Jan 2004 21:14:19 -0000 1.4
+++ programs/regedit/resource.h 6 Jan 2004 06:02:55 -0000
@@ -113,6 +113,7 @@
#define IDC_DWORD_HEX 32853
#define IDC_DWORD_DEC 32854
#define IDS_NEWKEY 32860
+#define IDS_NEWVALUE 32861
#define IDD_EDIT_STRING 2000
#define IDC_VALUE_NAME 2001
--
Dimi.
More information about the wine-patches
mailing list