************************************************ PROCEDURE GetRegKey ************************************************ LPARAMETERS tcOptName, tcKeyPath, tcUserKey #INCLUDE "ffc\registry.h" * Example: * GetRegKey("DefaultDSNDir", "Software\Odbc\Odbc.ini\Odbc File Dsn", "HKEY_LOCAL_MACHINE") * Returns: "C:\Program Files\Common Files\ODBC\Data Sources\" *-- check parameters ASSERT TYPE("tcOptName") = "C" AND NOT EMPTY(tcOptName) MESSAGE "GetRegKey() requires parameter <tcOptName> as 1st parameter!" ASSERT TYPE("tcKeyPath") = "C" AND NOT EMPTY(tcKeyPath) MESSAGE "GetRegKey() requires parameter <tcKeyPath> as 2nd parameter!" ASSERT TYPE("tcUserKey") = "C" AND NOT EMPTY(tcUserKey) MESSAGE "GetRegKey() requires parameter <tcUserKey> as 3rd parameter!" tcUserKey = UPPER(ALLTRIM(tcUserKey)) LOCAL lnUserKey DO CASE CASE tcUserKey = "HKEY_CLASSES_ROOT" lnUserKey = HKEY_CLASSES_ROOT CASE tcUserKey = "HKEY_CURRENT_USER" lnUserKey = HKEY_CURRENT_USER CASE tcUserKey = "HKEY_LOCAL_MACHINE" lnUserKey = HKEY_LOCAL_MACHINE CASE tcUserKey = "HKEY_USERS" lnUserKey = HKEY_USERS OTHERWISE ??CHR(7) WAIT WINDOW NOWAIT "'" + tcUserKey + "' is not a valid registry root!" RETURN "" ENDCASE LOCAL loReg, lcOptValue, lnErrNum loReg = NEWOBJECT("Registry", HOME() + "ffc\registry") lcOptValue = "" lnErrNum = loReg.GetRegKey(tcOptName, @lcOptValue, tcKeyPath, lnUserKey) RELEASE loReg IF lnErrNum <> 0 ??CHR(7) WAIT WINDOW NOWAIT "Could not find Key" RETURN "" ELSE *-- return value RETURN lcOptValue ENDIF *-- EOF GetRegKey ---------------------------------------------------------------------------------HTH
>LPARAMETER cValueName,cKeyValue > >LOCAL lpdwReserved,lpdwType,lpbData,lpcbData,nErrCode >STORE 0 TO lpdwReserved,lpdwType >STORE SPACE(256) TO lpbData >STORE LEN(m.lpbData) TO m.lpcbData > >DO CASE >CASE TYPE("THIS.nCurrentKey")#'N' OR THIS.nCurrentKey = 0 > RETURN ERROR_BADKEY >>And that's as far as it ever gets.