2

I have a Delphi application with an automation object. On the start of the program, I want to register the COM object automatically in the registry (instead of using the /regserver switch).

The old version of the program was written in Delphi 7 and I think I remember that this version registered itself after program start. But now it's compiled with D2009 and it doesn't register itself now. Maybe somebody know something about this?

Thank you very much!

2 Answers 2

8

This is probably failing because you are running on a machine with UAC and you don't have rights to write to HKLM. You aren't going to find a satisfactory solution using the /regserver switch because it will always try to write there.

You could switch to registry free COM, although it might just be better to do the registration as part of installation. That's when you are expected to do it because that's when you know that you will have sufficient rights.

Sign up to request clarification or add additional context in comments.

5 Comments

Agreed - for security reasons the registration should really be done as part of the application installation process.
Hi, thanks for your responses. I already had in mind that it could be something related to UAC - but if this is the reason, the program should register automatically when I run it as administrator (or not?)
@gonzales right-click on the .exe and select "Run as Adminstrator". This solution is fine for in-house software but would be considered sub-par for professional software.
Hi David, yes I tried this and the registry information is not written. That's why I'm wondering that UAC should cause the problem.
@gonzales Hard to say without more details. If you are elevating then you will have rights to HKLM. It's easy enough to debug with debug DCUs and running RAD Studio elevated (so that the process it starts is elevated. Here's one quick guess. Your machine is 64 bit and you looking in the 64 bit part of the registry when in fact you need to look in the 32 bit area.
5

You can use ComServer.UpdateRegistry(True); to register your com objects and ComServer.UpdateRegistry(False); to un-register.

ComServer is found in ComServ.pas

http://docwiki.embarcadero.com/VCL/en/ComServ.TComServer.UpdateRegistry

5 Comments

Nice, thanks for this. But I'm still wondering why the program registerd itself when compiled with D7, and not when compiled with D2009...
The feature was removed by Embarcadero for the reasons mentions by David Heffernan. When running as a regular user or with UAC enabled you are not allowed to modify the parts of the registry that holds the com registration. In Delphi XE there should be a way to register COM object for current user only that probably will be able to run for non admins with UAC enabled.
Auto register com-server was removed in Delphi 2007. Previous versions always updated the registry regardless if it was necessary or not. The change is for the better.
Thank you very much for this input. Where did you get this informations? ;)
@gonzales I looked in ComServ.pas :). The change is made in procedure TComServer.Initialize;.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.