none
String^ to LPCWSTR

    Question

  • How can i convert from 'System::String ^' to 'LPCWSTR'? I need to create a file with CreateFile command. I want to take the name of file from comboBox or textBox.  But when i wrote

    CreateFile(comboBox1->Text, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

    there is an error:

    Error 1 error C2664: 'CreateFileW' : cannot convert parameter 1 from 'System::String ^' to 'LPCWSTR'

    Saturday, April 22, 2006 9:25 AM

Answers