Basic COM   «Prev 

Implementing DllRegisterServer and DllUnregisterServer

DllRegisterServer can use Win32 API calls RegCreatekeyEx and RegSetValueEx to add keys and values into the registry.
Strings entered into the registry are "wide" strings, meaning that they are 16 bits per character.
RegDeleteKey and RegDeleteValue can be used in DllUnregisterServer to remove a registry entry.
StringFromGUID2 takes in a CLSID in numeric format (for example, CLSID_O1) and converts it into a string.
GetModuleFileName gets the full path name of a module (for example, DLL) to enter as the InprocServer32 value.
Check the Win32 and COM documentation for details about the registry. Later on, we will develop a server using ATL. The ATL COM-Wizard will generate data and code that automatically handle registration for us.

Implementing DllRegisterServer

The final step is to implement the DllRegisterServer function. The DLL that contains the component must export this function. The function will be called by a set-up application, or when the user runs the Regsvr32.exe tool.
The following example in C++ shows a minimal implementation of DlLRegisterServer:

STDAPI DllRegisterServer(void){
    return AMovieDllRegisterServer2(TRUE);