'System::String ^' to 'LPCWSTR'
.net, clr, visual-c++, winapi
Solution
The easiest way to do this in C++/CLI is to use `pin_ptr`:
#include <vcclr.h>
void CallFindFirstFile(System::String^ s)
{
WIN32_FIND_DATA data;
pin_ptr<const wchar_t> wname = PtrToStringChars(s);
FindFirstFile(wname, &data);
}
Problem
I want to convert `System::String ^` to `LPCWSTR`. for ``` FindFirstFile(LPCWSTR,WIN32_FIND_DATA); ``` Please help.