诺
诺亚
Unregistered / Unconfirmed
GUEST, unregistred user!
这里有两段函数,由于我不懂VC语言,特此请求会这两种语言的大侠帮我转换成Delphi语法,不胜感激。int CTesttransferDlg::XorString(CString *pStr){ if( pStr->IsEmpty() ) { return 0; } int nStrLen; char xorResult; char hsb,lsb; int i; nStrLen = pStr->GetLength(); xorResult = 0; for( i=0;
i<nStrLen;
i++ ) { if( pStr->GetAt(i) == ' ' ) pStr->SetAt(i,'0'); xorResult = xorResult^pStr->GetAt(i); } lsb = xorResult & 0x0f; if(lsb<=9) lsb += 0x30; else
lsb += 55; hsb = xorResult; hsb >>= 4; if( hsb <= 9) hsb += 0x30; else
hsb += 55; pStr->Insert(nStrLen, "1234"); // pStr->SetAt( nStrLen, hsb ); pStr->SetAt( nStrLen+1, lsb ); pStr->SetAt( nStrLen+2, 42 ); pStr->SetAt( nStrLen+3, 13 ); return 1;}int CTesttransferDlg::SendString(CString strSend){ LPTSTR pstr=strSend.
GetBuffer(m_strEditSend.
GetLength()+1); int res=m_sock.Send(pstr,strSend.
GetLength()+1); int nReturn = 1; if((res==SOCKET_ERROR&&m_sock.GetLastError()==WSAEWOULDBLOCK)|| (res>0&&res<strSend.
GetLength()+1)) { m_sock.SetResend( (BYTE*)(pstr+((res==-1)?0:res)), (strSend.
GetLength()+1)-((res==-1)?0:res) ); } else
if(res==SOCKET_ERROR&&m_sock.GetLastError()!=WSAEWOULDBLOCK) { MessageBox("发送失败"); nReturn = 0; } strSend.
ReleaseBuffer(); return nReturn;}
i<nStrLen;
i++ ) { if( pStr->GetAt(i) == ' ' ) pStr->SetAt(i,'0'); xorResult = xorResult^pStr->GetAt(i); } lsb = xorResult & 0x0f; if(lsb<=9) lsb += 0x30; else
lsb += 55; hsb = xorResult; hsb >>= 4; if( hsb <= 9) hsb += 0x30; else
hsb += 55; pStr->Insert(nStrLen, "1234"); // pStr->SetAt( nStrLen, hsb ); pStr->SetAt( nStrLen+1, lsb ); pStr->SetAt( nStrLen+2, 42 ); pStr->SetAt( nStrLen+3, 13 ); return 1;}int CTesttransferDlg::SendString(CString strSend){ LPTSTR pstr=strSend.
GetBuffer(m_strEditSend.
GetLength()+1); int res=m_sock.Send(pstr,strSend.
GetLength()+1); int nReturn = 1; if((res==SOCKET_ERROR&&m_sock.GetLastError()==WSAEWOULDBLOCK)|| (res>0&&res<strSend.
GetLength()+1)) { m_sock.SetResend( (BYTE*)(pstr+((res==-1)?0:res)), (strSend.
GetLength()+1)-((res==-1)?0:res) ); } else
if(res==SOCKET_ERROR&&m_sock.GetLastError()!=WSAEWOULDBLOCK) { MessageBox("发送失败"); nReturn = 0; } strSend.
ReleaseBuffer(); return nReturn;}