VC代码
typedef struct date
{
char count;
char order;
char temp[30];
};
void CChatDlg::OnTiquDy()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
CTime t=CTime::GetCurrentTime();
CString strTime="(%m-%d %H:%M:%S)";
strTime=t.Format(strTime);
UpdateData();
// info sendinfo;
// m_list.GetLBText(m_list.GetCurSel(),toname);
/* if(toname=="everyone")
{
sendinfo.type=1;
m_read=m_read+"\r\n"+strTime+"you to everyone:"+m_send;
m_send=strTime+m_name+"to everyone:"+m_send;
}
else
{ sendinfo.type=2;
LPCTSTR q=toname;
memcpy(sendinfo.name,q,toname.GetLength()+1);
m_read=m_read+"\r\n"+strTime+"you to"+toname+"say:"+m_send;
m_send=strTime+m_name+"you say to:"+m_send;
}
*/
#ifdef KG
date space;
memset((void *)&space, 0,sizeof(space));
LPCTSTR s=m_send;
memcpy(space.temp,s,m_send.GetLength()+1);
// memcpy(sendinfo.msg,s,m_send.GetLength()+1);
space.order=1;
// memcpy(sendinfo.msg,s,m_send.GetLength()+1);
int nCharSend=send(sockServer,(char *)&space,sizeof(space),0);
if(nCharSend==SOCKET_ERROR)
MessageBox("发送过程中发生一个错误!",NULL,MB_OK); m_read=m_read+"\r\n"+strTime+"you print :"+m_send;
m_send="";
#endif
UpdateData(FALSE);
GetDlgItem(IDC_EDIT2)->SetFocus();
}delphi代码
date=record
count:char;
order:char;
temp:array [0..30] OF char;
end;procedure TForm1.BitBtn1Click(Sender: TObject);
var
text: String;
space:date;
begin
OpenConnect;
if Client1.Active = True then
Client1.Active := False;
IF Client1.Connect THEN form1.Caption:='链接成功'; space.count:='0';
space.order:='1';
space.temp:='LONGSH';
//clientsocket.Socket.SendBuf(SendData,SizeOf(senddata));
client1.SendBuf(space,SizeOf(space));
form1.Caption:='发送成功';
sleep(500);
Client1.Disconnect;
form1.Caption:='断开链接';
end;转成后能链接喷码机(中科汇百H9喷码机),但是打印的数据更新不了,请问如何解决
typedef struct date
{
char count;
char order;
char temp[30];
};
void CChatDlg::OnTiquDy()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
CTime t=CTime::GetCurrentTime();
CString strTime="(%m-%d %H:%M:%S)";
strTime=t.Format(strTime);
UpdateData();
// info sendinfo;
// m_list.GetLBText(m_list.GetCurSel(),toname);
/* if(toname=="everyone")
{
sendinfo.type=1;
m_read=m_read+"\r\n"+strTime+"you to everyone:"+m_send;
m_send=strTime+m_name+"to everyone:"+m_send;
}
else
{ sendinfo.type=2;
LPCTSTR q=toname;
memcpy(sendinfo.name,q,toname.GetLength()+1);
m_read=m_read+"\r\n"+strTime+"you to"+toname+"say:"+m_send;
m_send=strTime+m_name+"you say to:"+m_send;
}
*/
#ifdef KG
date space;
memset((void *)&space, 0,sizeof(space));
LPCTSTR s=m_send;
memcpy(space.temp,s,m_send.GetLength()+1);
// memcpy(sendinfo.msg,s,m_send.GetLength()+1);
space.order=1;
// memcpy(sendinfo.msg,s,m_send.GetLength()+1);
int nCharSend=send(sockServer,(char *)&space,sizeof(space),0);
if(nCharSend==SOCKET_ERROR)
MessageBox("发送过程中发生一个错误!",NULL,MB_OK); m_read=m_read+"\r\n"+strTime+"you print :"+m_send;
m_send="";
#endif
UpdateData(FALSE);
GetDlgItem(IDC_EDIT2)->SetFocus();
}delphi代码
date=record
count:char;
order:char;
temp:array [0..30] OF char;
end;procedure TForm1.BitBtn1Click(Sender: TObject);
var
text: String;
space:date;
begin
OpenConnect;
if Client1.Active = True then
Client1.Active := False;
IF Client1.Connect THEN form1.Caption:='链接成功'; space.count:='0';
space.order:='1';
space.temp:='LONGSH';
//clientsocket.Socket.SendBuf(SendData,SizeOf(senddata));
client1.SendBuf(space,SizeOf(space));
form1.Caption:='发送成功';
sleep(500);
Client1.Disconnect;
form1.Caption:='断开链接';
end;转成后能链接喷码机(中科汇百H9喷码机),但是打印的数据更新不了,请问如何解决
然后跟 delphi 对比 看哪一步输出不对
俺做驱动 vc--delphi 时就这么做的 尤其是记录结构 数据类型
->
client1.SendBuf(PChar(space),SizeOf(space));数组长度是30个,是0..29,不是0..30