Solved

TRegistry cannot open existing key

Posted on 2011-03-25
10
363 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
  • 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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 Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

763 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