Solved

Registry OpenKey doesnt seem to work - Delphi 2010

Posted on 2011-09-26
1
1,191 Views
Last Modified: 2016-09-30
I try to read the registry

var
   Registry: TRegistry;
   PrinterName : string ;
begin
    Registry:=TRegistry.Create;
    PrinterName := devMode^.dmDeviceName;
    Registry.RootKey:=HKEY_LOCAL_MACHINE;
    if Registry.OpenKey('System\ControlSet001\Control\Print\Printers\'+lPrinterName+'\DsDriver',False) then begin
       ....
    end;

end;

Open in new window


This code worked with Delphi 2006 & Windows 7.
Printername would be in my case 'FreePDF'. The registry entry exists.
When i use it with Delphi 2010 then Openkey returns false (at least under Windows 7 - i didnt try other OS yet)

What am I missing?
0
Comment
Question by:Treppenmeister
1 Comment
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 36708338
Ok, you can try disabling totally the UAC.
Usually, working with the UAC enabled, makes HKEY_LOCAL_MACHINE inaccesible (to prevent any unattended system change)
You should so provide a manifest to give admin priviledges to your code when UAC  is enabled

Take a look here to understand what I mean http://delphi.about.com/od/delphitips2009/qt/delphi-vista-registry-run-on-startup.htm

Another suggestion. Delphi 2010 manages Unicode strings.
Are you sure about the PChar suggestion? Did you try it?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

919 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now