本文整理汇总了C++中CStringArray::IsSerializable方法的典型用法代码示例。如果您正苦于以下问题:C++ CStringArray::IsSerializable方法的具体用法?C++ CStringArray::IsSerializable怎么用?C++ CStringArray::IsSerializable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStringArray
的用法示例。
在下文中一共展示了CStringArray::IsSerializable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Read
BOOL CRegistry::Read (LPCTSTR pszKey, CStringArray& scArray)
{
ASSERT(m_hKey);
const int iMaxChars = 4096;
int OldSize = (int) scArray.GetSize();
DWORD dwType;
DWORD dwData = iMaxChars;
BYTE* byData = (BYTE*)::calloc(iMaxChars, sizeof(TCHAR));
ASSERT(byData);
LONG lReturn = RegQueryValueEx(m_hKey, pszKey, NULL, &dwType,
byData, &dwData);
m_Info.lMessage = lReturn;
m_Info.dwType = dwType;
m_Info.dwSize = dwData;
if(lReturn == ERROR_SUCCESS && dwType == REG_BINARY)
{
ASSERT(dwData < iMaxChars);
CMemFile file(byData, dwData);
CArchive ar(&file, CArchive::load);
ar.m_bForceFlat = FALSE;
ASSERT(ar.IsLoading());
ASSERT(scArray.IsSerializable());
scArray.RemoveAll();
scArray.SetSize(10);
scArray.Serialize(ar);
scArray.SetSize(OldSize);
ar.Close();
file.Close();
}
if(byData)
{
free(byData);
byData = NULL;
}
if(lReturn == ERROR_SUCCESS)
return TRUE;
return FALSE;
}
示例2: Write
BOOL CRegistry::Write (LPCTSTR pszKey, CStringArray& scArray)
{
if (m_bReadOnly)
{
ASSERT (FALSE);
return FALSE;
}
ASSERT(m_hKey);
const int iMaxChars = 4096;
BYTE* byData = (BYTE*)::calloc(iMaxChars, sizeof(TCHAR));
ASSERT(byData);
CMemFile file(byData, iMaxChars, 16);
CArchive ar(&file, CArchive::store);
ASSERT(scArray.IsSerializable());
scArray.Serialize(ar);
ar.Close();
const DWORD dwLen = (DWORD) file.GetLength();
ASSERT(dwLen < iMaxChars);
LONG lReturn = RegSetValueEx(m_hKey, pszKey, 0, REG_BINARY,
file.Detach(), dwLen);
m_Info.lMessage = lReturn;
m_Info.dwSize = dwLen;
m_Info.dwType = REG_BINARY;
if(byData)
{
free(byData);
byData = NULL;
}
if(lReturn == ERROR_SUCCESS)
return TRUE;
return FALSE;
}
示例3: OnLButtonDown
void CSdtMfcAppView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CFile * pfile = new CFile(TEXT("test.txt"),CFile::modeReadWrite | CFile::modeCreate);
ASSERT(pfile);
CArchive ar(pfile,CArchive::store);
CString str = TEXT("ABCDEFG");
CStringArray arrStr;
arrStr.Add(str);
//ar<<arrStr;
BOOL flag = arrStr.IsSerializable();
if (ar.IsStoring())
{
// TODO: 在此添加存储代码
arrStr.Serialize(ar);
}
else
{
// TODO: 在此添加加载代码
}
CView::OnLButtonDown(nFlags, point);
}