I am working on a program that opens a browser window and loads the appropriate URL when the user enters a URL in the text box. What is the easiest way to convert the URL from String to LPCSTR?
LPCTSTR x;
x = static_cast<LPCTSTR>(const_cast<void*>(static_cast<constvoid*>(System::Runtime::InteropServices::Marshal::StringToHGlobalAuto(inbox->Text))));
If you have a string of chars, YOU CANNOT CAST TO LPCTSTR. TCHARs are not chars all of the time. They might be wchar_t's.
If you have chars, use CreateProcessA()
If you have wchar_ts, use CreateProcessW()
If you have TCHARs, use CreateProcess()
As for how to get a char/wchar_t/TCHAR array from a String (which looks like it's part of some .NET stuff I'm not familiar with), I don't have a clue. But there's got to be some kind of c_str() or similar function that returns a pointer to the null terminated string data. From there you just have to figure out what type it is and call the appropriate function.