Solved

TRegistry cannot open existing key

Posted on 2011-03-25
10
375 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:rogerfg7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35214564
Do you have administrator rights in those machines?
0
 

Author Comment

by:rogerfg7
ID: 35214583
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
 
LVL 24

Expert Comment

by:jimyX
ID: 35214635
You can try either:
TRegistry.Create(KEY_QUERY_VALUE);

Open as read only:
Reg.OpenKeyReadOnly();

Or:
Reg.Access := KEY_READ;
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:rogerfg7
ID: 35214672
Can anything be done without changing the code base?
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35214714
I am afraid you are going to need Admin Rights to access that.
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35214729
BTW, what OS is that?
0
 

Author Comment

by:rogerfg7
ID: 35214834
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
 
LVL 24

Accepted Solution

by:
jimyX earned 250 total points
ID: 35215056
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
 

Author Comment

by:rogerfg7
ID: 35215101
Many thanks.  We will change the code base for the next release and test on a few PCs prior to release.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question