[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1406
  • Last Modified:

Registry OpenKey doesnt seem to work - Delphi 2010

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
Treppenmeister
Asked:
Treppenmeister
1 Solution
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now