LPARAMETERS thKey, tcValueName, tcValueData, tcValueType
*
* Set specified value on current registry key
*
LOCAL nResult,nLen,cOutBuff
LOCAL x,b,i,b0,b1,b2,b3,t
nResult = 0
#INCLUDE REGISTRY.H
DECLARE INTEGER RegSetValueEx IN Win32API ;
INTEGER nKeyHandle, ;
STRING cValueName, ;
INTEGER nReserved, ;
INTEGER nType, ;
STRING cBuffer, ;
INTEGER nBufferSize
*
* If no Registry Key is open, we fail. Pass the registry key in as first parm
*
IF TYPE('thKey') # 'N' OR thKey = 0
RETURN .F.
ENDIF
*
* Build a buffer to hold the output value based on the type specified in tcValueType
*
DO CASE
CASE tcValueType = 'STRING'
nLen = LEN(tcValueData)
cOutBuff = tcValueData + CHR(0)
nType = REG_SZ
CASE tcValueType = 'BIN'
nLen = LEN(tcValueData)
cOutBuff = tcValueData
nType = REG_BINARY
CASE tcValueType = 'MULTIZ'
nLen = LEN(tcValueData)
cOutBuff = tcValueData+CHR(0)
nType = REG_MULTI_SZ
CASE tcValueType = 'DWORD'
nLen = 4
x=int(tcValueData)
FOR i=3 to 0 step -1
t=CHR(48+i)
b=INT(x/(256^i))
b&t=b
x=x-b*(256^i)
ENDFOR
cOutBuff = CHR(b0)+CHR(b1)+CHR(b2)+CHR(b3)
nType = REG_DWORD
OTHERWISE
nType = 0
ENDCASE
nResult = RegSetValueEx(thkey, ;
tcValueName, ;
REG_OPTION_RESERVED, ;
nType, ;
cOutBuff, ;
nLen )
RETURN (nResult=0)EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater
NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC
The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys