Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Win32api and older computers
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00547931
Message ID:
00548087
Vues:
13
Hi George,

This is some of the components calls:
**
** Get key value from registry.
**
** .GetRegistryKey(, , [], [])
**
** = 'CLASSES_ROOT', 'CURRENT_USER',
** 'LOCAL_MACHINE', 'USERS', or
** 'CURRENT_CONFIG'
**
** = Relative key path from .
**
** = Optional key string, leave blank
** for '(Default)'.
**
** = Default value to assign if value returned is
** missing or of a different data type.
**
LPARAMETERS cHKey, ;
cKey, ;
cString, ;
vDefaultValue

LOCAL nParmCount, ;
nHKey, ;
vKeyValue, ;
nBufferSize, ;
nKeyType, ;
nResult

#DEFINE HKEY_CLASSES_ROOT 0x80000000
#DEFINE HKEY_CURRENT_USER 0x80000001
#DEFINE HKEY_LOCAL_MACHINE 0x80000002
#DEFINE HKEY_USERS 0x80000003
#DEFINE HKEY_CURRENT_CONFIG 0x80000005
#DEFINE RESERVED 0
#DEFINE KEY_QUERY_VALUE 0x0001
#DEFINE REG_SZ 1

nParmCount = PARAMETERS()

** DECLARE DLL statements for reading system registry
**
IF !This.lDeclared_GetRegistryKey
This.lDeclared_GetRegistryKey = .T.
DECLARE Integer RegOpenKeyEx IN Win32API ;
Integer nKey, String @cSubKey, Integer nReserved,;
Integer nAccessMask, Integer @nResult

DECLARE Integer RegQueryValueEx IN Win32API ;
Integer nKey, String cValueName, Integer nReserved,;
Integer @nType, String @cBuffer, Integer @nBufferSize

DECLARE Integer RegCloseKey IN Win32API ;
Integer nKey
ENDIF

** Initialize parameters
**
DO CASE
CASE 'CLASSES_ROOT' $ UPPER(m.cHKey)
nHKey = HKEY_CLASSES_ROOT
CASE 'CURRENT_USER' $ UPPER(m.cHKey)
nHKey = HKEY_CURRENT_USER
CASE 'LOCAL_MACHINE' $ UPPER(m.cHKey)
nHKey = HKEY_LOCAL_MACHINE
CASE 'CURRENT_CONFIG' $ UPPER(m.cHKey)
nHKey = HKEY_CURRENT_CONFIG
OTHERWISE
nHKey = HKEY_USERS
ENDCASE
IF EMPTY(m.cKey)
cKey = ''
ENDIF
IF EMPTY(m.cString)
cString = ''
ENDIF

** Initialize variables for DLL calls
**
vKeyValue = SPACE(256)
nBufferSize = LEN(m.vKeyValue)
nKeyType = REG_SZ
nResult = 0

** First need to open the appropriate key
**
IF RegOpenKeyEx(m.nHKey, m.cKey, RESERVED, KEY_QUERY_VALUE, ;
@nResult) = 0

** Read the value for the requested key string
**
RegQueryValueEx(m.nResult, m.cString, RESERVED, ;
@nKeyType, @vKeyValue, @nBufferSize)

** Close the key
**
RegCloseKey(m.nResult)
ENDIF
*v* Start: 04/1999 rsm Need to terminate at NULL, not just strip out NULLs.
*vKeyValue = STRTRAN(ALLTRIM(m.vKeyValue), CHR(0), '')
IF AT(CHR(0), m.vKeyValue) > 0
m.vKeyValue = LEFT(m.vKeyValue, AT(CHR(0), m.vKeyValue) - 1)
ENDIF
*v* End: 04/1999 rsm Need to terminate at NULL, not just strip out NULLs.

DO CASE
CASE UPPER(m.vKeyValue) = '.T.'
vKeyValue = .T.
CASE UPPER(m.vKeyValue) = '.F.'
vKeyValue = .F.
CASE ISDIGIT(m.vKeyValue)
vKeyValue = VAL(m.vKeyValue)
ENDCASE

** If default value was specified and the retrieved value
** does not match the default value's data type or the
** key value is empty then set and return the default
** value instead of the key value.
**
IF m.nParmCount = 4
IF TYPE('m.vKeyValue') # TYPE('m.vDefaultValue') OR ;
(TYPE('m.vKeyValue') = 'C' AND EMPTY(m.vKeyValue))
vKeyValue = m.vDefaultValue
ENDIF
ENDIF

RETURN m.vKeyValue

>>Thanx Larry,
>>The date of Advapi32.Dll is 05/11/98. But I have some systems running the component that have that date. How about other functions I saw in the Mailmanager's method: RegQueryValueEx, RegCloseKey. The actual error is invlaid number of parameters. Is it possible that some versions of the dll was not as forgiving when it came to passing parameters?
>
>PMFJI, but the declarations are correct, but this error wouldn't show itself until the functions were called. What do the calls look like?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform