Solved

Registry OpenKey doesnt seem to work - Delphi 2010

Posted on 2011-09-26
1
1,290 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

728 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