views:

208

answers:

2

I need to port a suite of Windows applications (running under XP with little security turned on) to Windows 7 with various levels of security, depending on how our clients may configure it. Each functional area is a seperate executable or DLL that is downloaded and registered by a central 'compound' application. This means that the different parts are all joined together to form in effect a large single application.

My problem is that the compound application knows about the other applications via COM registery, either as a typelibrary or as OCXs, where appropriate.

I have tried several questions here to try and solve the problems I am getting, but I don't seem to be able to get around the problem of needing elevated access to register applications and access the registry. Our clients will be expecting the same (relatively) seemless download and activation process as current under XP.

So does anyone have a solution for registering typelibraries and OCX controls without need to go through an elevation process.

Update :

Any solutions don't necessarily have to be in Delphi, solving this for any language would help me enormously.

Thanks in advance

A: 

Registering of COM applications etc requires the creation of keys and values under HKLM &/or HKCR in the registry. To write into those registry hives, an application MUST be elevated. For example, installers on Win7/Vista automatically run elevated, prompting users on startup with a UAC prompt (unless presumably your users have turned UAC off).

I think you will need to gently re-educate your clients with some modified expectations for Vista/Win7.

If you try and write into HKLM etc without being elevated, then you will probably run into issues where Vista/Win7 is virtualizing your access to the registry and your app then isn't writing into where it thinks it's writing.

There are a couple of SO answers here and here which should provide all of what you need to know to successfully get your Delphi app (or parts of it) elevated.

Conor Boyd
What add RegisterTypeLibForUser ? Do I require Elevated access for this ?
Mmarquee
I am unsure. We wanted our COM servers etc registered for any user. You also asked about "registry access", which I assumed meant registry access to e.g. HKLM in general. Regardless of type library registration, you will require elevated access to be able to write to HKLM or HKCR (if you're not running elevated, then I think you'll be writing to a virtualized view of the registry).
Conor Boyd
Access to HKLM can be changed, the registration of Typelibraries is the problem - Delphi only seems to make controls that access HKLM - rather than HKCU. I have to admit I am a bit lost with this.
Mmarquee
+1  A: 

I think I have solved it. If you override the DllRegisterServer and DllUnRegisterServer methods for each OCX, and in them redirect the access to the registry HKCR hive to HKCU, AND then change RegisterTypeLibrary from comserv.pas to call RegisterTypeLibForUser when the RegisterTypeLib call fails, then OCX controls can be registered without needing elevation. I think the true is of typelibraries as well.

The secret is that the OCX control needs to be changed, rather than the programs that register it.

Not sure if I have summarised this properly yet!

Mmarquee