Print Page | Close Window

CXTPPropExchange faq

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=9715
Printed Date: 19 June 2025 at 7:26am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPPropExchange faq
Posted By: jimmy
Subject: CXTPPropExchange faq
Date Posted: 27 February 2008 at 7:03am
Hello,

i use CXTPPropExchange function to save & store some data.

static void PropLOS2Data(CXTPPropExchange* pPX, SLOS2Data& ld)
{
    CXTPPropExchangeSection secLD(pPX->GetSection("LOS2Data"));

    PX_ULong(&secLD, _T("CRC"), ld.dwCRC, 0);
    PX_ULong(&secLD, _T("LenData"), ld.dwLenData, 0);
    // ??? PX_CharBuffer(&secLD, _T("PasswordOnline"), ld.szPasswordOnline, "");
}

With this function i save/load some data from a struct.
DWORD, int values are no problem.

#define MAX_PASSWORD   19

struct SLOS2Data
{
  ULONG dwCRC;
  ULONG dwLenData;
  char szPassword[MAX_PASSWORD + 1];
}

But how can i save/load szPassword ?
The szPassword is always \0 terminated.

I have wrote this template, but how can i save/load it ?
Or is there a other nice solution ?

template<class TYPE> BOOL PX_CharBuffer(CXTPPropExchange* pPX, LPCTSTR pszPropName, TYPE& szBuf, LPCTSTR lpDefault)
{
    int iBufSize = sizeof(szBuf);
    // DWORD nBytes = iBufSize;
    // return PX_Blob(pPX, pszPropName, szBuf, nBytes);
}

  Jimmy




Replies:
Posted By: jimmy
Date Posted: 27 February 2008 at 7:31am
Is this a correct way ?

template<class TYPE> void CharBufCpy(TYPE& szBuf, const CString& lpText)
{
    int iSize = sizeof(szBuf) - 1;
    memset(szBuf, 0, iSize + 1);
    int iLenText = lpText.GetLength();
    if (iLenText > iSize)
        iLenText = iSize;
    strncpy(szBuf, lpText, iLenText);
}

template<class TYPE> BOOL PX_CharBuffer(CXTPPropExchange* pPX, LPCTSTR pszPropName, TYPE& szBuf, LPCTSTR lpDefault)
{
    if (pPX->IsStoring())
    {
        CString strVal(szBuf);
        return PX_String(pPX, pszPropName, strVal);
    }
    else
    {
        CString strVal;
        BOOL bOk = PX_String(pPX, pszPropName, strVal, lpDefault);
        if (bOk)
            CharBufCpy(szBuf, strVal);
        return bOk;
    }
}

  Jimmy



Posted By: Oleg
Date Posted: 27 February 2008 at 1:40pm
Hi,
 
Maybe easy to change "char szPassword" to "CString strPassword" in struct ?
:)
 
 


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jimmy
Date Posted: 28 February 2008 at 3:09am
No, because the struct is a binary mapping of a file.

  Jimmy




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net