如何把一个结构体变量数组写入注册表?

解决方案 »

  1.   

    TRegistry 只有WriteInteger,WriteString之类,怎么写一个结构体进去。
      

  2.   

    把结构体按照顺序变成一个String 就可以了
      

  3.   

    CWinApp::WriteProfileBinary
    CWinApp::GetProfileBinarymsdn上的例子CWinApp* pApp = AfxGetApp();const TCHAR* pszKey = _T("My Section");
    struct complex {
      double re, im;
    } myData = { 1.4142, -0.5 };// Write the information to the registry.pApp->WriteProfileBinary(pszKey, _T("ComplexData"), (LPBYTE)&myData, 
       sizeof(myData));// Read the information from the registry.complex* pData;
    UINT n;
    BOOL ret = pApp->GetProfileBinary(pszKey, _T("ComplexData"), (LPBYTE*)&pData, 
       &n);ASSERT(ret);
    ASSERT(n == sizeof(complex));
    ASSERT(myData.re == pData->re);
    ASSERT(myData.im == pData->im);
    delete [] pData; // free the buffer
      

  4.   

    关键的是把结构体的数据转化为string ,然后WriteString写入。