Board index » delphi » TRegistry.WriteString not working on NT

TRegistry.WriteString not working on NT

TRegistry.WriteString seems to work on Win98 but not NT.
The following fragment of code works well in Win98, but on
NT, WriteString fails. Why?

Reg := registry.TRegistry.Create
try
  Reg.RootKey := HKEY_CLASSES_ROOT;
  if Reg.OpenKey( '\CLSID\{871C5380-42A0-1069-A2EA-08002B30309D}',False)
then
    begin
    try
      Reg.WriteString('','My value'); // NT raises ERegistryException
here,
                                      // but Win98 does not. Why?
    finally
      Reg.CloseKey
    end end
finally
  Reg.Free
end

The weird thing is that I can write to this key manually
on NT, using regedit. You would think that any thing that you
can do manually, you would be permitted to do programatically.

Please advise.

- Sean B. Durkin

 

Re:TRegistry.WriteString not working on NT


Does the program have the privs required to write HKCR?  That's the usual
98/NT problem, but noted you can do this manually.....

David

"Sean B. Durkin" <sdur...@siliconrose.com.au> wrote in message
news:392202B2.A9A508DB@siliconrose.com.au...

Quote
> TRegistry.WriteString seems to work on Win98 but not NT.
> The following fragment of code works well in Win98, but on
> NT, WriteString fails. Why?

> Reg := registry.TRegistry.Create
> try
>   Reg.RootKey := HKEY_CLASSES_ROOT;
>   if Reg.OpenKey( '\CLSID\{871C5380-42A0-1069-A2EA-08002B30309D}',False)
> then
>     begin
>     try
>       Reg.WriteString('','My value'); // NT raises ERegistryException
> here,
>                                       // but Win98 does not. Why?
>     finally
>       Reg.CloseKey
>     end end
> finally
>   Reg.Free
> end

> The weird thing is that I can write to this key manually
> on NT, using regedit. You would think that any thing that you
> can do manually, you would be permitted to do programatically.

> Please advise.

> - Sean B. Durkin

Re:TRegistry.WriteString not working on NT


Under NT, there is a security model inside the registry.

It seems you are not allowed to change internet explorers information??? Not
by the user policy your application
is using.

cu
Timo

Sean B. Durkin schrieb in Nachricht
<392202B2.A9A50...@siliconrose.com.au>...

Quote
>TRegistry.WriteString seems to work on Win98 but not NT.
>  if Reg.OpenKey( '\CLSID\{871C5380-42A0-1069-A2EA-08002B30309D}',False)

Re:TRegistry.WriteString not working on NT


Quote
In article <392202B2.A9A50...@siliconrose.com.au>, Sean B. Durkin wrote:
> TRegistry.WriteString seems to work on Win98 but not NT.
> The following fragment of code works well in Win98, but on
> NT, WriteString fails. Why?

Security stuff. Delphi tries to create a key with KEY_ALL_ACCESS by default
and that includes a few options that fall victim to security limits, unless
you have admin rights. If you have D5 use

Quote

> Reg := registry.TRegistry.Create( KEY_READ or KEY_WRITE );

For older versions you will have to use the registry API directly.
(RegOpenKey et al.).

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:TRegistry.WriteString not working on NT


No, thats not it. I tried Create( KEY_READ or KEY_WRITE ), but it
didn't make a difference.

Any ideas?

    - Sean B. Durkin

Quote
"Peter Below (TeamB)" wrote:
> In article <392202B2.A9A50...@siliconrose.com.au>, Sean B. Durkin wrote:
> > TRegistry.WriteString seems to work on Win98 but not NT.
> > The following fragment of code works well in Win98, but on
> > NT, WriteString fails. Why?

> Security stuff. Delphi tries to create a key with KEY_ALL_ACCESS by default
> and that includes a few options that fall victim to security limits, unless
> you have admin rights. If you have D5 use

> > Reg := registry.TRegistry.Create( KEY_READ or KEY_WRITE );

> For older versions you will have to use the registry API directly.
> (RegOpenKey et al.).

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitly requested!

Re:TRegistry.WriteString not working on NT


Quote
In article <392344DC.3CC7B...@siliconrose.com.au>, Sean B. Durkin wrote:
> No, thats not it. I tried Create( KEY_READ or KEY_WRITE ), but it
> didn't make a difference.

> Any ideas?

No. You may want to try writing to the key in question using the API
functions directly.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads