Delphi 2006 Relative registry open Win7 x64


I want to read and then write some key registry in 7x64 but this function doesn't work as I want
FReg.OpenKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion\

it opens automaticly SOFTWARE\Wow6432Node\SOFTWARE\Microsoft\ ...

How to open the same key as requested without this "Wow6432Node" ?
I need solution which will open read and then write IDENTICAL key on x32 XP and 7x64

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You may need to run in 32-bit emulation mode under Win 7 or if there is a XP emulation mode.

NoradEEAuthor Commented:
"You may need to run in 32-bit emulation mode under Win 7 or if there is a XP emulation mode "

No I cannot just have exe which must modify registry in that way...
NoradEEAuthor Commented:
Maybe some Winapi ? Has anyone got Win7 MSDN ?
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

To write to local machine on Windows Vista/7 your program needs admin rights. There is no way around it.

You'll need this files:

1. administrator.manifest


<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
  <assemblyIdentity version="" name=""/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <!-- UAC Manifest Options
            If you want to change the Windows User Account Control level replace the
            requestedExecutionLevel node with one of the following.

        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

            If you want to utilize File and Registry Virtualization for backward
            compatibility then delete the requestedExecutionLevel node.
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

2. administrator.rc


1 24 "administrator.manifest"

now use the command file to create a resource file:

brcc32 administrator.rc

you can a .res file.

Now in your .dpr file add this line:

{$R 'administrator.res' 'administrator.rc'}

Your program will prompt for UAC access and write directly to the registry from now on.

NoradEEAuthor Commented:
Dear ThomasReimann.

I'm afraid that you've not read carefully and do not understood problem.
File is running with full admin privileges (right click "Run ad administrator") this is not problem

Problem is to store to reg path without this "Wow6432Node"
In my tests about one year ago, it was not enough to run the program as administrator, you had to have the manifest included in the exe.

What you may also try is to open the registry in 64 bit mode:

     RegOut64 := TRegistry.Create(KEY_ALL_ACCESS OR KEY_WOW64_64KEY);
     RegOut64.RootKey := HKEY_LOCAL_MACHINE;
I forgot this:


  KEY_WOW64_64KEY = $0100;
  KEY_WOW64_32KEY = $0200;
NoradEEAuthor Commented:
Thomas what is that?

Will this work on Delphi 2006 ?

I need to modify such code:
OpenKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion\Mysoft', False) then
      FRegValue := Trim(FReg.ReadString('Value'));

You need to search for the Registry object.

You must have something like:


somewhere in the code myRegistry is created

myRegistry := TRegistry.Create(KEY_ALL_ACCESS);

you must add the 64bit access rights to that:

myRegistry := TRegistry.Create(KEY_ALL_ACCESS OR KEY_WOW64_64KEY);
NoradEEAuthor Commented:
I'ts mixed too much
simply again can someone give full code replacement for that?
I need to modify such code:
OpenKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion\Mysoft', False) then
      FRegValue := Trim(FReg.ReadString('Value'));
You don't have to change OpenKey() at all, you must search where the Registry object is created and change it to 64bit there. Leave OpenKey() alone.
NoradEEAuthor Commented:
ok so how to do that?
Sumarry of all your posts?
Please write me in one comment instead of few mixed

Would be thankful.
You must do two things to access LOCAL_MACHINE on a 64 bit Vista/7 system.

1. The program must run with full admin rights. You can implement these by adding the administrator manifest. I've described it earlier.
2. You must find the position in your code where the Registry Object is created. Search for TRegistry.Create. If you found it replace whatever is in Create() with Create(KEY_ALL_ACCESS OR KEY_WOW64_64KEY); If your system does not know KEY_WOW64_64KEY, then add const KEY_WOW64_64KEY = $0100; to your program.

I suggest you also read the basics about TRegistry in the Delphi Help file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NoradEEAuthor Commented:
thanks ok
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.