NoradEE
asked on
Delphi 2006 Relative registry open Win7 x64
Hi,
I want to read and then write some key registry in 7x64 but this function doesn't work as I want
FReg.OpenKey('SOFTWARE\Mic rosoft\Win dows NT\CurrentVersion\
it opens automaticly SOFTWARE\Wow6432Node\SOFTW ARE\Micros oft\ ...
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
I want to read and then write some key registry in 7x64 but this function doesn't work as I want
FReg.OpenKey('SOFTWARE\Mic
it opens automaticly SOFTWARE\Wow6432Node\SOFTW
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
ASKER
"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...
No I cannot just have exe which must modify registry in that way...
ASKER
Maybe some Winapi ? Has anyone got Win7 MSDN ?
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
content:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microso ft-com:asm .v1"
xmlns:asmv1="urn:schemas-m icrosoft-c om:asm.v1" xmlns:asmv2="urn:schemas-m icrosoft-c om:asm.v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microso ft-com:asm .v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microso ft-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="requireAdministrato r" 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="requireAdministrato r" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Co mmon-Contr ols"
version="6.0.0.0"
processorArchitecture="X86 "
publicKeyToken="6595b64144 ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</asmv1:assembly>
2. administrator.rc
content:
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.
You'll need this files:
1. administrator.manifest
content:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microso
xmlns:asmv1="urn:schemas-m
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microso
<security>
<requestedPrivileges xmlns="urn:schemas-microso
<!-- 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="requireAdministrato
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="requireAdministrato
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Co
version="6.0.0.0"
processorArchitecture="X86
publicKeyToken="6595b64144
language="*"
/>
</dependentAssembly>
</dependency>
</asmv1:assembly>
2. administrator.rc
content:
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.
ASKER
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"
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_A CCESS OR KEY_WOW64_64KEY);
RegOut64.RootKey := HKEY_LOCAL_MACHINE;
What you may also try is to open the registry in 64 bit mode:
RegOut64 := TRegistry.Create(KEY_ALL_A
RegOut64.RootKey := HKEY_LOCAL_MACHINE;
I forgot this:
const
KEY_WOW64_64KEY = $0100;
KEY_WOW64_32KEY = $0200;
const
KEY_WOW64_64KEY = $0100;
KEY_WOW64_32KEY = $0200;
ASKER
Thomas what is that?
Will this work on Delphi 2006 ?
I need to modify such code:
OpenKey('SOFTWARE\Microsof t\Windows NT\CurrentVersion\Mysoft', False) then
begin
FRegValue := Trim(FReg.ReadString('Valu e'));
Will this work on Delphi 2006 ?
I need to modify such code:
OpenKey('SOFTWARE\Microsof
begin
FRegValue := Trim(FReg.ReadString('Valu
You need to search for the Registry object.
You must have something like:
myRegistry.OpenKey()
somewhere in the code myRegistry is created
myRegistry := TRegistry.Create(KEY_ALL_A CCESS);
you must add the 64bit access rights to that:
myRegistry := TRegistry.Create(KEY_ALL_A CCESS OR KEY_WOW64_64KEY);
You must have something like:
myRegistry.OpenKey()
somewhere in the code myRegistry is created
myRegistry := TRegistry.Create(KEY_ALL_A
you must add the 64bit access rights to that:
myRegistry := TRegistry.Create(KEY_ALL_A
ASKER
I'ts mixed too much
simply again can someone give full code replacement for that?
----------------
I need to modify such code:
OpenKey('SOFTWARE\Microsof t\Windows NT\CurrentVersion\Mysoft', False) then
begin
FRegValue := Trim(FReg.ReadString('Valu e'));
-----------------
simply again can someone give full code replacement for that?
----------------
I need to modify such code:
OpenKey('SOFTWARE\Microsof
begin
FRegValue := Trim(FReg.ReadString('Valu
-----------------
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.
ASKER
ok so how to do that?
Sumarry of all your posts?
Please write me in one comment instead of few mixed
Would be thankful.
Regards
Sumarry of all your posts?
Please write me in one comment instead of few mixed
Would be thankful.
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks ok
mlmcc