STDAPI_(void) DllEnumRegistrationInfo(REGISTRYINFOPROC pEnumProc, LPARAM lParam)
{ try
  { OutputDebugFmt(_T("DllEnumRegistrationInfo()\n"));

    LPCTSTR prodPrefix = NULL;
    LPCTSTR compPrefix = NULL;
    TCHAR   szModulePath[MAX_PATH];

    COMServer::GetModuleFileName(szModulePath,ARRAYSIZE(szModulePath));

    VersionInfo verInfo(szModulePath);

    prodPrefix = (LPCTSTR)verInfo.GetStringInfo(_T("ProductPrefix"));
    compPrefix = (LPCTSTR)verInfo.GetStringInfo(_T("ComponentPrefix"));

    Registry registry;

    registry.SetComponentId(compPrefix);

    COMServer::GetModuleFileName(szModulePath,ARRAYSIZE(szModulePath));

    RegistryUtil::RegisterComObjectsInTypeLibrary(registry,szModulePath);

    registry.EnumRegistry(pEnumProc,lParam);
  }
  catch(BVR20983Exception e)
  { OutputDebugFmt(_T("DllRegistrationInfo(): Exception \"%s\" [%ld]>\n"),e.GetErrorMessage(),e.GetErrorCode());
    OutputDebugFmt(_T("  Filename \"%s\" Line %d\n"),e.GetFileName(),e.GetLineNo());
  }
  catch(exception& e) 
  { OutputDebugFmt(_T("DllRegistrationInfo(): Exception <%s,%s>\n"),typeid(e).name(),e.what()); }
  catch(...)
  { OutputDebugFmt(_T("DllRegistrationInfo(): Exception\n")); }
} // of DllEnumRegistrationInfo()
/**
 * RUNDLL32.EXE <dllname>,DllRegistrationInfo <filename>
 *
 * hwnd        - window handle that should be used as the owner window for any windows your DLL creates
 * hinst       - your DLL's instance handle
 * lpszCmdLine - command line your DLL should parse
 * nCmdShow    - describes how your DLL's windows should be displayed
 */
STDAPI_(void) _DllRegistrationInfo_(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine,int nCmdShow)
{ try
  { OutputDebugFmt(_T("DllRegistrationInfo(): <%s>\n"),lpszCmdLine);

    LPCTSTR prodPrefix = NULL;
    LPCTSTR compPrefix = NULL;
    TCHAR   szModulePath[MAX_PATH];

    COMServer::GetModuleFileName(szModulePath,ARRAYSIZE(szModulePath));

    VersionInfo verInfo(szModulePath);

    prodPrefix = (LPCTSTR)verInfo.GetStringInfo(_T("ProductPrefix"));
    compPrefix = (LPCTSTR)verInfo.GetStringInfo(_T("ComponentPrefix"));

    TCHAR filename[MAX_PATH];

    ::memset(filename,_T('\0'),MAX_PATH);

    int     i         = 0;
    boolean stop      = false;
    boolean newFormat = false;
    LPTSTR  nextToken = NULL;
    for( LPTSTR tok=_tcstok_s(lpszCmdLine,_T(" "),&nextToken);NULL!=tok && !stop;tok=_tcstok_s(NULL,_T(" "),&nextToken),i++ )
    {
      if( _tcscmp(tok,_T("-new"))==0 )
        newFormat = true;
      else
      { _tcscpy_s(filename,MAX_PATH,tok);

        stop = true;
      } // of else
    } // of for

    if( filename[0]!=_T('\0') )
    { basic_ostringstream<TCHAR> msgStream;
      msgStream<<_T("file=")<<filename;

      //::MessageBox(hwnd,msgStream.str().c_str(),_T("DllRegistrationInfo"),MB_OK | MB_ICONINFORMATION);

      { Registry registry;
        TCHAR    szModulePath[MAX_PATH];

        if( newFormat )
          registry.SetDumpType(Registry::XML);
        else
          registry.SetDumpType(Registry::MSI);

        registry.SetComponentId(compPrefix);

        COMServer::GetModuleFileName(szModulePath,ARRAYSIZE(szModulePath));

        RegistryUtil::RegisterComObjectsInTypeLibrary(registry,szModulePath);

#ifdef _UNICODE
        wofstream fos(filename,ios::app);
#else
        ofstream fos(filename,ios::app);
#endif

        fos<<registry;

        fos.close();
      } // of if
    } // of if
    else 
      PrintRegistrationInfoUsage(hwnd);
  }
  catch(BVR20983Exception e)
  { OutputDebugFmt(_T("DllRegistrationInfo(): Exception \"%s\" [%ld]>\n"),e.GetErrorMessage(),e.GetErrorCode());
    OutputDebugFmt(_T("  Filename \"%s\" Line %d\n"),e.GetFileName(),e.GetLineNo());
  }
  catch(exception& e) 
  { OutputDebugFmt(_T("DllRegistrationInfo(): Exception <%s,%s>\n"),typeid(e).name(),e.what()); }
  catch(...)
  { OutputDebugFmt(_T("DllRegistrationInfo(): Exception\n")); }
} // of _DllRegistrationInfo_()