consulta por modificacion en regsitro de windows

81 views
Skip to first unread message

Jorge

unread,
Aug 9, 2016, 8:16:46 AM8/9/16
to publicesvfoxpro
hace unos dias mande la consulta que sigue abajo :


hola :  necesito agregar una clave en el registro de windows 
       para lo cual uso este codigo;

loRegistry = NEWOBJECT( "registry", "registry.vcx")
loRegistry.openkey("Software\Microsoft\Windows\CurrentVersion\Internet Settings",-2147483647,.T.) 


1 ) loRegistry.setregkey("Receivetimeout", "DDD","Software\Microsoft\Windows\CurrentVersion\Internet Settings",-2147483647 , .T.)

la linea en el registro queda de esta manera :  Receivetimeout  REG_SZ    DDD   y en la ruta correcta .O sea la agrega a la registry sin problemas.

Esta prueba la hice a raiz de que lo que yo necesito agregar en realidad es :

2 ) loRegistry.setregkey("Receivetimeout", 6291456,"Software\Microsoft\Windows\CurrentVersion\Internet Settings",-2147483647 , .T.)

para que me quede la liena de registro de esta manera :

Receivetimeout  REG_DWORD   0X006000000 (6291456)

EL PROBLEMA ES QUE AL EJECUTAR LA LINEA DE LA MANERA 2 , DIRECTAMENTE NO ME AGREGA LA CLAVE .

LA SINTAXIS DE LA LINEA 2 TIENE QUE SER DISTINTA PARA EL TIPO DE DATO REG_DWORD ? GRACIAS 



Por favor necesitaba saber si alguno la leyo , y en caso que esto no se pueda hacer de la manera que lo planteo, en lo posible me lo confirmen .
gracias 
 

Patricio Muñoz

unread,
Aug 9, 2016, 8:28:04 AM8/9/16
to publice...@googlegroups.com
Jorge

probaste mandando el 6291456 entre comillas?
ejemplo

2 ) loRegistry.setregkey("Receivetimeout", "6291456","Software\Microsoft\Windows\CurrentVersion\Internet Settings",-2147483647 , .T.)

Bendiciones


--
Patricio Muñoz
Pro&Tech
Analista en Sistemas

marcelo lopez

unread,
Aug 9, 2016, 8:47:17 AM8/9/16
to publicesvfoxpro
Gracias por la rta Patricio :

si , eso tmb lo intente y no hubo caso . saludos 

Jorge

unread,
Aug 9, 2016, 8:49:29 AM8/9/16
to publicesvfoxpro
Patricio , gracias por la rta :

Si, eso tmb lo intente .pero no anduvo.

gracias 

El 9 de agosto de 2016, 9:27, Patricio Muñoz <protech...@gmail.com> escribió:

Luiz Alexandre Ruiz

unread,
Aug 9, 2016, 10:07:07 AM8/9/16
to Comunidad de Visual Foxpro en Español
Abaixo tem uma rotina que você pode gravar com o nome de Registry.prg e usá-la, mas tem alguns ajustes a serem feitos nela para o seu caso.
Tem um exemplo abaixo como usar, mas o mesmo só permite usar String, que é o mesmo problema que você tem no o Registry.VCX, mas vou marcar os locais que você deve observar e fazer o ajuste que você precisa, OK?
Ao chamar este PRG você vai passar o caminho todo para o registro, mas se você observar as áreas que vou deixar em vermelho verás que dá para melhorar isso.
Estou sem tempo para melhorar esta rotina, porque eu quero fazer algo melhorado nela, mas nela tem o caminho que você precisa... Abraços.


* Program:     REGISTRY.PRG
* Created:     10/19/2004
* Developer:   Greg Reichert
* Copyright:   public domain 2004 GLR software
*------------------------------------------------------------
* Description: Read and write to registry in Name / Value pair method.
* Parameters:  tKey, req, d="", Registry key.
*               tValue, opt, d="", value to write to key.
* Return:      Value from key.
* Syntax:
*     Set Value:
*        Registry( "HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualFoxPro\MyKey", "myValue" )
*
*    Get Value:
*        lcValue = Registry( "HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualFoxPro\MyKey" )
*------------------------------------------------------------
* Id Date        By         Description
*  1 08/27/2002  Greg Reichert    Initial Creation
*
*------------------------------------------------------------
LPARAMETERS tKey, tValue
LOCAL lcTemp
lcTemp = _Registry("GET", tKey)
IF EMPTY(lcTemp)
    _Registry("SET", tKey, TRANSFORM(tValue))
    lcTemp = _Registry("GET", tKey)
ENDIF
RETURN lcTemp


*------------------------------------------------------------
* Description: Get / Set Registry
* Parameters:  <para>, <req/opt>, D=<def>, <desc>
* Return:     
* Use:        
*------------------------------------------------------------
* Id Date        By         Description
*  1 04/12/2002  Greg Reichert    Initial Creation
*
*------------------------------------------------------------
PROCEDURE _Registry
LPARAMETERS tAction, tKey, tValue
    * Registry roots
    HKEY_CLASSES_ROOT           = -2147483648  && BITSET(0,31)
    HKEY_CURRENT_USER           = -2147483647  && BITSET(0,31)+1
    HKEY_LOCAL_MACHINE          = -2147483646  && BITSET(0,31)+2
    HKEY_USERS                  = -2147483645  && BITSET(0,31)+3

    #DEFINE REG_SZ                 1    && Data string
    #DEFINE REG_BINARY             3    && Binary data in any form.
    #DEFINE REG_DWORD             4    && A 32-bit number.

    DECLARE Integer RegCreateKey IN Win32API ;
        Integer nHKey, String @cSubKey, Integer @nResult

    DECLARE INTEGER RegOpenKey IN Win32API ;
        INTEGER nHKey, STRING @cSubKey, INTEGER @nResult

    DECLARE INTEGER RegCloseKey IN Win32API ;
        INTEGER nHKey

    DECLARE INTEGER RegQueryValueEx IN Win32API ;
        INTEGER nHKey, STRING lpszValueName, INTEGER dwReserved,;
        INTEGER @lpdwType, STRING @lpbData, INTEGER @lpcbData

    DECLARE Integer RegSetValueEx IN Win32API ;
        Integer hKey, String lpszValueName, Integer dwReserved,;
        Integer fdwType, String lpbData, Integer cbData

    *--------------------------------------------
    *  parse cKey
    *--------------------------------------------
    LOCAL hKey, cKey, cData
    hKey    = LEFT( tkey, AT("\", tKey)-1)
    tKey     = SUBSTR( tKey, AT("\",tKey)+1)
    cKey    = LEFT( tKey, RAT("\",tKey)-1)
    tKey     = SUBSTR( tKey, RAT("\",tKey)+1)
    cData    = tKey
   
    LOCAL nCurrentKey,nErrCode
    nCurrentKey = 0
    nErrCode = RegOpenKey(&hKey,cKey,@nCurrentKey)
    IF nErrCode>0
        nErrCode = RegCreateKey(&hKey,cKey,@nCurrentKey)
    ENDIF
   
    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 UPPER(ALLTRIM(tAction))="GET"

        m.nErrCode=RegQueryValueEx(nCurrentKey,cData, m.lpdwReserved,@lpdwType,@lpbData,@lpcbData)
        m.cKeyValue = LEFT(m.lpbData,m.lpcbData-1)
       
    CASE UPPER(ALLTRIM(tAction))="SET"
        * Make sure we null terminate this guy
        lpcbData = TRANSFORM(m.tValue)+CHR(0)
        nValueSize = LEN(m.lpcbData)

        * Set the key value here
        m.nErrCode = RegSetValueEx(nCurrentKey,m.cData,0,;
            REG_SZ,m.lpcbData ,m.nValueSize)

        cKeyValue = m.nErrCode=0
    ENDCASE
   
    =RegCloseKey(nCurrentKey)

    #IF VERSION(5)>=700
        CLEAR DLLS RegCreateKey
        CLEAR DLLS RegOpenKey
        CLEAR DLLS RegCloseKey
        CLEAR DLLS RegQueryValueEx
        CLEAR DLLS RegSetValueEx
    #ENDIF

    RETURN cKeyValue

Jorge

unread,
Aug 9, 2016, 10:21:55 AM8/9/16
to publicesvfoxpro
Luiz  obrigado  por la rta !!
Reply all
Reply to author
Forward
0 new messages