Click here to Skip to main content
Licence 
First Posted 2 May 2000
Views 82,678
Bookmarked 36 times

Enable an MFC ActiveX Control to Self-Register

By | 6 Jun 2000 | Article
A simple method that enables your MFC ActiveX Control to be self-registering

Why Self-Registering?

You have developed some ActiveX controls. If the user has to register your controls before they can be used, they will feel inconvenienced. It is better to have the components register themselves. If you use ATL to develop your ActiveX control, it comes with a self-registering capability automatically. However, if you use MFC, the control is not self-registering by default. This article shows you how to enable self-registering for MFC ActiveX controls.


What is Self-Registering?

Self-Registering means that the server enables the client to register and unregister the server at run-time. In other words, the client who wants to use the DLL server will register it if the server is enabled for self-registering. You don’t have to work with the Registry. A self-registering DLL server, for example an ATL ActiveX control, exports two functions for registering and unregistering itself: DllRegisterServer() and DllUnregisterServer(). They are called by an external program.

The procedure is as follows:

  1. The client looks for the string OleSelfRegister in the version information of the server.
  2. If this string is found, the client registers the server using the pointer obtained from DllRegisterServer() in the server.
  3. After using the server, the client calls DllUnregisterServer() in the server to unregister it.

When you create a MFC ActiveX control using VC++, the control is not self-registering by default. To modify it to be self-registering, you need to edit the Version Information in the resource. However, the resource editor does not let you do it. You have to open the .rc file and edit it manually. All you have to do is to add:

VALUE "OLESelfRegister", "\0"
following
VALUE "ProductVersion", "1, 0, 0, 1\0"

After you edit, the version information block will look something like this:

VALUE "CompanyName", "MyCompany\0"
VALUE "FileDescription", "MyCtrl ActiveX Control Module\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", " MyCtrl \0"
VALUE "LegalCopyright", "Copyright (C) 2000\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", " MyCtrl.OCX\0"
VALUE "ProductName", " MyCtrl ActiveX Control Module\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
VALUE "OLESelfRegister", "\0"

Then you build the control again, you will get a self-registering ActiveX control.


License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Frank W. Wu

Technical Lead

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow to register & load the MFC ActiveX Control built for a Smartphone Device? Pinmembersnehayp0:21 25 Jan '10  
QuestionInstallation of my applications developed in VB 6 PinmemberJuvent0:09 23 Aug '08  
QuestionCan Anyone help me in solving this problem ??? Pinmemberpraveen gahlot19:21 26 May '08  
AnswerRe: Can Anyone help me in solving this problem ??? PinmemberFrank W. Wu5:55 27 May '08  
GeneralATL Composite Control doesn't register PinmemberDexterND23:38 15 May '07  
GeneralRe: What does that mean? PinsussAnon21:20 7 Jun '00  
GeneralRe: What does that mean? PinmemberAnonymous0:56 26 Oct '01  
QuestionWhat does that mean? PinsussAlvaro Mendez12:51 3 May '00  
AnswerRe: What does that mean? PinsussJosef Haslinger20:33 3 May '00  
AnswerRe: What does that mean? PinsussWenfei Wu3:46 4 May '00  
GeneralRe: What does that mean? PinsussAlvaro Mendez10:06 8 May '00  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 7 Jun 2000
Article Copyright 2000 by Frank W. Wu
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid