Marshal2: Self-Registration of Standard Marshaling Servers

Click to open or copy the Marshal2 project files.

Click to open or copy the Include files (required).

Click to open or copy the Library files (required).

Note   To use this sample, you must first build the Register sample.

The Marshal2 sample shows an alternate and more advanced technique for building a proxy/stub marshaling DLL for the ICar, IUtility, and ICruise custom interfaces. The previous Marshal sample illustrates the system default method of producing the marshaling DLL. That method controls the conditional compilation of the DLLDATA.C file to generate default definitions for the DllMain, DllRegisterServer, and DllUnregisterServer functions in the DLL. Marshal2 does not generate these default functions. Instead, they are coded explicitly.  Thus, this lesson has more detail on the content of these functions.

Although the default definitions of these functions are adequate for most programming, there may be occasions when you want more control over the content of the marshaling DLL. For example, you might want to perform some action within DllMain during DLL_PROCESS_ATTACH, you might want to code explicit control over the registration and unregistration of the marshaling server, or you might want to add standard module version information to the DLL resources. This sample covers these areas.

See the parent topic, COM Tutorial Samples, to download global tutorial files or any HTML files about this sample.

Building SDK Samples

This sample uses the following keywords:

dllmain; dllregisterserver; dllunregisterserver; getlasterror; getmodulefilename; getusername; lstrcat; lstrcpy; lstrlen; regclosekey; regcreatekeyex; regdeletekey; regsetvalueex; setregkeyvalue; stringfromguid2; text; unicodeok