title: Delphi WideString in Visual Studio MFC
body: <p>I have am trying to receive information from a EXE that was written in Delphi.  The EXE passes me a pointer to one of its data structures:</p>
  
  <pre><code>Type
    RecordType = Record
      St:   WideString;
      Next: Pointer;
    End;
  
  Var
    DataRec: ^RecordType;
  </code></pre>
  
  <p>So in Visual Studio MFC I have declared a data type that should be similar:</p>
  
  <pre><code>struct RecordRec
  {
    BSTR St;
    void *Next;
  };
  
  RecordRec *DataRec;
  </code></pre>
  
  <p>The Delphi Help says that a WideString is compatible with a BSTR, however, this does not work.  When I look at my St in Debug Mode it says</p>
  
  <pre><code>"0x0000000000000000 &lt;Bad Ptr&gt;   wchar_t *"
  </code></pre>
  
  <p>I don't know how to declare the equivalent of a WideString in Visual Studio MFC.</p>
  
  <p>If it was a ShortString I would declare:</p>
  
  <pre><code>struct RecordRec
  {
    BYTE StLen;
    char St[255];
    void *Next;
  };
  </code></pre>
  
  <p>but this does not work for a WideString and I really don't think I should declare a variable with ~2^30 (1,073,741,824) characters in it.</p>
  
  <p>What am I missing?  I really hope that someone can help.</p>