In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Problem with TRegistry

Xailer professional forum in English
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

I am trying to write a value to a registry using the following code. It
fails to create a registry key.
WITH OBJECT TRegistry():Create()
nError := :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
IF nError != 0
nError := :CreateKey("SoftwareAlterraCheckPointFiles_Folders")
ENDIF
IF nError == 0
:SetString("TVSelection", ::oEditBtnTVSelection:cText)
:CloseKey()
ENDIF
:Destroy()
END
Even if I create the key - using RegEdit - by hand
("SoftwareAlterraCheckPointFiles_FoldersTVSelection") no value is
saved.
Anybody any idea?
Stephan
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
unless you are using the default value it seems you forgot to set the :Root
property.
It that doesn't help, just put some MsgSysError( :nLastError ) after each
operation to see where it fails.
Regards,
José Lalí­n
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
unless you are using the default value it seems you forgot to set the :Root
property.
It that doesn't help, just put some MsgSysError( :nLastError ) after each
operation to see where it fails.
Regards,
José Lalí­n
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

José,
it says 'Incorrect function'. What can you make out of this?
Regards,
Stephan
"José Lalín" <notengo@correo.com> wrote in message
news:46f57417$[email=2@ozsrv2.ozlan.local...]2@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
> unless you are using the default value it seems you forgot to set the
> :Root property.
>
> It that doesn't help, just put some MsgSysError( :nLastError ) after each
> operation to see where it fails.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

José,
it says 'Incorrect function'. What can you make out of this?
Regards,
Stephan
"José Lalín" <notengo@correo.com> wrote in message
news:46f57417$[email=2@ozsrv2.ozlan.local...]2@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
> unless you are using the default value it seems you forgot to set the
> :Root property.
>
> It that doesn't help, just put some MsgSysError( :nLastError ) after each
> operation to see where it fails.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

Forgot to mention that I use the default root 'HKEY_CURRENT_USER'.
"José Lalín" <notengo@correo.com> wrote in message
news:46f57417$[email=2@ozsrv2.ozlan.local...]2@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
> unless you are using the default value it seems you forgot to set the
> :Root property.
>
> It that doesn't help, just put some MsgSysError( :nLastError ) after each
> operation to see where it fails.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

Forgot to mention that I use the default root 'HKEY_CURRENT_USER'.
"José Lalín" <notengo@correo.com> wrote in message
news:46f57417$[email=2@ozsrv2.ozlan.local...]2@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
> unless you are using the default value it seems you forgot to set the
> :Root property.
>
> It that doesn't help, just put some MsgSysError( :nLastError ) after each
> operation to see where it fails.
>
> Regards,
> José Lalín
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
> it says 'Incorrect function'. What can you make out of this?
Let me see the code and mark the place where the error appears.
Regards,
José Lalí­n
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
> it says 'Incorrect function'. What can you make out of this?
Let me see the code and mark the place where the error appears.
Regards,
José Lalí­n
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

Here it is:
WITH OBJECT TRegistry():New()
nError := :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
IF nError != 0
nError := :CreateKey("SoftwareAlterraCheckPointFiles_Folders")
MsgSysError( :nLastError )
ENDIF
IF nError == 0
:SetString("TVSelection", ::oEditBtnTVSelection:cText)
:CloseKey()
ELSE
MsgSysError( :nLastError )
ENDIF
:Destroy()
END
In both cases the it says 'Incorrect function'.
"José Lalín" <notengo@correo.com> wrote in message
news:46f5942e$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
>> it says 'Incorrect function'. What can you make out of this?
>
> Let me see the code and mark the place where the error appears.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

Here it is:
WITH OBJECT TRegistry():New()
nError := :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
IF nError != 0
nError := :CreateKey("SoftwareAlterraCheckPointFiles_Folders")
MsgSysError( :nLastError )
ENDIF
IF nError == 0
:SetString("TVSelection", ::oEditBtnTVSelection:cText)
:CloseKey()
ELSE
MsgSysError( :nLastError )
ENDIF
:Destroy()
END
In both cases the it says 'Incorrect function'.
"José Lalín" <notengo@correo.com> wrote in message
news:46f5942e$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
>> it says 'Incorrect function'. What can you make out of this?
>
> Let me see the code and mark the place where the error appears.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

When I create the path in the registry by hand
'HKEY_CURRENT_USERSoftwareAlterraCheckPointFiles_Folders TVSelection'
and call :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
MsgSysError( :nLastError ) reports 'The specified path is invalid'
"José Lalín" <notengo@correo.com> wrote in message
news:46f5942e$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
>> it says 'Incorrect function'. What can you make out of this?
>
> Let me see the code and mark the place where the error appears.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

When I create the path in the registry by hand
'HKEY_CURRENT_USERSoftwareAlterraCheckPointFiles_Folders TVSelection'
and call :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
MsgSysError( :nLastError ) reports 'The specified path is invalid'
"José Lalín" <notengo@correo.com> wrote in message
news:46f5942e$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
>> it says 'Incorrect function'. What can you make out of this?
>
> Let me see the code and mark the place where the error appears.
>
> Regards,
> José Lalín
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
> When I create the path in the registry by hand
> 'HKEY_CURRENT_USERSoftwareAlterraCheckPointFiles_Folders TVSelection'
> and call :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
> MsgSysError( :nLastError ) reports 'The specified path is invalid'
Ok, then remove the first slash in the OpenKey()/CreateKey() calls.
Regards,
José Lalí­n
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
> When I create the path in the registry by hand
> 'HKEY_CURRENT_USERSoftwareAlterraCheckPointFiles_Folders TVSelection'
> and call :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
> MsgSysError( :nLastError ) reports 'The specified path is invalid'
Ok, then remove the first slash in the OpenKey()/CreateKey() calls.
Regards,
José Lalí­n
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

No, that doesn't change a thing.
I tried the following code (from a older thread):
WITH OBJECT TRegistry():Create()
:Root := HKEY_LOCAL_MACHINE
IF :OpenKey( "SoftwareMicrosoftWindowsCurrentVersion" ) == 0
cName := :GetString( "ProgramsFilesDir" )
:CloseKey()
ENDIF
:Destroy()
END WITH
and this works!!
"José Lalín" <notengo@correo.com> wrote in message
news:46f59cfd$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
>> When I create the path in the registry by hand
>> 'HKEY_CURRENT_USERSoftwareAlterraCheckPointFiles_Folders TVSelection'
>> and call :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
>> MsgSysError( :nLastError ) reports 'The specified path is invalid'
>
> Ok, then remove the first slash in the OpenKey()/CreateKey() calls.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

No, that doesn't change a thing.
I tried the following code (from a older thread):
WITH OBJECT TRegistry():Create()
:Root := HKEY_LOCAL_MACHINE
IF :OpenKey( "SoftwareMicrosoftWindowsCurrentVersion" ) == 0
cName := :GetString( "ProgramsFilesDir" )
:CloseKey()
ENDIF
:Destroy()
END WITH
and this works!!
"José Lalín" <notengo@correo.com> wrote in message
news:46f59cfd$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
>> When I create the path in the registry by hand
>> 'HKEY_CURRENT_USERSoftwareAlterraCheckPointFiles_Folders TVSelection'
>> and call :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
>> MsgSysError( :nLastError ) reports 'The specified path is invalid'
>
> Ok, then remove the first slash in the OpenKey()/CreateKey() calls.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

Ok. The problem seems to be in the CreateKey() method. After have created
the path by hand the SetString() method works fine. And you are right, there
should be no slash at the beginnig.
I am of to bed now. Hope we can solve this tomorrow.
Thanks for your support so far!
Regards,
Stephan
"José Lalín" <notengo@correo.com> wrote in message
news:46f59cfd$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
>> When I create the path in the registry by hand
>> 'HKEY_CURRENT_USERSoftwareAlterraCheckPointFiles_Folders TVSelection'
>> and call :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
>> MsgSysError( :nLastError ) reports 'The specified path is invalid'
>
> Ok, then remove the first slash in the OpenKey()/CreateKey() calls.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

Ok. The problem seems to be in the CreateKey() method. After have created
the path by hand the SetString() method works fine. And you are right, there
should be no slash at the beginnig.
I am of to bed now. Hope we can solve this tomorrow.
Thanks for your support so far!
Regards,
Stephan
"José Lalín" <notengo@correo.com> wrote in message
news:46f59cfd$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
>> When I create the path in the registry by hand
>> 'HKEY_CURRENT_USERSoftwareAlterraCheckPointFiles_Folders TVSelection'
>> and call :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
>> MsgSysError( :nLastError ) reports 'The specified path is invalid'
>
> Ok, then remove the first slash in the OpenKey()/CreateKey() calls.
>
> Regards,
> José Lalín
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
I have been doing some tests and found the problem. It seems that the API
needs to have an opened key before creating a new one so the code should be:
WITH OBJECT TRegistry():Create()
nError := :OpenKey( "Software" )
IF nError != 0
nError := :CreateKey( "AlterraCheckPointFiles_Folders" )
ENDIF
IF nError == 0
:SetString( "TVSelection", ::oEditBtnTVSelection:cText )
:CloseKey()
ENDIF
:Destroy()
END
This code runs nicely here. Test it and let me know if it works.
Regards,
José Lalí­n
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
I have been doing some tests and found the problem. It seems that the API
needs to have an opened key before creating a new one so the code should be:
WITH OBJECT TRegistry():Create()
nError := :OpenKey( "Software" )
IF nError != 0
nError := :CreateKey( "AlterraCheckPointFiles_Folders" )
ENDIF
IF nError == 0
:SetString( "TVSelection", ::oEditBtnTVSelection:cText )
:CloseKey()
ENDIF
:Destroy()
END
This code runs nicely here. Test it and let me know if it works.
Regards,
José Lalí­n
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

Thanks a lot José for this 7 X 24 support. I got working now!!
My code is as follows:
WITH OBJECT TRegistry():Create()
nError := :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
IF nError != 0
nError := :OpenKey("Software")
IF nError == 0
nError := :CreateKey("AlterraCheckPointFiles_Folders")
ENDIF
ENDIF
IF nError == 0
:SetString("TVSelection", ::oEditBtnTVSelection:cText)
:CloseKey()
ENDIF
:Destroy()
END
"José Lalín" <notengo@correo.com> wrote in message
news:46f65659$[email=2@ozsrv2.ozlan.local...]2@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
> I have been doing some tests and found the problem. It seems that the API
> needs to have an opened key before creating a new one so the code should
> be:
>
> WITH OBJECT TRegistry():Create()
> nError := :OpenKey( "Software" )
> IF nError != 0
> nError := :CreateKey( "AlterraCheckPointFiles_Folders" )
> ENDIF
> IF nError == 0
> :SetString( "TVSelection", ::oEditBtnTVSelection:cText )
> :CloseKey()
> ENDIF
> :Destroy()
> END
>
> This code runs nicely here. Test it and let me know if it works.
>
> Regards,
> José Lalín
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

Problem with TRegistry

Mensaje por Stephan Hennekens »

Thanks a lot José for this 7 X 24 support. I got working now!!
My code is as follows:
WITH OBJECT TRegistry():Create()
nError := :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
IF nError != 0
nError := :OpenKey("Software")
IF nError == 0
nError := :CreateKey("AlterraCheckPointFiles_Folders")
ENDIF
ENDIF
IF nError == 0
:SetString("TVSelection", ::oEditBtnTVSelection:cText)
:CloseKey()
ENDIF
:Destroy()
END
"José Lalín" <notengo@correo.com> wrote in message
news:46f65659$[email=2@ozsrv2.ozlan.local...]2@ozsrv2.ozlan.local...[/email]
>
> Stephan,
>
> I have been doing some tests and found the problem. It seems that the API
> needs to have an opened key before creating a new one so the code should
> be:
>
> WITH OBJECT TRegistry():Create()
> nError := :OpenKey( "Software" )
> IF nError != 0
> nError := :CreateKey( "AlterraCheckPointFiles_Folders" )
> ENDIF
> IF nError == 0
> :SetString( "TVSelection", ::oEditBtnTVSelection:cText )
> :CloseKey()
> ENDIF
> :Destroy()
> END
>
> This code runs nicely here. Test it and let me know if it works.
>
> Regards,
> José Lalín
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
> Thanks a lot José for this 7 X 24 support. I got working now!!
You are welcome !
> nError := :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
I think you can safely remove this line and it will work. The CreateKey()
methods justs opens the key if it already exists or at least this is what
the docs say.
Regards,
José Lalí­n
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Problem with TRegistry

Mensaje por notengo »

Stephan,
> Thanks a lot José for this 7 X 24 support. I got working now!!
You are welcome !
> nError := :OpenKey("SoftwareAlterraCheckPointFiles_Folders")
I think you can safely remove this line and it will work. The CreateKey()
methods justs opens the key if it already exists or at least this is what
the docs say.
Regards,
José Lalí­n
Responder