Interface ICom Car IUnknown

1.0 Type Library) library ATLCARSERVERLib importlib(stdole32.tlb) importlib(stdole2.tlb) helpstring(ComCar Class) In addition to updating your type information, the Object Wizard also alters your server-wide object map with a new OBJECT_ENTRY macro. Each object in your ATL server will be listed here. The major code updates come by way of the addition of three new source code files ComCar.h The header file for your new coclass ComCar.cpp The implementation file for your new coclass ComCar.rgs...

The Full MIDL Output

In addition to the .tlb file, the MIDL compiler also generates a number of files that are intended to be used during the development of the COM server and C COM clients. Figure 2-8 illustrates the complete MIDL output. RawCu Cir_pjC dllda'a.c f 1 1 med tc build a uttoa stub and proxy DLL Lo unKjl y uj C H Entcrfacci RawCu Cir_pjC dllda'a.c f 1 1 med tc build a uttoa stub and proxy DLL Lo unKjl y uj C H Entcrfacci Figure 2-8 Output of the Midl.exe compiler As you can see, the name of each output...

The IClass Factory interface

Interface IClassFactory IUnknown in, unique IUnknown pUnkOuter, in REFIID riid, out, iid_is riid void ppvObject HRESULT LockServer in BOOL fLock The most critical and most often called method is CreateInstance , which creates an instance of the associated coclass on behalf of the calling client. LockServer is used less often and is used to hold the binary server itself in memory per client request recall the global lock counter . Class objects exist only to create another type of COM object....

Building Scriptable Objects Using IDispatch

The final topic of this chapter is to refresh the role of IDispatch. As you have just seen, C and Visual Basic 6.0 are able to exercise early binding when making use of COM types. Early binding describes the process of understanding the calling conventions for a given interface method at compile time rather than at runtime. Using this preferred technique, a COM client is able to make sure that the method name and parameter format is abiding by the contract laid out in the server's type library....

COM Type Information

The previous two chapters were more concerned with the internal composition of COM in-process servers than the finer details of IDL or COM type information in general . Understanding COM type information is critical when exploring the issues behind COM and .NET interoperability for one simple reason When a .NET type attempts to access a legacy COM type, an intermediate object termed a Runtime Callable Wrapper, or simply RCW is responsible for translating between COM types and .NET types. For...

Viewing Your Imports and Exports Using dumpbinexe

The dumpbin.exe utility is a command line tool that allows you to view a number of details for a given unmanaged DLL or EXE . Like most command line tools, dumpbin.exe supports a set of command line flags you use to inform it exactly what you are interested in viewing. Table 1-1 illustrates some of the more common options. exported from an executabl e file or DLL. imported to an executabl e file or DLL. default if no other option is specified. First, let's check out the set of imported modules...

The Disparams structure allows you to send over all required parameters to a method using one data structure

Typedef struct tagDISPPARAMS size_is cArgs VARIANTARG rgvarg Array of arguments. size_is cNamedArgs DISPID rgdispidNamedArgs Array of named arguments. UINT cArgs of items in array. UINT cNamedArgs of named arguments. DISPPARAMS More often than not, you only need to concern yourself with the first and third fields of the DISPPARAMS structure. As for the other fields, automation objects can support the idea of named arguments. The Visual Basic language allows developers to call a method and send...

Accessing a Coclass Using CoCreate Instance

Having seen CoGetClassObject in action, you can now look at CoCreateInstance . This function is useful if you only require a single instance of the coclass. CoCreateInstance finds the class object and calls CreateInstance from the IClassFactory pointer automatically. All you do is pass in the CLSID and IID you are looking for CoCreateInstance creates the class factory for you automatically. HRESULT CoCreateInstance REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID...

Understanding IClass Factory

Because COM is a language-independent architecture, a client cannot create a COM object using a language-specific keyword. For example, the C new operator has no built-in ability to create a new instance of a binary object. Also, a COM client can create a server that may be located at any location in the Enterprise. Given these two issues locality- and language-independence , you need a language- and location-neutral way in which a client can create a COM object. This is accomplished through...

The Marshal Class

is a key type that is used with all facets of .NET interoperability. This sealed class defines a healthy dose of static Shared in terms of VB .NET members that provides a bridge between managed and unmanaged constructs. When you are working with PInvoke proper meaning you are not interested in communicating with COM-based DLLs , you really only need to access a very small subset of its overall functionality. In fact, a majority of the members provided by the Marshal type are most useful when...