Solved

TRegistry cannot open existing key

Posted on 2011-03-25
10
367 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

734 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