Creating a Component

Since you’ve already learned how to create dynamic linked library and normal executable components, we’re going to do something different in this chapter. You’ll create an NT service that acts as an OCR server. Recall that an NT service can start up by itself when the machine is powered up. This can be an advantage after a power outage, at which time the machine powers itself back up, allowing your service to automatically come back to life. This is nice since it can happen without the need of an administrator.

However, this problem doesn’t apply to COM components, because components can be dynamically activated. In other words, the SCM will launch the correct component upon client request even if the component was not an NT service. From the COM perspective, there is really no reason why we’re creating an NT service other than the fact that the ATL COM AppWizard allows us to create this kind of component by simply checking a box. By checking this option, all the necessary code for an NT service is generated for you. Knowing this, even if you don’t want to use COM, you can take advantage of this option to generate the underlining code for a regular NT service executable.

Before you build this component, you should take note that the screen shots shown throughout this book may differ slightly from the ones that you see on your computer monitors. This is because new features will continue to be added as ATL and MFC evolve.

Figure 6-1. The ATL COM AppWizard dialog ...

Get Learning DCOM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.