Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Registry.prg - CLASS filereg's GetAppPath PROCEDURE
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Registry.prg - CLASS filereg's GetAppPath PROCEDURE
Divers
Thread ID:
00661519
Message ID:
00661519
Vues:
74
The GetAppPath procedure only returns the proper application path if the registry value type is REG_SZ (string value). For text files (.txt) the value type is stored as a REG_EXPAND_SZ (evaluated string), for example %SystemRoot%\system32\NOTEPAD.EXE %1.

After examining registry.prg I realize the GetAppPath calls GetKeyValue procedure. GetKeyValue errors if the value is not a REG_SZ value.
  PROCEDURE GetKeyValue
* Obtains a value from a registry key
* Note: this routine only handles Data strings (REG_SZ)
  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
    CASE TYPE("m.cValueName") #"C"
      RETURN ERROR_BADPARM
  ENDCASE

  m.nErrCode=RegQueryValueEx(THIS.nCurrentKey,m.cValueName,;
    m.lpdwReserved,@lpdwType,@lpbData,@lpcbData)

* Check for error
  IF m.nErrCode # ERROR_SUCCESS
    RETURN m.nErrCode
  ENDIF

* Make sure we have a data string data type
  IF lpdwType # REG_SZ
    RETURN ERROR_NONSTR_DATA
  ENDIF

  m.cKeyValue = LEFT(m.lpbData,m.lpcbData-1)
  RETURN ERROR_SUCCESS
ENDPROC
It seems pretty straightforward to write a method to evaluate any REG_EXPAND_SZ value type since the variables are surrounded by %variable_name%.

Does an updated version of registry.prg already exist that returns REG_SZ and REG_EXPAND_SZ value types? If not does a complete list of registry variables exist? How do I retrieve the values for these variables?
Heavy Metal Pedal - click with care
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform