Writing into the Windows registry
Writing into the Windows registry
Hello,
Can someone provide me a small example how to update a key in the Windows registry?
Thanks.
Can someone provide me a small example how to update a key in the Windows registry?
Thanks.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Re: Writing into the Windows registry
Michel
this is an example, HTH
this is an example, HTH
Code: Select all
oReg := TReg32():Create( HKEY_CURRENT_USER, "Control Panel\Desktop\WindowMetrics" ) // scrollbars
I := 0
oReg:Get( "ScrollHeight", @I )
IF I # 0
oReg:Set( "ScrollHeight", DVAL )
oReg:Set( "ScrollWidth", DVAL )
oReg:Close()
ENDIF
Re: Writing into the Windows registry
Richard,
Thanks a lot for your help. But I'm afraid I don't quite understand.
I have never written into the registry before.
This is what I need to write into the registry :
Thanks a lot in advance.
Thanks a lot for your help. But I'm afraid I don't quite understand.
I have never written into the registry before.
This is what I need to write into the registry :
Maybe you could translate it for my in FHW?Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment]
"STCUNR"="53"
"STCURA"="Name1"
"STJUDA"="Name2"
Thanks a lot in advance.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Re: Writing into the Windows registry
Code: Select all
oReg := TReg32():Create( HKEY_LOCAL_MACHINE, "ControlSet001\Control\Session Manager\Environment" )
oReg:Set( "STCUNR", "53")
oReg:Set( "STCURA", "name1" )
oReg:Set( "STJUDA", "name2" )
oReg:Close()
Code: Select all
#define HKEY_LOCAL_MACHINE 2147483650 // 0x80000002
Re: Writing into the Windows registry
Hello,
Thank you all for your help. Until now, everything is running just fine.
I use this function to change environment variables. Because I think it is better to change user environment varaibles, I changed my code to HKEY_CURRENT USER like this :By using this code, the variables are changed in the register.
Still one problem left : how do I activate them without having to reboot or to logoff?
Thanks.
Thank you all for your help. Until now, everything is running just fine.
I use this function to change environment variables. Because I think it is better to change user environment varaibles, I changed my code to HKEY_CURRENT USER like this :
Code: Select all
#DEFINE HKEY_CURRENT_USER 2147483649 // 0x80000002
......
IF RegRet
oReg := TReg32():Create( HKEY_CURRENT_USER,"Environment")
IF UPPER(cPar) = "J"
IF !EMPTY(cNAAM) ; oReg:Set("STJUDA",cNAAM) ; ENDIF
ELSE
IF !EMPTY(cNAAM) ; oReg:Set("STCURA",cNAAM) ; ENDIF
IF !EMPTY(cNR ) ; oReg:Set("STCUNR",cNR ) ; ENDIF
ENDIF
oReg:Close()
ENDIF
Still one problem left : how do I activate them without having to reboot or to logoff?
Thanks.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Writing into the Windows registry
Michel,
You may need to use function SetEnvironmentVariable() from Windows API:
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Here you can review a thread about it:
http://forums.fivetechsupport.com/viewt ... 610#p73610
You may need to use function SetEnvironmentVariable() from Windows API:
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Here you can review a thread about it:
http://forums.fivetechsupport.com/viewt ... 610#p73610
Re: Writing into the Windows registry
Antonio,
I tried that API-function. The variables are only changed while my application is running. But not permanently.
On the MSDN-page you send me, I also read : "Sets the contents of the specified environment variable for the current process.".
But thanks anyway.
I tried that API-function. The variables are only changed while my application is running. But not permanently.
On the MSDN-page you send me, I also read : "Sets the contents of the specified environment variable for the current process.".
But thanks anyway.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Re: Writing into the Windows registry
Could someone send me a small example how I can read my variables from the registry?
Thanks.
Thanks.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Writing into the Windows registry
Michel,
oReg := TReg32():New( HKEY_CURRENT_USER,"Environment")
MsgInfo( oReg:Get("STJUDA") )
oReg:Close()
oReg := TReg32():New( HKEY_CURRENT_USER,"Environment")
MsgInfo( oReg:Get("STJUDA") )
oReg:Close()
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Writing into the Windows registry
Also you may use to set and retrieve environment variables:
hb_SetEnv( "michel", "this is a test" )
MsgInfo( GetEnv( "michel" ) )
hb_SetEnv( "michel", "this is a test" )
MsgInfo( GetEnv( "michel" ) )
Re: Writing into the Windows registry
Sorry, Antonio.
Sure that I know that function but I completely forgot.
Thanks.
Sure that I know that function but I completely forgot.
Thanks.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Re: Writing into the Windows registry
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
Re: Writing into the Windows registry
Antonio,
I tried HB_SETENV but I got an error "unresolved function".
Which library do I need to add?
Thanks.
Otto,
I'll have a look at your topic. Thanks.
I tried HB_SETENV but I got an error "unresolved function".
Which library do I need to add?
Thanks.
Otto,
I'll have a look at your topic. Thanks.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- MarcoBoschi
- Posts: 925
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
Re: Writing into the Windows registry
I use this function to Use pdfCreator in AutoSave Mode
It works
Bye
It works
Bye
Code: Select all
FUNCTION SETTAREG( cDir , cFile , cAutoSave )
LOCAL oReg
oReg:=TReg32():New( HKEY_CURRENT_USER , "SOFTWARE\PDFCreator\Program" )
oReg:Set( "UseAutosave" , cAutoSave )
oReg:Set( "UseAutosaveDirectory" , cAutoSave )
oReg:Set( "AutosaveDirectory" , UPPER( cDir ) )
oReg:Set( "AutosaveFilename" , UPPER( cFile ) )
oReg:Close()
RETURN .T.
Marco Boschi
info@marcoboschi.it
info@marcoboschi.it
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Writing into the Windows registry
Michel,
I am afraid that hb_SetEnv() is only available for Harbour
I am afraid that hb_SetEnv() is only available for Harbour