📄 dictionary.h
字号:
// Dictionary.h : Declaration of the CDictionary
#pragma once
#ifdef STANDARDSHELL_UI_MODEL
#include "resource.h"
#endif
#ifdef POCKETPC2003_UI_MODEL
#include "resourceppc.h"
#endif
#ifdef SMARTPHONE2003_UI_MODEL
#include "resourcesp.h"
#endif
#ifdef AYGSHELL_UI_MODEL
#include "resourceayg.h"
#endif
#include "ALTCOMM.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
#define MaxWordCount 10000
#define MaxWordLength 32
//数据字典翻译
struct DictWord {
TCHAR wordFromLang[MaxWordLength];
TCHAR wordToLang[MaxWordLength];
//bool bChange;
};
// CDictionary
class ATL_NO_VTABLE CDictionary :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CDictionary, &CLSID_Dictionary>,
public IDictionary
{
public:
CDictionary()
: m_wordcount(0)
, m_dictname(NULL)
, m_lchange(0)
{
for(int i=0; i<MaxWordCount; i++)
{
m_pData[i].wordFromLang[0] = 0;
m_pData[i].wordToLang[0] = 0;
}
m_dictname = new TCHAR[140];
}
//#ifndef _CE_DCOM
DECLARE_REGISTRY_RESOURCEID(IDR_DICTIONARY)
//#endif
BEGIN_COM_MAP(CDictionary)
COM_INTERFACE_ENTRY(IDictionary)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
delete m_dictname;
}
public:
STDMETHOD(InitialDict)(BSTR bStrDict);
STDMETHOD(AddWord)(BSTR SrcWord, BSTR DestWord);
STDMETHOD(ModifyWord)(BSTR SrcWord, BSTR DestWord);
STDMETHOD(DeleteWord)(BSTR bStrWord);
STDMETHOD(QueryWord)(BSTR bStrWord, BSTR* bStrDest);
STDMETHOD(SyncDictLib)(void);
STDMETHOD(Hello)(LONG HelloNo, LONG* pHello);
private:
// 修改字符
long m_lchange;
// 数据词典数
long m_wordcount;
// 数据词典名
TCHAR *m_dictname;
IDBCreateSession *m_pIDBCreateSession;
// 从BSTR字符串转换到CHAR型
struct DictWord m_pData[MaxWordCount];
//函数
STDMETHODIMP ConvertBstrToChar(BSTR pbStrFrom, TCHAR * pcTo);
// //根据单词查找字典顺序
STDMETHODIMP GetIndexOfWord(BSTR bStrWordFnd, long * lIndex);
// 打开字典数据库
HRESULT OpenDatabase(void);
// 创建数据库
HRESULT CreateDatabase(void);
// 执行脚本
HRESULT ExecuteSQL(ICommandText * pICmdText, WCHAR * pwszQuery);
// 初始化内存数组
HRESULT InitDictWord(void);
BOOL GetColumnOrdinal(DBCOLUMNINFO* pDBColumnInfo, DWORD dwNumCols, WCHAR* pwszColName, DWORD* pOrdinal);
};
OBJECT_ENTRY_AUTO(__uuidof(Dictionary), CDictionary)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -