Transformation between ISTREAM interface and cstring

xiaoxiao2021-03-06  23

Q: How to pass the string included in the cstring to a function with the ISTREAM type parameter? Q: How to get a string according to the ISTREAM interface pointer? A: The unidentified class cstreamoncstring in the MFC7 implements the M_STRSTREAM member of the ISTREAM interface to access the packaged cstring type. If you don't have an MFC7, you can create an ISTREAM's memory stream to create an ISTREAM's memory stream. After calling iStream :: Write to write strings to memory flow objects; or create iStream's memory stream to implement objects, repeated call iStream :: read and iStream :: Write copys data from source stream to memory stream, and then calls the gethglobalfromstream function directly to directly access the memory handle. Some of the above calls are encapsulated in the MFC into the ColestreamFile class. The following code reads a memory to the byte array. You can convert byte arrays into strings based on the type of string. Colestreamfile Osfread; OSfread.attach (PStream); Long Llength = OSfread.getLength (); CBYTEARRAY BABUF; Babuf.Setsize (LLEngth); Osfread.Read (Babuf.GetData (), LLENGTH);

转载请注明原文地址:https://www.9cbs.com/read-65316.html

New Post(0)