CString转System::String ^应用实例

来源:互联网 发布:定时提醒软件 绿色 编辑:程序博客网 时间:2024/05/29 19:13

需要使用using namespace System; 


void CTrafficDetectDlg::OnNetStart()

{
NetPushGeoDaemon ^netPushGeoDaemon=gcnew NetPushGeoDaemon();

CString cstr = "";

// TODO: Add your command handler code here
dscServer.DoModal();//DSC服务界面

if(dscServer.isLogin)//打开DSC服务
{
cstr = dscServer.csDSCip;//DSC服务界IP Control传回IP地址
System::String ^ip = gcnew String(cstr.GetBuffer());//CString转System::String ^
cstr.ReleaseBuffer();//释放资源
//ip = gcnew String(dscServer.csDSCip);
if(netPushGeoDaemon->BuildNetConnection(ip,dscServer.iDSCport))//连接服务器
{
AfxMessageBox("打开DSC服务成功!");
}
else
{
AfxMessageBox("打开DSC服务失败!");
}


}
else//关闭DSC服务
{
if(netPushGeoDaemon->StopNetPushDaemon())//关闭服务器
{
AfxMessageBox("关闭DSC服务!");
}
else
{
AfxMessageBox("关闭DSC服务失败!");
}
}




//int N = 24;
//cli::array<System::Byte>^ senddata = gcnew cli::array<System::Byte>(N);
//char senddata1[24] ={ 0xFE, 0xEF, 0x03, 0x02, 0x01, 0x04, 0x05, 0x06, 0x07, 0x08, 0x0E, 0x04, 0x0B, 0x0E, 0x0D, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xAA };
//for(int i=0;i<N;i++)
//{
// senddata[i]=senddata1[i];
//}
//netPushGeoDaemon->NetPushDataRecordThread(senddata);//发送数据





}
0 0
原创粉丝点击