VC.net String to LPWSTR
问题 How can I transform from string to LPWSTR String^ str= "hello world"; LPWSTR apppath= (LPWSTR)(Marshal::StringToHGlobalAnsi(str).ToPointer()); But it doesn't work.After transformed: 回答1: You're trying to read single-byte characters (that's what Marshal::StringToHGlobalAnsi is returning) as wide characters (that's what an LPWSTR type points to), and you're getting whatever is in memory interpreted as a wide-character string. You need to marshal the appropriate type, and you need to be aware of