Solved

Registry OpenKey doesnt seem to work - Delphi 2010

Posted on 2011-09-26
1
1,171 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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

16 Experts available now in Live!

Get 1:1 Help Now