title: L prefix for strings in C++
body: <p>I have a static library. This library have the following function defined</p>
  
  <pre><code>int WriteData(LPTSTR s)
  </code></pre>
  
  <p>The sample to call the function is </p>
  
  <pre><code>LPTSTR s = (LPTSTR) L"Test Data";   
  int n = WriteData(s);
  </code></pre>
  
  <p>WriteData return 0 on success and -1 on failure.</p>
  
  <p>I am writing a dynamic DLL to export this function.</p>
  
  <pre><code>int TestFun(LPTSTR lpData)
  {
     return  WriteData(lpData);
  }
  </code></pre>
  
  <p>A C++ test application result</p>
  
  <pre><code>LPTSTR s = (LPTSTR) L"Test Data";   
  TestFun(s);  //OK  return 0
  
  LPTSTR s = (LPTSTR) "Test Data";    
  TestFun(s);  //Fail  return -1
  </code></pre>
  
  <p>I have to call it from a c# application. I assume my DLL-Import signature would be:</p>
  
  <pre><code>        [DllImport("Test.dll")]
          private static extern int TestFun(String s);
  </code></pre>
  
  <p>My question is very simple How can i call it from .Net? 
  As you can see i have control over </p>
  
  <pre><code>TestFun(LPTSTR lpData)
  </code></pre>
  
  <p>but no control over </p>
  
  <pre><code>WriteData(LPTSTR s)
  </code></pre>
  
  <hr>
  
  <p>Thanks everybody for their input. So far i am stuck on casting. I think my problem would be solved when i woul be able take input from user and write 2 line for casting in place of following line.</p>
  
  <pre><code>   LPTSTR s = (LPTSTR) L"Test Data"); //&lt;= How can ii take input from user and 
      TestFun(s);  //OK  return 0
  </code></pre>