The Manual Technique
With the two previous techniques, your program has no way to control which machine OCRClient
should talk to. Because there’s no way to programmatically specify a server destination, COM looks into the registry to pull out a pre-configured server destination. The technique that we’re about to discuss allows us to control which machine the OCRClient
application should communicate with. To do this, we need to use one of the COM activation API functions discussed in Chapter 4. The first thing that you should do is to add a handler for the Manual
button, because you will need to add code to this handler. We’ll do that now, naming the handler OnManual.
Remote Activation API Functions
COM publishes a number of activation API functions. The lowest API function is CoGetClassObject, which returns a requested class factory interface pointer for object creation. There are also the CoGetInstanceFromFile and CoGetInstanceFromIStorage API functions that activate an object and initialize it with persistent data.
However, the one that we often use is CoCreateInstanceEx, which allows us to pass along two important pieces of information. The first is the COSERVERINFO
structure, which allows us to set security options and server destination. In this section, we will be simple and just set the server destination, as the security member of the COSERVERINFO
structure is discussed in detail in Chapter 5 and Chapter 9. The second structure that you need to know is MULTI_QI
, which allows ...
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.