16101 sub := top createSubKeyNamed:'FooBarBaz'. |
16101 sub := top createSubKeyNamed:'FooBarBaz'. |
16102 top deleteSubKeyNamed:'FooBarBaz' flags:nil. |
16102 top deleteSubKeyNamed:'FooBarBaz' flags:nil. |
16103 " |
16103 " |
16104 ! |
16104 ! |
16105 |
16105 |
16106 remoteKeyOnHost:hostNameString |
16106 remoteKeyOnHost:hostName |
16107 "return the corresponding registry entry from |
16107 "return the corresponding registry entry from |
16108 a remote computers registry. |
16108 a remote computers registry. |
16109 Note: The registry key must be form a predefined list defined by Microsoft." |
16109 Note: The registry key must be form a predefined list defined by Microsoft." |
16110 |
16110 |
16111 |hostNameUtf16Z newEntry remoteHandle errorNumber| |
16111 |hostNameUtf16Z newEntry remoteHandle errorNumber| |
16112 |
16112 |
16113 hostNameUtf16Z := hostNameString notEmptyOrNil ifTrue:[hostNameString asUnicode16StringZ]. |
16113 hostNameUtf16Z := hostName notEmptyOrNil ifTrue:[hostName asUnicode16StringZ]. |
16114 |
16114 |
16115 %{ |
16115 %{ |
16116 HKEY myKey, remoteKey = 0; |
16116 HKEY myKey, remoteKey = 0; |
16117 int _retVal; |
16117 int _retVal; |
16118 |
16118 |
16119 /* Notes from MSDN: |
16119 /* Notes from MSDN: |
16120 * link: https://docs.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regconnectregistryw |
16120 * link: https://docs.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regconnectregistryw |
16121 * |
16121 * |
16122 * 1) RegConnectRegistry requires the Remote Registry service to be running on the remote computer. |
16122 * 1) RegConnectRegistry requires the Remote Registry service to be running on the remote computer. |
16123 * By default, this service is configured to be started manually. To configure the Remote Registry |
16123 * By default, this service is configured to be started manually. To configure the Remote Registry |
16124 * service to start automatically, run Services.msc and change the Startup Type of the service to Automatic. |
16124 * service to start automatically, run Services.msc and change the Startup Type of the service to Automatic. |
16125 * |
16125 * |
16126 * 2) If the computer is joined to a workgroup and the "Force network logons using local accounts to authenticate as |
16126 * 2) If the computer is joined to a workgroup and the "Force network logons using local accounts to authenticate as |
16127 * Guest" policy is enabled, the function fails. Note that this policy is enabled by default if the computer is joined |
16127 * Guest" policy is enabled, the function fails. Note that this policy is enabled by default if the computer is joined |
16128 * to a workgroup. |
16128 * to a workgroup. |
16129 * |
16129 * |
16130 * 3) If the current user does not have proper access to the remote computer, the call to RegConnectRegistry fails. To connect |
16130 * 3) If the current user does not have proper access to the remote computer, the call to RegConnectRegistry fails. To connect |
16131 * to a remote registry, call LogonUser with LOGON32_LOGON_NEW_CREDENTIALS and ImpersonateLoggedOnUser before calling |
16131 * to a remote registry, call LogonUser with LOGON32_LOGON_NEW_CREDENTIALS and ImpersonateLoggedOnUser before calling |
16132 * RegConnectRegistry. |
16132 * RegConnectRegistry. |
16133 * |
16133 * |
16134 * 4) myKey must be a predefined registry handle. |
16134 * 4) myKey must be a predefined registry handle. |
16135 * more at: https://docs.microsoft.com/en-us/windows/desktop/SysInfo/predefined-keys |
16135 * more at: https://docs.microsoft.com/en-us/windows/desktop/SysInfo/predefined-keys |
16136 * |
16136 * |
16137 * 5) When a handle returned by RegConnectRegistry is no longer needed, it should be closed by calling RegCloseKey. (done by registerForFinaliation) |
16137 * 5) When a handle returned by RegConnectRegistry is no longer needed, it should be closed by calling RegCloseKey. (done by registerForFinaliation) |
16138 * |
16138 * |
16139 */ |
16139 */ |
16140 |
16140 |
16141 if (__isExternalAddressLike(__INST(handle)) && __isUnicode16String(hostNameUtf16Z)) { |
16141 if (__isExternalAddressLike(__INST(handle)) && __isUnicode16String(hostNameUtf16Z)) { |
16142 myKey = (HKEY)__externalAddressVal(__INST(handle)); |
16142 myKey = (HKEY)__externalAddressVal(__INST(handle)); |
16143 if ((_retVal = RegConnectRegistryW(__unicode16StringVal(hostNameUtf16Z), myKey, &remoteKey)) == ERROR_SUCCESS) { |
16143 if ((_retVal = RegConnectRegistryW(__unicode16StringVal(hostNameUtf16Z), myKey, &remoteKey)) == ERROR_SUCCESS) { |
16144 remoteHandle = __MKEXTERNALADDRESS(remoteKey); |
16144 remoteHandle = __MKEXTERNALADDRESS(remoteKey); |
16547 " |
16547 " |
16548 (self key:'HKEY_CLASSES_ROOT\MicrosoftWorks.WordProcessor\CLSID') defaultValue |
16548 (self key:'HKEY_CLASSES_ROOT\MicrosoftWorks.WordProcessor\CLSID') defaultValue |
16549 " |
16549 " |
16550 ! |
16550 ! |
16551 |
16551 |
16552 deleteValueNamed:aValueName |
16552 deleteValueNamed:name |
16553 "delete a value. |
16553 "delete a value. |
16554 Return true on success." |
16554 Return true on success." |
16555 |
16555 |
16556 |errorNumber| |
16556 |nameUtf16Z errorNumber| |
|
16557 |
|
16558 "/ name must be a string |
|
16559 name isString ifFalse: [ |
|
16560 Transcript showCR: 'The registry value name must be a String!!'. |
|
16561 ^ false |
|
16562 ]. |
|
16563 |
|
16564 "/ adding terminating null into empty string |
|
16565 name notNil ifTrue:[ |
|
16566 nameUtf16Z := name isEmpty ifTrue:[(name, (Character codePoint: 0)) asUnicode16String] "/ needed for defaultValue |
|
16567 ifFalse:[name asUnicode16StringZ] |
|
16568 ]. |
16557 |
16569 |
16558 %{ |
16570 %{ |
16559 HKEY myKey; |
16571 HKEY myKey = 0; |
16560 int _retVal; |
16572 int _retVal; |
16561 |
16573 |
16562 if (__isExternalAddressLike(__INST(handle)) |
16574 if (__isExternalAddressLike(__INST(handle)) |
16563 && __isStringLike(aValueName)) { |
16575 && __isUnicode16String(nameUtf16Z)) { |
16564 myKey = (HKEY)__externalAddressVal(__INST(handle)); |
16576 myKey = (HKEY)__externalAddressVal(__INST(handle)); |
16565 if ((_retVal = RegDeleteValueA(myKey, __stringVal(aValueName))) == ERROR_SUCCESS) { |
16577 if ((_retVal = RegDeleteValueW(myKey, __unicode16StringVal(nameUtf16Z))) == ERROR_SUCCESS) { |
16566 RETURN (true); |
16578 RETURN (true); |
16567 } |
16579 } |
16568 if ((_retVal != ERROR_PATH_NOT_FOUND) |
16580 if ((_retVal != ERROR_PATH_NOT_FOUND) |
16569 && (_retVal != ERROR_FILE_NOT_FOUND)) { |
16581 && (_retVal != ERROR_FILE_NOT_FOUND)) { |
16570 errorNumber = __MKSMALLINT(_retVal); |
16582 errorNumber = __MKSMALLINT(_retVal); |
16571 } |
16583 } |
16572 } |
16584 } |
16573 %}. |
16585 %}. |
16574 errorNumber notNil ifTrue:[ |
16586 errorNumber notNil ifTrue:[ |
16575 (OperatingSystem errorHolderForNumber:errorNumber) reportError. |
16587 (OperatingSystem errorHolderForNumber:errorNumber) reportError. |
16576 ]. |
16588 ]. |
16961 Transcript showCR: 'The registry value name must be a String!!'. |
16973 Transcript showCR: 'The registry value name must be a String!!'. |
16962 ^ nil |
16974 ^ nil |
16963 ]. |
16975 ]. |
16964 "/ name asUnicodeString and null terminated |
16976 "/ name asUnicodeString and null terminated |
16965 name notNil ifTrue:[ |
16977 name notNil ifTrue:[ |
16966 name isEmpty ifTrue:[nameUtf16Z := (name, (Character codePoint: 0)) asUnicode16String] "/ needed for defaultValue: |
16978 nameUtf16Z := name isEmpty ifTrue:[(name, (Character codePoint: 0)) asUnicode16String] "/ needed for defaultValue: |
16967 ifFalse:[nameUtf16Z := name asUnicode16StringZ] |
16979 ifFalse:[name asUnicode16StringZ] |
16968 ]. |
16980 ]. |
16969 "/ data asUnicode16String and null terminated |
16981 "/ data asUnicode16String and null terminated |
16970 data notNil ifTrue:[ |
16982 data notNil ifTrue:[ |
16971 data isString ifTrue:[ |
16983 data isString ifTrue:[ |
16972 data isEmpty ifTrue:[dataUtf16Z := (data, (Character codePoint: 0)) asUnicode16String] "/ for empty data strings |
16984 dataUtf16Z := data isEmpty ifTrue:[(data, (Character codePoint: 0)) asUnicode16String] "/ for empty data strings |
16973 ifFalse:[dataUtf16Z := data asUnicode16StringZ] |
16985 ifFalse:[ data asUnicode16StringZ] |
16974 ]. |
16986 ]. |
16975 data isArray ifTrue:[ |
16987 data isArray ifTrue:[ |
16976 dataUtf16Z := data collect:[:eachString | "/ for every Array member to be null terminated |
16988 dataUtf16Z := data collect:[:eachString | "/ for every Array member to be null terminated |
16977 eachString asUnicode16StringZ |
16989 eachString asUnicode16StringZ |
16978 ] |
16990 ] |