TRegistry cannot open existing key

We are checking in code for a registered pdf reader before we try to open a pdf file.  

However, we are having problems on some machines that do not seem to be able to open the .pdf key in HKEY_CLASSES_ROOT, despite it being there in the registry and return false from the PdfRegistered function.

  if PdfRegistered then
    ShellExecute(0, nil, pchar(pdfFile), nil, nil, SW_SHOWNORMAL)
  else
    AskInstallAcrobat;

function TfrmMain.PdfRegistered: boolean;
begin
  with TRegistry.Create do
  try
    RootKey := HKEY_CLASSES_ROOT;
    Result := OpenKey('.pdf', False);  // False = do not create
  finally
    Free;
  end;
end;

Open in new window


Any ideas
rogerfg7Asked:
Who is Participating?
 
jimyXCommented:
If you do not want to change the code (or changing the code is not possible at this stage) then you are left with one option which is, start your application with "RUN AS" and select Admin account.
0
 
jimyXCommented:
Do you have administrator rights in those machines?
0
 
rogerfg7Author Commented:
No. These are user machines.  This is a searchable CD that goes out to customers.  We have had this problem recently on a few machines, both in-house and out on customers' sites.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
jimyXCommented:
You can try either:
TRegistry.Create(KEY_QUERY_VALUE);

Open as read only:
Reg.OpenKeyReadOnly();

Or:
Reg.Access := KEY_READ;
0
 
rogerfg7Author Commented:
Can anything be done without changing the code base?
0
 
jimyXCommented:
I am afraid you are going to need Admin Rights to access that.
0
 
jimyXCommented:
BTW, what OS is that?
0
 
rogerfg7Author Commented:
Thanks for changing the zone, I hit submit from the preview screen, without selecting the right zone.

OS I have tested on have all been XP Prof.

Can we get the administrator to enable the .pdf key in the registry to be readable by the code when logged in as non-admin user?
0
 
rogerfg7Author Commented:
Many thanks.  We will change the code base for the next release and test on a few PCs prior to release.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.