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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- 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 | Expand
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Re: Writing into the Windows registry
Code: Select all | Expand
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()
and
Code: Select all | Expand
#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 | Expand
#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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- Antonio Linares
- Site Admin
- Posts: 42395
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 10 times
- Been thanked: 41 times
- Contact:
Re: Writing into the Windows registry
Michel,
You may need to use function SetEnvironmentVariable() from Windows API:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686206(v=vs.85).aspx
Here you can review a thread about it:
http://forums.fivetechsupport.com/viewtopic.php?p=73610#p73610
You may need to use function SetEnvironmentVariable() from Windows API:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686206(v=vs.85).aspx
Here you can review a thread about it:
http://forums.fivetechsupport.com/viewtopic.php?p=73610#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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- Antonio Linares
- Site Admin
- Posts: 42395
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 10 times
- Been thanked: 41 times
- 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: 42395
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 10 times
- Been thanked: 41 times
- 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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- Otto
- Posts: 6396
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 8 times
- Been thanked: 1 time
- Contact:
Re: Writing into the Windows registry
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- MarcoBoschi
- Posts: 1070
- 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 | Expand
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: 42395
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 10 times
- Been thanked: 41 times
- 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