Skip to content

Instantly share code, notes, and snippets.

@j2doll
Created March 30, 2018 03:13
Show Gist options
  • Select an option

  • Save j2doll/3ce86586f212ece091b7df319a44f5d3 to your computer and use it in GitHub Desktop.

Select an option

Save j2doll/3ce86586f212ece091b7df319a44f5d3 to your computer and use it in GitHub Desktop.
AfxWriteStringLength
void AFXAPI AfxWriteStringLength(CArchive& ar, UINT_PTR nLength, BOOL bUnicode)
{
if (bUnicode)
{
// Tag Unicode strings
ar<<(BYTE)0xff;
ar<<(WORD)0xfffe;
}
if (nLength < 255)
{
ar<<(BYTE)nLength;
}
else if (nLength < 0xfffe)
{
ar<<(BYTE)0xff;
ar<<(WORD)nLength;
}
else if (nLength < 0xffffffff)
{
ar<<(BYTE)0xff;
ar<<(WORD)0xffff;
ar<<(DWORD)nLength;
}
else
{
ar<<(BYTE)0xff;
ar<<(WORD)0xffff;
ar<<(DWORD)0xffffffff;
ar<<(ULONGLONG)nLength;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment