Have you tried using OpenKeyReadOnly instead of OpenKey?

Bevan



Luke Pascoe wrote:
> 
> Under Win95 my app cannot read from the registry. the reg access call is as
> follows:
> 
> function GetRegStringEntry(Root: HKey; Key, Value: String;
>   var Res: String): Boolean;
> // Returns success, result in Res
> begin
>   Result := False;
> 
>   with TRegistry.Create do begin
>     RootKey := Root;
>     if OpenKey(Key, False{This is CanCreate}) then
>       try
>         try
>           if ValueExists(Value) then
>           begin
>             Res := ReadString(Value);
>             Result := True;
>           end
>           else
>             showmessage('value doesnt exist');
>         except
>           showmessage('exception');
>         end;
>       finally
>         Free;
>       end
>     else
>       Showmessage('openkey failed');
>       Free;
>     end;
> end;
> 
> It fails at openkey only when CanCreate is False (writing to the registry is
> fine BTW) and if I make CanCreate True then ReadString causes an access
> violation. The data is there and OK, all the params are correct. it works
> under everything except 95.
> 
> Anyone know a way to fix this or at least what's causing it?
> 
> ========================================================
>  Luke Pascoe                          Delphi Programmer
>              enSynergy Consulting LTD
> 
>  [EMAIL PROTECTED]  +64-9-3551593  fax +64-9-3551590
>  Level 4,   10-12 Federal St,   Auckland,   New Zealand
>  PO Box 32521,  Devonport,  Auckland 1330,  New Zealand
> 
> ================== I.H.T.F.P. ==========================
> ---------------------------------------------------------------------------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to