本文整理汇总了C++中CByteArray::SetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CByteArray::SetSize方法的具体用法?C++ CByteArray::SetSize怎么用?C++ CByteArray::SetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CByteArray
的用法示例。
在下文中一共展示了CByteArray::SetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void NS_ISERVER::CLocalServer::LocalAskNotice(BOOL bSigned)
{
NET_HEAD_MAN head = {0};
head.Version = COM_VER;
head.Length = sizeof tag_ask_read_notice;
head.Cmd = C_MANGER_ASKREADNOTICE;
tag_ask_read_notice notice = {0};
notice.nAsk = (UINT)bSigned;
CByteArray buffer;
buffer.SetSize(sizeof NET_HEAD_MAN + head.Length);
memcpy(buffer.GetData(), &head, sizeof NET_HEAD_MAN);
memcpy(buffer.GetData() + sizeof NET_HEAD_MAN, ¬ice, sizeof tag_ask_read_notice);
m_lpSocket->SendBuffer(buffer.GetData(), buffer.GetSize());
buffer.RemoveAll();
if (bSigned)
{
CIBALog::GetInstance()->Write(_T("发送通告签收成功"));
}
else
{
CIBALog::GetInstance()->Write(_T("发送获取通告的请求"));
}
}
示例2: OnSendFromSerialPort
// 从串口发送数据
//************************************
// Method: OnSendFromSerialPort
// FullName: CUartToUdpSocket::OnSendFromSerialPort
// Access: private
// Returns: void
// Qualifier:
// Parameter: unsigned char * TXDATA
// Parameter: unsigned int uiCount
//************************************
void CUartToUdpSocket::OnSendFromSerialPort(unsigned char* TXDATA, unsigned int uiCount)
{
// 如果端口未打开则不发送数据
// if(NULL == hCom)
// {
// return;
// }
//
// OVERLAPPED wol;
// wol.Internal=0;
// wol.InternalHigh=0;
// wol.Offset=0;
// wol.OffsetHigh=0;
// wol.hEvent=CreateEvent(NULL,TRUE,FALSE,NULL);
//
// WriteFile(hCom,TXDATA,uiCount,NULL,&wol);
if (m_pctrlMSComm1 == NULL)
{
AfxMessageBox(_T("串口MSCOMM控件指针为空!"));
return;
}
if(m_pctrlMSComm1->get_PortOpen() == FALSE)
{
return;
}
CByteArray array;
array.RemoveAll();
array.SetSize(uiCount);
for(unsigned int i=0; i<uiCount; i++)
{
array.SetAt(i, TXDATA[i]);
}
m_pctrlMSComm1->put_Output(COleVariant(array)); // 发送数据
}
示例3: Extract
bool CMinizip::Extract(LPCTSTR FileName, LPCTSTR DestPath, UINT BufSize)
{
USES_CONVERSION;
if (unzLocateFile(m_ZipFile, T2CA(FileName), 0) != UNZ_OK)
return(FALSE);
if (unzOpenCurrentFile(m_ZipFile) != UNZ_OK)
return(FALSE);
CByteArray ba;
ba.SetSize(BufSize);
bool retc = FALSE; // assume failure
TRY {
CFile DestFile(DestPath, CFile::modeCreate | CFile::modeWrite);
int BytesRead;
while ((BytesRead = unzReadCurrentFile(m_ZipFile, ba.GetData(), BufSize)) > 0) {
DestFile.Write(ba.GetData(), BytesRead);
}
if (!BytesRead) // if EOF
retc = TRUE; // success provided current file closes OK
}
CATCH (CFileException, e) {
e->ReportError();
}
END_CATCH
if (unzCloseCurrentFile(m_ZipFile) != UNZ_OK) // close fails if bad CRC
return(FALSE);
return(retc);
}
示例4: Read
BOOL CRegistry::Read (LPCTSTR pszKey, CByteArray& bcArray)
{
ASSERT(m_hKey);
const int iMaxChars = 4096;
int OldSize = (int) bcArray.GetSize();
DWORD dwType;
DWORD dwData = iMaxChars;
BYTE* byData = (BYTE*)::calloc(iMaxChars, sizeof(TCHAR));
ASSERT(byData);
LONG lReturn = RegQueryValueEx(m_hKey, pszKey, NULL, &dwType,
byData, &dwData);
m_Info.lMessage = lReturn;
m_Info.dwType = dwType;
m_Info.dwSize = dwData;
if(lReturn == ERROR_SUCCESS && dwType == REG_BINARY)
{
ASSERT(dwData < iMaxChars);
CMemFile file(byData, dwData);
CArchive ar(&file, CArchive::load);
ar.m_bForceFlat = FALSE;
ASSERT(ar.IsLoading());
ASSERT(bcArray.IsSerializable());
bcArray.RemoveAll();
bcArray.SetSize(10);
bcArray.Serialize(ar);
bcArray.SetSize(OldSize);
ar.Close();
file.Close();
}
if(byData)
{
free(byData);
byData = NULL;
}
if(lReturn == ERROR_SUCCESS)
return TRUE;
return FALSE;
}
示例5: WriteHostNameReply
bool CPackets::WriteHostNameReply()
{
static const int MAX_HOST_NAME = 256;
DWORD PktLen = sizeof(PACKET_HDR) + MAX_HOST_NAME;
CByteArray pkt;
pkt.SetSize(PktLen);
FRAP_HOST_NAME_REPLY *pp = (FRAP_HOST_NAME_REPLY *)pkt.GetData();
if (gethostname(pp->HostName, MAX_HOST_NAME) == SOCKET_ERROR)
return(FALSE);
InitHdr(*pp, PMID_HOST_NAME_REPLY, PktLen);
return(Write(*pp, PktLen));
}
示例6: rreg
// Read Operation
int CFanmotorDlg::rreg(int reg_addr)
{
success=1;
CString s;
int dat=0;
long r;
int timeout_counter=0;
CByteArray baAddr;
baAddr.SetSize (1);
baAddr.SetAt(0,reg_addr);
COleVariant ReadAddress(baAddr); // Create ReadAddress argument
VARIANT dataIn;
VariantInit(&dataIn);
int datalen=2;//in bytes
if(this->virtual_board)
{
dat = ReadVirtualBoardReg(reg_addr, fOTP);
}
else
{
r = Bridge->ReadIICdataReg(L"0000011", 0x49, ReadAddress,datalen, &dataIn);
//r = Bridge->ReadIICdataReg(L"0000011", reg_addr, ReadAddress,datalen, &dataIn);
//Sleep(500);
//r = Bridge->ReadIICdataReg(L"0000011", 0x49, ReadAddress,datalen, &dataIn);//no data received.????
//do{
// timeout_counter++;
// if (timeout_counter == TIMEOUT){
// DisplayInforMessageBox((LPCWSTR)L"Error", (LPCWSTR)L"Device is not available.\nPlease check your hardware connection and power supply!");
// success = 0;
// }
// r = Bridge->ReadIICdataReg(L"0000011", 0x49, ReadAddress,datalen, &dataIn);
//}while ((r !=34) && (timeout_counter != TIMEOUT));
CString strByte;
for (long i = 0; i < datalen; i++) {
BYTE ReadByte;
SafeArrayGetElement(dataIn.parray, &i, &ReadByte);
strByte.Format(L"%02x",ReadByte);
s += strByte;
}
dat=use_debugdlg_main.string2int(s,2*datalen);
// success=1;
//}
//else {ErrorMsg(r);};
VariantClear(&dataIn);
}
return dat;
Sleep(20);
}
示例7: ConvertHexChar
//由于这个转换函数的格式限制,在发送框中的十六制字符应该每两个字符之间插入一个空隔
//如:A1 23 45 0B 00 29
//CByteArray是一个动态字节数组,可参看MSDN帮助
int CPageDebug::String2Hex(CString str, CByteArray &sendData)
{
int hexdata,lowhexdata;
int hexdatalen = 0;
int len = str.GetLength();
sendData.SetSize(len/2);
for(int i = 0; i < len;)
{
char lstr,hstr=str[i];
if(hstr == ' ')
{
i++;
continue;
}
i++;
if(i>len)
{
break;
}
lstr=str[i];
hexdata = ConvertHexChar(hstr);
lowhexdata = ConvertHexChar(lstr);
if((hexdata==16)||(lowhexdata==16))
{
break;
}
else
{
hexdata = hexdata*16+lowhexdata;
}
i++;
sendData[hexdatalen] = (char)hexdata;
hexdatalen++;
}
sendData.SetSize(hexdatalen);
return hexdatalen;
}
示例8: OnRespondGetLog
void CCommandProcessor::OnRespondGetLog(BYTE *pBuffer, size_t /*bufLen*/)
{
if (!m_bGetLog)
{
return;
}
m_bGetLog = FALSE;
try
{
NET_HEAD_MAN head = {0};
SCREEN_TERMINFO stTermInfo = {0};
GetHead(pBuffer, &head);
GetBody(pBuffer, &stTermInfo, sizeof(stTermInfo));
CByteArray buf;
buf.SetSize(head.Length - sizeof(stTermInfo));
CopyMemory(buf.GetData(), pBuffer + sizeof(head) + sizeof(stTermInfo), buf.GetSize());
CString strPicFile(theApp.GetWorkPath() + _T("\\IBATermLog\\"));
CIBAHelpper::MakeSurePathExists(strPicFile);
strPicFile.Append(CA2W(stTermInfo.termID));
strPicFile.Trim();
if (head.Version == 1) //zip
{
strPicFile.AppendFormat(_T("[%s].zip"), CIBAHelpper::GetCurrentTimeAsString());
}
else
{
strPicFile.AppendFormat(_T("[%s].log"), CIBAHelpper::GetCurrentTimeAsString());
}
SaveFile(strPicFile, buf);
}
catch (CFileException* e)
{
e->Delete();
CIBALog::GetInstance()->Write(_T("Get Log: Operation file failed."));
}
catch (...)
{
CIBALog::GetInstance()->Write(_T("Get Log failed."));
}
}
示例9: SetControlData
void CMFCControlContainer::SetControlData(WORD nIDC, DWORD dwSize, BYTE* pbData)
{
CByteArray* pArray = new CByteArray;
pArray->SetSize(dwSize);
BYTE* pbBuffer = pArray->GetData();
if (memcpy_s(pbBuffer, dwSize, pbData, dwSize) != 0)
{
delete pArray;
ASSERT(FALSE);
return;
}
m_mapControlData.SetAt(nIDC, pArray);
}
示例10: WriteStripDone
bool CPackets::WriteStripDone(UINT JobID, UINT ThreadIdx, float RenderTime, UINT y1, UINT y2, const ESCTIME *Strip, UINT StripSize)
{
UINT PktLen = sizeof(FRAP_STRIP_DONE_HDR) + StripSize;
CByteArray pkt;
pkt.SetSize(PktLen);
FRAP_STRIP_DONE *pp = (FRAP_STRIP_DONE *)pkt.GetData();
InitHdr(*pp, PMID_STRIP_DONE, PktLen);
pp->JobID = JobID;
pp->ThreadIdx = ThreadIdx;
pp->RenderTime = RenderTime;
pp->y1 = y1;
pp->y2 = y2;
pp->StripSize = StripSize;
memcpy(pp->Strip, Strip, StripSize);
return(Write(*pp, PktLen));
}
示例11: SendComm
//从串口发送数据
void SerialComm::SendComm(BYTE* sendData, int sendLength)
{
CByteArray send;
send.RemoveAll();
send.SetSize(sendLength);
for (size_t i = 0; i<sendLength; i++)
{
send.SetAt(i, sendData[i]);
}
myComm.put_Output(COleVariant(send));
for (size_t i = 0; i < 105; i++)
{
myReceiveDate[i] = 0;
}
}
示例12: OnbtnMSCommSend
void COscillDlg::OnbtnMSCommSend()
{
// TODO: Add your control notification handler code here
UpdateData( true );
CByteArray sendArr;
WORD wLength;
wLength = m_szMSCommSend.GetLength();
sendArr.SetSize( wLength );
for( int i =0; i<wLength; i++ )
{
sendArr.SetAt( i, m_szMSCommSend.GetAt( i ) );
}
// m_mscom.SetOutput( COleVariant(sendArr) );
}
示例13: ApplyProcessor
//************************************
// Method: ApplyProcessor
// FullName: CPHEEqualizer::ApplyProcessor
// Access: public
// Returns: procStatus
// Qualifier:
// Parameter: CImgSource * in_pImgSrc
// Parameter: CImgSource * out_ImgResult
//************************************
procStatus CPHEEqualizer::ApplyProcessor(CImgSource *in_pImgSrc, CImgSource *out_ImgResult)
{
ASSERT(in_pImgSrc);
ASSERT(in_pImgSrc->GetSourceRef());
ASSERT(out_ImgResult);
procStatus eRetCode = eNormal;
//CDWordArray arrProbalility;
CByteArray arrNewTable;
CHistogram oSrcHis;
eRetCode = in_pImgSrc->GetHistoram(oSrcHis);
#ifdef _DEBUG
// for (INT i=0; i<IMP_GRAY_LEVELS; i++)
// {
// TRACE("\nPos:%d \tVal:%d", i, oSrcHis.GetAt(i));
// }
// TRACE("\nTOTAL:%d", oSrcHis.Accumulate(IMP_GRAY_LEVELS-1));
#endif
INT nHisSize = oSrcHis.GetSize();
//arrProbalility.SetSize(nHisSize);
arrNewTable.SetSize(nHisSize);
DOUBLE nTotal = oSrcHis.Accumulate(nHisSize-1);
if(eRetCode == eNormal)
{
for(INT k=0; k<nHisSize; k++)
{
DOUBLE ta = oSrcHis.Accumulate(k);
DOUBLE dTemp = ((DOUBLE)oSrcHis.Accumulate(k)/nTotal) * (IMP_GRAY_LEVELS -1);
arrNewTable.SetAt(k, (BYTE) dTemp);
}
CProcGrayTransformer oTransformer;
oTransformer.m_eType = eCustomTrans;
oTransformer.InitCustomTransform(&arrNewTable);
eRetCode = oTransformer.ApplyProcessor(in_pImgSrc, out_ImgResult);
}
return eRetCode;
}
示例14: WriteDib
bool CPackets::WriteDib(UINT JobID, UINT FrameID, float RenderTime, PVOID DibBits, const DIB_INFO& DibInfo)
{
UINT DibLen = DibInfo.Length;
UINT PktLen = sizeof(FRAP_DIB_HDR) + DibLen;
CByteArray pkt;
pkt.SetSize(PktLen);
FRAP_DIB *pp = (FRAP_DIB *)pkt.GetData();
InitHdr(*pp, PMID_DIB, PktLen);
pp->JobID = JobID;
pp->FrameID = FrameID;
pp->RenderTime = RenderTime;
pp->Width = DibInfo.Size.cx;
pp->Height = DibInfo.Size.cy;
pp->BitCount = DibInfo.BitCount;
pp->DibLen = DibLen;
memcpy(pp->DibBits, DibBits, DibLen);
return(Write(*pp, PktLen));
}
示例15: ReadSongText
void CChordEaseDoc::ReadSongText(CFile& File, CString& Text)
{
ULONGLONG LongLen = File.GetLength();
ASSERT(LongLen <= UINT_MAX);
UINT len = static_cast<UINT>(LongLen);
// assume input file is ANSI text
#ifdef UNICODE
USES_CONVERSION;
CByteArray buf;
buf.SetSize(len + 1); // allocate buffer; extra byte for terminator
File.Read(buf.GetData(), len); // read ANSI text into byte buffer
LPCSTR pText = reinterpret_cast<LPCSTR>(buf.GetData());
Text = A2W(pText); // convert text from ANSI to Unicode and store
#else // ANSI
LPTSTR pText = Text.GetBuffer(len); // allocate text buffer
File.Read(pText, len); // read text into buffer
Text.ReleaseBuffer(len); // not null-terminated, so specify length
#endif
}