New registry key adding patch

Zimler Attila hijaszu at hlfslinux.hu
Wed Dec 31 10:18:19 CST 2003


Hi,

I made the regedit program able to add new registry key (however, the 
key does not appear until next run of regedit in the browser tree - as I 
consulted it with Dimitrie, it will be handled later).

The diff is made against todays cvs tree (as 2003 december 31).

Attila

PS: Dimitrie: what is the next step to do?
-------------- next part --------------
diff -r -d -c -N wine/programs/regedit/edit.c wine.new_regkey/programs/regedit/edit.c
*** wine/programs/regedit/edit.c	2003-12-12 04:08:59.000000000 +0000
--- wine.new_regkey/programs/regedit/edit.c	2003-12-31 14:36:44.000000000 +0000
***************
*** 17,22 ****
--- 17,25 ----
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   */
+ /* Modified by Attila ZIMLER <hijaszu at hlfslinux.hu> on 28th of dec 2003.
+     - New key adding is now supported.
+ */
  
  #define WIN32_LEAN_AND_MEAN     /* Exclude rarely-used stuff from Windows headers */
  
***************
*** 91,96 ****
--- 94,129 ----
      return FALSE;
  }
  
+ BOOL CreateKey(HKEY hKey)
+ {
+     LONG lRet;
+     HKEY retKey;
+     char* keyName = 0;
+     unsigned int keyNum = 1;
+          
+     /* If we have illegal parameter return with operation failure */
+     if (!hKey) return FALSE;
+     
+     /* try to find out a name for the newly create key */
+     /* TODO: warning is issued because asprintf's implicit declaration,
+ 	I tried to declare it as
+ 	extern "C" ssize_t asprintf(char**, const char**, ...)
+ 	which is the format of this function, but it seems not helping.
+ 	Don't know why :(
+ 	*/
+     asprintf(&keyName, "new key");
+     lRet = RegOpenKey(hKey, keyName, &retKey);
+     while (lRet == ERROR_SUCCESS) {
+ 	    asprintf(&keyName, "new key %u", ++keyNum);
+ 	    lRet = RegOpenKey(hKey, keyName, &retKey);
+     }
+     
+     lRet = RegCreateKey(hKey, keyName, &retKey);
+     
+     free(keyName);
+     return lRet == ERROR_SUCCESS;
+ }
+ 
  BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
  {
      DWORD valueDataLen;
diff -r -d -c -N wine/programs/regedit/framewnd.c wine.new_regkey/programs/regedit/framewnd.c
*** wine/programs/regedit/framewnd.c	2003-12-12 04:08:59.000000000 +0000
--- wine.new_regkey/programs/regedit/framewnd.c	2003-12-31 14:38:34.000000000 +0000
***************
*** 469,474 ****
--- 469,478 ----
      case ID_EDIT_COPYKEYNAME:
          CopyKeyName(hWnd, _T(""));
          break;
+     case ID_EDIT_NEW_KEY:
+ 	if (CreateKey(hKey))
+ 	    RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+ 	break;
      case ID_REGISTRY_PRINTERSETUP:
          /*PRINTDLG pd;*/
          /*PrintDlg(&pd);*/
diff -r -d -c -N wine/programs/regedit/main.h wine.new_regkey/programs/regedit/main.h
*** wine/programs/regedit/main.h	2003-12-12 04:08:59.000000000 +0000
--- wine.new_regkey/programs/regedit/main.h	2003-12-31 14:39:57.000000000 +0000
***************
*** 93,98 ****
--- 93,99 ----
  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__ */


More information about the wine-devel mailing list