c++ - Why the CString(LPCTSTR lpsz) constrcutor check the high two bytes of lpsz? -


i reading source code of cstring in mfc. curious implementation way of constructor cstring::cstring(lpctstr lpsz).

in understanding, before copying string indicated lpsz, needs check whether lpsz null no need combine checking if hiword(lpsz) null.

is mfc guy passing here , willing give explanations?

cstring::cstring(lpctstr lpsz) {     init();     if (lpsz != null && hiword(lpsz) == null)     {         uint nid = loword((dword)lpsz);         if (!loadstring(nid))             trace1("warning: implicit loadstring(%u) failed\n", nid);     }     else     {         int nlen = safestrlen(lpsz);         if (nlen != 0)         {             allocbuffer(nlen);             memcpy(m_pchdata, lpsz, nlen*sizeof(tchar));         }     } } 

it checks whether passed actual pointer or integer resource identifier makeintresource. in latter case loads string resources.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -