在wince中使用STL的MAP必须在stdafx.cpp中添加下列语句,否则编译会报lockit错误.
#include "stdafx.h"
#ifdef UNDER_CE
#include <yvals.h>
namespace std
{
_Lockit::_Lockit()
{
}
_Lockit::~_Lockit()
{
}
};
#endif
/
使用IMultiLanguage2接口检测字符串的编码,在windows上正常运行,但是在WINCE上会失败。
在wince上进行DetectInputCodepage时检测无效,如果没有包含Internet Explorer Multiple-Language Base API组件,
IMultiLanguage2接口会创建失败,但是还是检测不准。
#include "Mlang.h"
void CVCDetectDlg::OnButton1()
{
// TODO: Add your control notification handler code here
::CoInitializeEx(NULL,COINIT_MULTITHREADED); // init COM
IMultiLanguage2* pIMultiLanguage2 = NULL;
HRESULT hr = S_OK;
hr = CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER, IID_IMultiLanguage2, (void**)&pIMultiLanguage2);
if (hr == S_OK)
{
DetectEncodingInfo encoding[10];
CFile file;
if (!file.Open("5.txt",CFile::modeRead | CFile::shareDenyNone, NULL))
{
return ;
}
int nFileLen = (int)file.GetLength();
// char *pBuf = new char[nFileLen];
char *pBuf = new char[nFileLen+1];
memset(pBuf, 0, nFileLen +1);
// memset(pBuf, 0, nFileLen );
file.SeekToBegin();
file.Read(pBuf,nFileLen);
file.Close();
// char* str1="中华人民共和国万岁";
char* str1=pBuf;
int nScores = 10;
int nBufLen = strlen(str1);
memset(encoding, 0, sizeof(DetectEncodingInfo)*10);
hr = pIMultiLanguage2->DetectInputCodepage(MLDETECTCP_NONE, 0, str1, &nBufLen, encoding, &nScores);
if (hr == S_OK)
{
TRACE(_T("%d,%d/n"), encoding[0].nLangID, encoding[0].nCodePage);
}
pIMultiLanguage2->Release();
delete []pBuf;
}
::CoUninitialize();
}
//