📄 imcf.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name:
imcf.cpp
Abstract:
MS Qwerty Input Method COM Class Factory CClassFactory implementation.
--*/
#ifndef UNDER_CE
#include "wchar.h"
#endif
#include "dllmain.h"
#include "imcf.h"
#include "im.h"
extern "C" const CLSID CLSID_CMSMultiboxIm;
//
// Ctor, Dtor.
//
CClassFactory::CClassFactory( REFCLSID rclsid )
{
g_dwObjectCount++ ;
m_cRef = 1;
m_clsid = rclsid;
}
CClassFactory::~CClassFactory()
{
g_dwObjectCount-- ;
}
//
// IUnknown methods.
//
STDMETHODIMP CClassFactory::QueryInterface( REFIID riid, LPVOID FAR* ppobj )
{
*ppobj = NULL;
if( IID_IUnknown == riid || IID_IClassFactory == riid ) {
*ppobj = (LPVOID)this;
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) CClassFactory::AddRef(VOID)
{
return ++m_cRef;
}
STDMETHODIMP_(ULONG) CClassFactory::Release(VOID)
{
// RETAILMSG(1,(TEXT("CF Release 0x%08x\r\n"),m_cRef));
if( --m_cRef ) {
return m_cRef;
}
delete this;
return 0;
}
//
// IClassFactory methods.
//
STDMETHODIMP CClassFactory::CreateInstance(
IUnknown FAR* pUnkOuter,
REFIID riid,
LPVOID FAR *ppunkObject )
{
HRESULT hr = E_FAIL;
if( ppunkObject ) {
*ppunkObject = NULL;
}
//
// We don't aggregate
//
if( pUnkOuter ) {
return CLASS_E_NOAGGREGATION;
}
if( pUnkOuter && riid != IID_IUnknown ) {
return E_INVALIDARG;
}
//
// Create the class object and retrieve the requested interface.
//
if( CLSID_CMSMultiboxIm == m_clsid)
{
CInputMethod *pInputMethod = new CInputMethod(pUnkOuter, g_hInstDll);
if ( !pInputMethod )
return E_OUTOFMEMORY;
hr = pInputMethod->QueryInterface( riid, ppunkObject );
if ( FAILED(hr) )
delete pInputMethod;
}
return hr;
}
STDMETHODIMP CClassFactory::LockServer( BOOL fLock )
{
if( fLock ) {
g_dwObjectCount++;
}else{
g_dwObjectCount--;
}
return NOERROR;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -