mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-04 18:57:38 +00:00
Added support for creating new keys.
This commit is contained in:
parent
32c7454d75
commit
071b7dae8a
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue