Página 1 de 2
Problem with TRegistry
Publicado: Sab Sep 22, 2007 3:51 pm
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
Problem with TRegistry
Publicado: Sab Sep 22, 2007 9:58 pm
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
Problem with TRegistry
Publicado: Sab Sep 22, 2007 9:58 pm
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
Problem with TRegistry
Publicado: Sab Sep 22, 2007 11:46 pm
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
Problem with TRegistry
Publicado: Sab Sep 22, 2007 11:46 pm
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
Problem with TRegistry
Publicado: Sab Sep 22, 2007 11:51 pm
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
Problem with TRegistry
Publicado: Sab Sep 22, 2007 11:51 pm
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 12:15 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 12:15 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 12:26 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 12:26 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 12:38 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 12:38 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 12:52 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 12:52 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 1:17 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 1:17 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 1:29 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 1:29 am
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 2:03 pm
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 2:03 pm
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 3:20 pm
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 3:20 pm
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 10:19 pm
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
Problem with TRegistry
Publicado: Dom Sep 23, 2007 10:19 pm
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