Leer y grabar valores del registro de Windows

Leer y grabar valores del registro de Windows

Postby JmGarcia » Tue Feb 24, 2009 7:17 pm

Quisiera poder leer y grabar valores del registro de Windows Mobile versión 5 o 6.

En algunos lenguajes es asi:
Para leer: RegRead ("HKCU", "ControlPanel\Backlight", "ACTimeout")
Para grabar: RegWriteDword ("HKCU", "ControlPanel\Backlight", "Brightness", 10)

Gracias.
Mi abuelo decía: Los aviones vuelan porque Dios quiere, y los helicópteros ni Dios sabe porque vuelan.
FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA

Re: Leer y grabar valores del registro de Windows

Postby Antonio Linares » Wed Feb 25, 2009 12:07 am

JM,

FWPPC proporciona la Clase TReg32, aqui tienes un ejemplo de uso (probado en PC):
Code: Select all  Expand view

// Managing Register services from FiveWin
#include "FWCE.Ch"

#define  HKEY_LOCAL_MACHINE      2147483650

//---------------------------------------------------------------------------//

function Main()

   LOCAL oReg, cName, uVar

   oReg := TReg32():Create( HKEY_LOCAL_MACHINE, "SOFTWARE\FiveWin\Reg32 Class Test" )

   // Call Set with an empty string to access the default key

   oReg:Set( "", "This is the default value" )
   oReg:Set( "A number", 12345 )
   oReg:Set( "A Date", DATE() )
   oReg:Set( "A logical value", .F. )
   MsgStop( "Windows registry updated!" )

   oReg:Close()

   oReg := TReg32():New( HKEY_LOCAL_MACHINE, "SOFTWARE\FiveWin\Reg32 Class Test" )

   uVar := oReg:Get( "", "This is the default value" )
   MsgStop( uVar, "Default: VALTYPE()= " + VALTYPE( uVar ) )
   uVar := oReg:Get( "A number", 12345 )
   MsgStop( uVar, "A number: VALTYPE()= " + VALTYPE( uVar ) )
   uVar := oReg:Get( "A Date", DATE() )
   MsgStop( uVar, "A Date: VALTYPE()= " + VALTYPE( uVar ) )
   uVar := oReg:Get( "A logical value", .F. )
   MsgStop( uVar,"Logic: VALTYPE()= " + VALTYPE( uVar ) )

   oReg:Close()

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41208
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Leer y grabar valores del registro de Windows

Postby JmGarcia » Thu Feb 26, 2009 7:21 pm

Antonio Linares wrote:
Code: Select all  Expand view
#define  HKEY_LOCAL_MACHINE      2147483650


¿ Cuales son los valores para HKEY_CLASS_ROOT, HKEY_CURRENT_USER y HKEY_USERS ?

Probaremos a ver...
Mi abuelo decía: Los aviones vuelan porque Dios quiere, y los helicópteros ni Dios sabe porque vuelan.
FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA

Re: Leer y grabar valores del registro de Windows

Postby Antonio Linares » Thu Feb 26, 2009 7:51 pm

JM,

#define HKEY_CLASSES_ROOT 2147483648
#define HKEY_CURRENT_USER 2147483649
#define HKEY_LOCAL_MACHINE 2147483650
#define HKEY_USERS 2147483651
#defien HKEY_CURRENT_CONFIG 2147483653
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41208
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Leer y grabar valores del registro de Windows

Postby JmGarcia » Wed Mar 04, 2009 8:55 pm

Y una última pregunta:

Suponemos que NO SE QUE "campos" tiene el registro... ¿ Como podemos saber cuantos (y cuales) tiene cada directorio del registro ?

Gracias.
Mi abuelo decía: Los aviones vuelan porque Dios quiere, y los helicópteros ni Dios sabe porque vuelan.
FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA

Re: Leer y grabar valores del registro de Windows

Postby Antonio Linares » Thu Mar 05, 2009 1:11 am

JM,

Aqui tienes un ejemplo probado en el PC:
Code: Select all  Expand view

#define  HKEY_LOCAL_MACHINE      2147483650

#define  ERROR_SUCCESS                    0

function Main()

   local hKey, cName, uValue, n := 0

   RegOpenKey( HKEY_LOCAL_MACHINE,;
               "Software\Microsoft\Windows\CurrentVersion\Run", @hKey )
   
   while RegEnumValue( hKey, n++, @cName, @uValue ) == ERROR_SUCCESS
      MsgInfo( cName )
      MsgInfo( uValue )
   end

   RegCloseKey( hKey )

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41208
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Leer y grabar valores del registro de Windows

Postby Salvador » Thu Nov 12, 2009 12:40 pm

Probado con esta clave del registro devuelve valores incoherentes :?: . Compilado con el SDK de WMB5.
Code: Select all  Expand view

#define HKEY_CURRENT_USER 2147483649

#define  ERROR_SUCCESS                    0

function Main()

   local hKey, cName, uValue, n := 0

   RegOpenKey( HKEY_CURRENT_USER,;
               "ControlPanel\Notifications\{8ddf46e7-56ed-4750-9e58-afc6ce486d03}", @hKey
   
   while RegEnumValue( hKey, n++, @cName, @uValue ) == ERROR_SUCCESS
      MsgInfo( cName )
      MsgInfo( uValue )
   end

   RegCloseKey( hKey )

return nil
 
Saludos
Salvador
Salvador
 
Posts: 144
Joined: Sun Dec 18, 2005 3:18 pm
Location: España


Return to FiveWin para Pocket PC

Who is online

Users browsing this forum: No registered users and 6 guests