<b>* method _SetKeyValue</b> lparameters pcValueName, puValue * this routine sets a key value local lnValueSize, lcValue, lcValueType this.mnErrorNum = ERROR_SUCCESS lcValueType = type( "puValue" ) do case case ( this.mnCurrentKey = 0 ) this.mnErrorNum = ERROR_BADKEY case ( type( "pcValueName" ) != "C" ) this.mnErrorNum = ERROR_BADPARM case ( this.mnKeyType = REG_NONE ) * new key, so set type according to puValue do case case ( lcValueType == "C" ) this.mnKeyType = REG_SZ case ( lcValueType == "N" ) this.mnKeyType = REG_DWORD otherwise this.mnErrorNum = ERROR_BADPARM endcase case ( ( lcValueType == "C" ) and ( this.mnKeyType != REG_SZ ) ) this.mnErrorNum = ERROR_NONSTR_DATA case ( ( lcValueType == "N" ) and ( this.mnKeyType != REG_DWORD ) ) this.mnErrorNum = ERROR_NONDWORD_DATA case empty( pcValueName ) and empty( puValue ) this.mnErrorNum = ERROR_BADPARM endcase if ( this.mnErrorNum != ERROR_SUCCESS ) return this.mnErrorNum endif * fix up the value to store in the registry do case case ( this.mnKeyType = REG_SZ ) * Make sure we null terminate this guy lcValue = puValue + chr(0) lnValueSize = len( lcValue ) case ( this.mnKeyType = REG_DWORD ) lcValue = ToLong( puValue ) lnValueSize = 4 endcase * Set the key value this.mnErrorNum = RegSetValueEx( this.mnCurrentKey, @pcValueName, 0, this.mnKeyType, ; @lcValue, lnValueSize ) if ( this.mnErrorNum == ERROR_SUCCESS ) this.mnMaxValueDataLen = max( this.mnMaxValueDataLen, lnValueSize ) * update the object properties this._GetKeyValue( pcValueName ) endif return this.mnErrorNum <b>*method _GetKeyValue</b> lparameters pcValueName * Obtains a value from a registry key this.mnErrorNum = ERROR_SUCCESS do case case ( this.mnCurrentKey = 0 ) this.mnErrorNum = ERROR_BADKEY case ( type( "pcValueName" ) != "C" ) this.mnErrorNum = ERROR_BADPARM endcase if ( this.mnErrorNum != ERROR_SUCCESS ) return this.mnErrorNum endif local lpdwReserved, lpdwtype, lcData, lnData lpdwReserved = 0 lpdwtype = REG_NONE lcData = space( this.mnMaxValueDataLen ) lnData = len( lcData ) this.mnErrorNum = RegQueryValueEx( this.mnCurrentKey, @pcValueName, @lpdwReserved, @lpdwType, ; @lcData, @lnData ) if ( this.mnErrorNum = ERROR_SUCCESS ) this.mnKeyType = lpdwType this.muKeyValue = this._DecodeValue( lpdwType, lcData, lnData ) endif return this.mnErrorNum <b>* method _DecodeValue</b> lparameter pdwType, pcData, pnData local luRetVal luRetVal = .null. do case case pdwType = REG_SZ luRetVal = left( pcData, pnData-1 ) case pdwType = REG_DWORD luRetVal = FromLong( pcData ) case pdwType = REG_BINARY * provide read access to this type, but for registry safety reasons write is not supported luRetVal = left( pcData, pnData ) otherwise * Don't support anything other types endcase return luRetValThe functions ToLong and FromLong are available on my website under Q&A, General, Article qGEN003