📄 lucentcti.cpp
字号:
// lucentCti.cpp : Implementation of DLL Exports.
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f lucentCtips.mk in the project directory.
#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "lucentCti.h"
#include "lucentCti_i.c"
#include "CTIEvent.h"
#include "MichelleCTI.h"
#include "DirectoryNumber.h"
#include "KVList.h"
#include "KVPair.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_CTIEvent, CCTIEvent)
OBJECT_ENTRY(CLSID_MichelleCTI, CMichelleCTI)
OBJECT_ENTRY(CLSID_DirectoryNumber, CDirectoryNumber)
OBJECT_ENTRY(CLSID_KVList, CKVList)
OBJECT_ENTRY(CLSID_KVPair, CKVPair)
END_OBJECT_MAP()
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern BOOL GlobalStartup(HINSTANCE hInstance);
extern void GlobalCleanup();
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_Module.Init(ObjectMap, hInstance, &LIBID_CTILib);
DisableThreadLibraryCalls(hInstance);
if (!GlobalStartup(hInstance))
return FALSE;
}
else if (dwReason == DLL_PROCESS_DETACH)
{
GlobalCleanup();
_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)
{
// registers object, typelib and all interfaces in typelib
// DebugBreak();
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
return _Module.UnregisterServer(TRUE);
}
static HRESULT InternalCreateInstance(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
LPCLASSFACTORY pFactory;
HRESULT hRes = _Module.GetClassObject(rclsid, IID_IClassFactory, (LPVOID *)&pFactory);
if(SUCCEEDED(hRes)) {
hRes = pFactory->CreateInstance(NULL, riid, ppv);
pFactory->Release();
}
return(hRes);
}
#define DEFINE_CASTER(Class, Interface) \
Class *I2C(Interface *pInterface) \
{ \
Class *pClass = NULL; \
if(pInterface) \
pClass = dynamic_cast<Class *>(pInterface); \
return(pClass); \
}
#define DEFINE_CREATOR(Class, Interface, rclsid, riid) \
HRESULT CreateClass(Class **ppClass, Interface **ppInterface) \
{ \
HRESULT hRes = InternalCreateInstance(rclsid, riid, (LPVOID *)ppInterface); \
if(SUCCEEDED(hRes)) { \
*ppClass = I2C(*ppInterface); \
if(!*ppClass) { \
(*ppInterface)->Release(); \
*ppInterface = NULL; \
hRes = E_FAIL; \
} \
} \
return(hRes); \
}
DEFINE_CASTER(CKVPair, IKVPair)
DEFINE_CASTER(CKVList, IKVList)
DEFINE_CASTER(CCTIEvent, ICTIEvent)
DEFINE_CASTER(CDirectoryNumber, IDirectoryNumber)
DEFINE_CREATOR(CKVPair, IKVPair, CLSID_KVPair, IID_IKVPair)
DEFINE_CREATOR(CKVList, IKVList, CLSID_KVList, IID_IKVList)
DEFINE_CREATOR(CCTIEvent, ICTIEvent, CLSID_CTIEvent, IID_ICTIEvent)
DEFINE_CREATOR(CDirectoryNumber, IDirectoryNumber, CLSID_DirectoryNumber, IID_IDirectoryNumber)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -