home *** CD-ROM | disk | FTP | other *** search
- // dtsxform.cpp : Implementation of DLL Exports.
-
-
- // Note: Proxy/Stub Information
- // To build a separate proxy/stub DLL,
- // run nmake -f dtsxformps.mk in the project directory.
-
- #include "stdafx.h"
- #include "resource.h"
- #include "initguid.h"
- #include "dtsxform.h"
-
- #include "dtsxform_i.c"
- #include "Xform.h"
- //category manager stuff
- #include <comcat.h>
-
-
- CComModule _Module;
-
- STDAPI RegisterCLSIDInCategory(REFCLSID clsid, CATID catid);
- STDAPI UnRegisterCLSIDInCategory(REFCLSID clsid, CATID catid);
-
-
- BEGIN_OBJECT_MAP(ObjectMap)
- OBJECT_ENTRY(CLSID_DTSStrCatXform, CXform)
- END_OBJECT_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // DLL Entry Point
-
- extern "C"
- BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
- {
- if (dwReason == DLL_PROCESS_ATTACH)
- {
- _Module.Init(ObjectMap, hInstance);
- DisableThreadLibraryCalls(hInstance);
- }
- else if (dwReason == DLL_PROCESS_DETACH)
- _Module.Term();
- return TRUE; // ok
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // Used to determine whether the DLL can be unloaded by OLE
-
- STDAPI DllCanUnloadNow(void)
- {
- return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // Returns a class factory to create an object of the requested type
-
- STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
- {
- return _Module.GetClassObject(rclsid, riid, ppv);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // DllRegisterServer - Adds entries to the system registry
-
- STDAPI DllRegisterServer(void)
- {
- HRESULT hr;
- // registers object, typelib and all interfaces in typelib
- hr = _Module.RegisterServer(TRUE);
- if (SUCCEEDED(hr))
- {
- //Do this for every transform clsid in this dll
- hr = RegisterCLSIDInCategory(CLSID_DTSStrCatXform, CATID_DTSCustomXform);
- }
- return hr;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // DllUnregisterServer - Removes entries from the system registry
-
- STDAPI DllUnregisterServer(void)
- {
- _Module.UnregisterServer();
- {
- //Do this for every transform clsid in this dll
- RegisterCLSIDInCategory(CLSID_DTSStrCatXform, CATID_DTSCustomXform);
- }
- return S_OK;
- }
-
-
- //Utility functions to do DTS specific registry entries
- //component category stuff..probably should be moved into oleutil
- STDAPI RegisterCLSIDInCategory(REFCLSID clsid, CATID catid)
- {
- // Register your component categories information.
- ICatRegister* pcr = NULL ;
- HRESULT hr = S_OK ;
- hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr);
- if (SUCCEEDED(hr))
- {
- // Register this category as being "implemented" by the class.
- CATID rgcatid[1] ;
- rgcatid[0] = catid;
- hr = pcr->RegisterClassImplCategories(clsid, 1, rgcatid);
- }
-
- if (pcr != NULL)
- pcr->Release();
-
- return hr;
- }
-
- STDAPI UnRegisterCLSIDInCategory(REFCLSID clsid, CATID catid)
- {
- ICatRegister* pcr = NULL ;
- HRESULT hr = S_OK ;
- hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr);
- if (SUCCEEDED(hr))
- {
- // Unregister this category as being "implemented" by the class.
- CATID rgcatid[1] ;
- rgcatid[0] = catid;
- hr = pcr->UnRegisterClassImplCategories(clsid, 1, rgcatid);
- }
-
- if (pcr != NULL)
- pcr->Release();
-
- return hr;
- }
-
-