-2

I have an application that makes use of the registry and it worked fine until I moved to XE8 and Windows 10 64 bit. Now the only way I can get it to work with the registry is to run XE8 as an administrator and recompile the application. Why is that?

Is there a way to configure XE8 so that it always runs as administrator?

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Seti Net
  • 693
  • 1
  • 7
  • 24
  • 3
    Running your IDE as admin, as a matter of course, is a bad idea. If your process really needs to run as admin, then you need to indicate that in the application manifest. One wonders whether or not you really do need to be running as admin. Probably you previous application had no manifest and you were running virtualized. Probably you never got round to updating your application for UAC back in 2005. Without specific details of why you need to modify HKLM, and how your app is designed, it's hard to give specific advice. – David Heffernan Sep 23 '15 at 11:41

1 Answers1

1

I have an application that makes use of the registry and it worked fine until I moved to XE8 and Windows 10 64 bit. Now the only way I can get it to work with the registry is to run XE8 as an administrator and recompile the application. Why is that?

The Registry API has not changed. Accessing the Registry works the same regardless of which version of Delphi your app is compiled in. Running the IDE itself as an admin has no effect on whether the compiled app runs as an admin, unless you are running the app inside the IDE's debugger.

Without seeing your actual code, or knowing what Registry key(s) you are trying to access, or even knowing if your app is compiled for 32bit or 64bit, there is no real way to answer your question. All we can do is guess.

You are likely trying to access a Registry key that you do not have access to when running your app as a non-admin. Either the access will simply fail outright, or more likely is being silently redirected by Registry Virtualization, Registry Redirector, or Registry Reflection to another section of the Registry, depending on what the root issue of your problem actually is.

Is there a way to configure XE8 so that it always runs as administrator?

For the IDE itself? Create a shortcut to bds.exe, go into the shortcut Properties, and enable the "Run this program as an administrator" option.

For your app? Add a UAC manifest to your project that sets the requestedExecutionLevel value to requireAdminstrator. If you need to debug the app, the IDE has to run as an admin as well.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Thank you Remy. Your comment made clear the operation of Administrator when running the IDE and also allowed me to find the problem. I was enumerating the USB subsystem on HKEY_LOCAL_MACHINE but using an OpenKey that required Administrator privilidges. I changed this to OpenKeyReadOnly('HARDWARE') and it works fine now. Thanks again. – Seti Net Sep 24 '15 at 17:01
  • @Seti Your old versions of the program were also broken in the same way. – David Heffernan Sep 26 '15 at 08:07