Commit 071b7dae authored by Zimler Attila's avatar Zimler Attila Committed by Alexandre Julliard

Added support for creating new keys.

parent 32c7454d
......@@ -201,6 +201,7 @@ BEGIN
IDS_BAD_VALUE "Can't query value '%s'"
IDS_UNSUPPORTED_TYPE "Can't edit keys of this type (%ld)"
IDS_TOO_BIG_VALUE "Value is too big (%ld)"
IDS_NEWKEY "New Key"
END
/*****************************************************************/
......
......@@ -91,6 +91,40 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
return FALSE;
}
BOOL CreateKey(HKEY hKey)
{
LONG lRet;
HKEY retKey;
TCHAR keyName[32];
static TCHAR newKey[28] = ""; /* should be max keyName len - 4 */
HINSTANCE hInstance;
unsigned int keyNum = 1;
/* 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) {
sprintf(keyName, "%s %u", newKey, ++keyNum);
lRet = RegOpenKey(hKey, keyName, &retKey);
}
if (lRet == ERROR_SUCCESS) return FALSE;
lRet = RegCreateKey(hKey, keyName, &retKey);
return lRet == ERROR_SUCCESS;
}
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
{
DWORD valueDataLen;
......
......@@ -469,6 +469,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case ID_EDIT_COPYKEYNAME:
CopyKeyName(hWnd, _T(""));
break;
case ID_EDIT_NEW_KEY:
CreateKey(hKey);
break;
case ID_REGISTRY_PRINTERSETUP:
/*PRINTDLG pd;*/
/*PrintDlg(&pd);*/
......
......@@ -93,6 +93,7 @@ extern BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);
extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
/* edit.c */
BOOL CreateKey(HKEY hKey);
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
#endif /* __MAIN_H__ */
......@@ -106,6 +106,7 @@
#define IDS_BAD_VALUE 32837
#define IDS_UNSUPPORTED_TYPE 32838
#define IDS_TOO_BIG_VALUE 32839
#define IDS_NEWKEY 32840
#define IDD_EDIT_STRING 2000
#define IDC_VALUE_NAME 2001
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment