I use CMemFile and CArchive
First store in ar and save buffer from file in Registry key
What I store is CObArray
The object is:
class Sites
CString first,second;
CString GetFirst();
CString GetSecong();
Here is my OnCreate() where I whant to read stored data and init CListBox

const INT nSIZE = 4096;
HKEY hKey;
DWORD dwType;
DWORD dwData  = nSIZE;
BYTE* bData   = (BYTE*)::calloc(nSIZE, sizeof(TCHAR));

     if(ERROR_SUCCESS !=
    MessageBox("Error Open");

const LONG retValue = ::RegQueryValueEx(hKey, "proba", NULL, &dwType,bData, &dwData);
if(retValue == ERROR_SUCCESS && REG_BINARY == dwType)

  // Load Read values in file
  CMemFile file(bData, nSIZE);
  //Attach file to archive
  CArchive ar(&file, CArchive::load);

  //Load "object"



// Loop and load elements to List box
     for(int i=0;i < object.GetSize();i++)
          Sites*     pSite=(Sites*)object[i];
          CRuntimeClass*     pRt=pSite->GetRuntimeClass();

          if(pSite->IsKindOf(RUNTIME_CLASS(Sites))) MessageBox("It Is");
          CListBox* pList=(CListBox*)dlgbar.GetDlgItem(IDC_LIST);
My problem is that pRt->m_nObjectSize;
in not 0 but string stay empty
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

what is the full definition of Sites look like?

CObList::Serialize requires that you provide friend operators for << and >> for non CObject classes (eg CString)

friend CArchive& AFXAPI operator<<(CArchive& ar, const Sites& sites)
  ar << sites.first;
  ar << sites.second;

friend CArchive& AFXAPI operator>>(CArchive& ar, Sites& sites)
  ar >> sites.first;
  ar >> sites.second;

plamtodAuthor Commented:
class Sites : public CObject  
     void SetSecond(CString nSecond);
     CString GetSecond();
     CString first;
     void SetFirst(CString nFirst);
     CString GetFirst();
     virtual ~Sites();

     CString second;
//     CString first;


It's possible
CObArray object;
yes but whan you do DECLARE_SERIAL you will see that MFC defines that you require the above >> friend operator (afx.h) - the above operators I mentioned above - should work (Maybe with a few mods) but the essence is there

> It's possible

it is working now ? or it compiles ?
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

plamtodAuthor Commented:
I use the idea from

Should I predefine <<(>>).
I see - but if you look in mfc/src/list_s.cpp you will see that CStringList::Serialize(CArchive& ar) understands that it is dealing with CStrings and will therefore serialize them correctly - what I am saying is that MFC does not undestand how to serialize Sites and will need help (from you)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
plamtodAuthor Commented:
Thanks a lot.
I wasn't overload Serialize for Sites class
Now O.K.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.