using namespace System::Text;

String ^TCHARtoStr(TCHAR *temp) //TCHAR转String
{
array<unsigned char> ^lname=gcnew array<unsigned char>(128);
String ^lName;
Marshal::Copy(IntPtr(temp),lname,0,lname->Length);
int ii;
for(ii=0;ii<lname->Length;ii++)
if(lname[ii]=='\0')
break;
lName=Encoding::Default->GetString(lname,0,ii);
delete lname;
return lName;
}

 

TCHAR* strName=(TCHAR*)(void*)Marshal::StringToHGlobalUni(Convert::ToString(this->textBox2->Text));

 

posted on 2018-12-24 17:32  幽love梦费重寻  阅读(931)  评论(0编辑  收藏  举报