title: How to convert c# string to c++ string when we pass string as parameter using winapis
body: <p>Using SendMessageW function I am passing c# string as a parameter to c++ function. I am typecasting to CString in c++ but it's value is empty. Please check below code and provide solution</p>
  
  <p>-----------------------c# code ------------------</p>
  
  <pre><code>public unsafe IntPtr Testing()
  {
  
    string string_aux = "Stringtochange";
    void* pt = Marshal.StringToBSTR(string_aux).ToPointer();
    IntPtr ab = new IntPtr(pt);
    return ab;
  }
  
  public void GetValue()  
  {
  
     SendMessageW(utilityHandle1, TVM_GETITEMHEIGHT, handle,Testing());
  
  }
  </code></pre>
  
  <p>--------------------- C++ code --------------</p>
  
  <pre><code>CString *st = (CString*)lParam;
  
  MessageBox(NULL,*st,L"stringvalue",NULL);
  </code></pre>
  
  <hr>
  
  <p>Here *st value is empty. </p>