REG_NONE

Started by naholt, August 03, 2015, 09:50:47 AM

Previous topic - Next topic

naholt

I am converting a string over from a batch file to winbatch but I have hit a snag.  its calls for a "reg_none".  I have never seen this and need to convert it over to winbatch.  here is the string from a batch file: reg add "HKEY_LOCAL_MACHINE\default\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mpp\OpenWithProgids" /V "MSProject.Project.9" /T "REG_NONE" /D "000".  This is  a new one for me.

thank you for  your help
Nicholas

td

Unfortunately, the WIL registry functions don't offer much support for the value type of 'REG_NONE'.  There are multiple ways to work around this but the simplest and most reliable way may be to simply call the appropriate Win32 API functions:

Code (winbatch) Select
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  RegCreateValueNone - creates a zero length
;;                       registry value.
;;     _hKey - Target registry key open with write
;;             access.
;;     _strValuName - Name of key to create.
;;
;;   Retuns zero on success, otherwise, non-zero
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#definefunction RegCreateValueNone( _hKey, _strValName)
   REG_NONE = 0
   return DllCall('Advapi32.dll',long:'RegSetValueExW',long:_hKey,lpwstr:_strValName,long:0,long:REG_NONE,long:0,long:0)
#endfunction


;; Test
hKey = RegOpenKeyEx(@REGCURRENT ,'Software\Wilson WindowWare','FULL',0,"")
strTestVal = 'TestNone'
nResult = RegCreateValueNone(hKey, strTestVal)
RegCloseKey(hKey)
if nResult == 0 then strText = 'Succeeded'
else strText = 'Failed'
Message('Create Empty Value', strText)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

naholt

that worked perfectly!!!!!

thank you very much