From: <mie...@us...> - 2009-07-04 21:11:38
|
Revision: 4873 http://oorexx.svn.sourceforge.net/oorexx/?rev=4873&view=rev Author: miesfeld Date: 2009-07-04 21:11:37 +0000 (Sat, 04 Jul 2009) Log Message: ----------- [2790115] WindowsRegistry::delete() incorrect Modified Paths: -------------- main/trunk/extensions/platform/windows/rxwinsys/rxwinsys.cpp main/trunk/extensions/platform/windows/rxwinsys/winsystm.cls Modified: main/trunk/extensions/platform/windows/rxwinsys/rxwinsys.cpp =================================================================== --- main/trunk/extensions/platform/windows/rxwinsys/rxwinsys.cpp 2009-07-04 01:32:08 UTC (rev 4872) +++ main/trunk/extensions/platform/windows/rxwinsys/rxwinsys.cpp 2009-07-04 21:11:37 UTC (rev 4873) @@ -276,10 +276,59 @@ } +// TODO This is a function from oodCommon.cpp, need to put all this stuff together. +POINTER rxGetPointerAttribute(RexxMethodContext *context, RexxObjectPtr obj, CSTRING name) +{ + CSTRING value = ""; + if ( obj != NULLOBJECT ) + { + RexxObjectPtr rxString = context->SendMessage0(obj, name); + if ( rxString != NULLOBJECT ) + { + value = context->ObjectToStringValue(rxString); + } + } + POINTER p = NULL; + string2pointer(value, &p); + return p; +} + + +/** WindowsRegistry::delete() | WindowsRegistry::deleteKey() + * + * Deletes a registry key. Maps to both the delete() and the deleteKey() + * methods. + * + * delete() deletes a subkey and all its descendents (subkeys.) deleteKey() + * will only delete the subkey if it is empty, i.e. it contains no subkeys. + * + * @param hkHandle [optional] A handle to an open registry key. The key must + * have been opened with the DELETE access right. If this + * argument is omitted then the CURRENT_KEY attribute is + * used. + * + * @param subkeyName The name of the subkey to be deleted. The name is case + * insensitive. + * + * @return O on success, otherwise the Windows system error code. + */ +RexxMethod3(uint32_t, WSRegistry_delete, OPTIONAL_POINTERSTRING, hkHandle, CSTRING, subKeyName, OSELF, self) +{ + HKEY hk = (HKEY)(argumentExists(1) ? hkHandle : rxGetPointerAttribute(context, self, "CURRENT_KEY")); + + if ( strcmp(c->GetMessageName(), "DELETEKEY") == 0 ) + { + return RegDeleteKey(hk, subKeyName); + } + else + { + return SHDeleteKey(hk, subKeyName); + } +} + size_t RexxEntry WSRegistryKey(const char *funcname, size_t argc, CONSTRXSTRING argv[], const char *qname, PRXSTRING retstr) { HKEY hk; - LONG rc; CHECKARG(2,5); @@ -347,19 +396,6 @@ RETC(1); } } - else if ( strcmp(argv[0].strptr, "DELETE") == 0 ) - { - GET_HKEY(argv[1].strptr, hk); - - if ((rc = RegDeleteKey(hk, argv[2].strptr)) == ERROR_SUCCESS) - { - RETC(0); - } - else - { - RETVAL(rc); - } - } else if ( strcmp(argv[0].strptr, "QUERY") == 0 ) { char Class[256]; @@ -3912,6 +3948,8 @@ RexxMethodEntry rxwinsys_methods[] = { + REXX_METHOD(WSRegistry_delete, WSRegistry_delete), + REXX_METHOD(WSEventLog_test, WSEventLog_test), REXX_METHOD(WSEventLog_init, WSEventLog_init), REXX_METHOD(WSEventLog_uninit, WSEventLog_uninit), Modified: main/trunk/extensions/platform/windows/rxwinsys/winsystm.cls =================================================================== --- main/trunk/extensions/platform/windows/rxwinsys/winsystm.cls 2009-07-04 01:32:08 UTC (rev 4872) +++ main/trunk/extensions/platform/windows/rxwinsys/winsystm.cls 2009-07-04 21:11:37 UTC (rev 4873) @@ -123,11 +123,8 @@ return retc -::method Delete - use arg hkey, subkey - if arg(1,'o') = 1 then hkey = self~Current_Key - retc = WSRegistryKey("DELETE", hkey, subkey) - return retc +::method deleteKey external "LIBRARY rxwinsys WSRegistry_delete" +::method delete external "LIBRARY rxwinsys WSRegistry_delete" ::method SetValue use arg hkey, name, valu, atype This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |