当前位置: 首页>>代码示例>>C++>>正文


C++ CByteArray::GetData方法代码示例

本文整理汇总了C++中CByteArray::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ CByteArray::GetData方法的具体用法?C++ CByteArray::GetData怎么用?C++ CByteArray::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CByteArray的用法示例。


在下文中一共展示了CByteArray::GetData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void NS_ISERVER::CLocalServer::LocalAuditUserQuit(CString strTermID, CString strIP,UINT nMemberID)
{
	NET_HEAD_MAN head = {0};
	head.Version = COM_VER;
	head.Length = sizeof TIBAAuditUserQuit;
	head.Cmd = C_MANGER_AUDITUSERQUIT;

	TIBAAuditUserQuit info = {0};

	_snprintf(info.termID, LEN_TERMID, CT2A(strTermID));
	_snprintf(info.termIP, LEN_IPADDR, CT2A(strIP));
	info.memberID=nMemberID;

	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, &info, sizeof TIBAAuditUserQuit);

	m_lpSocket->SendBuffer(buffer.GetData(), buffer.GetSize());

	buffer.RemoveAll();

	IBA_LOG(_T("发送实名下机信息,TermID=%s,IP=%s,MemberID=%d"),strTermID,strIP,nMemberID);
}
开发者ID:layerfsd,项目名称:PersonalIBA,代码行数:25,代码来源:LocalServer.cpp

示例2: 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);
}
开发者ID:victimofleisure,项目名称:FFRend,代码行数:27,代码来源:Minizip.cpp

示例3: ConvertReceivedDataToString

CString ConvertReceivedDataToString(CByteArray & data)
   {
     // data is UTF-8 encoded
    CArray<WCHAR, WCHAR> wc;
     // First, compute the amount of space required.  n will include the
     // space for the terminal NUL character
    INT_PTR n = ::MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)data.GetData(), (int)data.GetSize(), NULL, 0);
    if(n == 0)
       { /* failed */
        DWORD err = ::GetLastError();
        TRACE(_T("%s: MultiByteToWideChar (1) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
        return CString(_T(""));
       } /* failed */
    else
       { /* success */
        wc.SetSize(n);
        n = ::MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)data.GetData(), (int)data.GetSize(), (LPWSTR)wc.GetData(), (int)n);
        if(n == 0)
           { /* failed */
            DWORD err = ::GetLastError();
            TRACE(_T("%s: MultiByteToWideChar (2) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
            return CString(_T(""));
           } /* failed */
       } /* success */     

     // Data is now in Unicode
     // If we are a Unicode app we are done
     // If we are an ANSI app, convert it back to ANSI

#ifdef _UNICODE
     // If this is a Unicode app we are done
    return CString(wc.GetData(), (int)wc.GetSize());
#else // ANSI
    // Invert back to ANSI
    CString s;
    n = ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wc.GetData(), (int)wc.GetSize(), NULL, 0, NULL, NULL);
    if(n == 0)
       { /* failed */
        DWORD err = ::GetLastError();
        TRACE(_T("%s: WideCharToMultiByte (1) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
        return CString("");
       } /* failed */
    else
       { /* success */
        LPSTR p = s.GetBuffer((int)n);
        n = ::WideCharToMultiByte(CP_ACP, 0, wc.GetData(), (int)wc.GetSize(), p, (int)n, NULL, NULL);
        if(n == 0)
           { /* conversion failed */
            DWORD err = ::GetLastError();
            TRACE(_T("%s: WideCharToMultiByte (2) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
            s.ReleaseBuffer();
            return CString("");
           } /* conversion failed */
        s.ReleaseBuffer();
        return s;
       } /* success */
#endif
   } // ConvertReceivedDataToString
开发者ID:Cholga,项目名称:tlcopy,代码行数:58,代码来源:Convert.cpp

示例4: GetData

HRESULT CClipboard::GetData(BYTE *pData, UINT *pnDataLength, UINT nClipboardKey)
{
   HRESULT hr = S_OK;

   if (pnDataLength == NULL)
      return E_POINTER;
   if (nClipboardKey == 0)
      return E_INVALIDARG;

   CByteArray *pByteArray = NULL;
   if (m_mapData.Lookup(nClipboardKey, pByteArray))
   {
      if (pData == NULL)
         *pnDataLength = pByteArray->GetSize();
      else
      {
         UINT nToCopy = min(*pnDataLength, (unsigned)pByteArray->GetSize());
         memcpy(pData, pByteArray->GetData(), nToCopy);
         *pnDataLength = nToCopy;
      }
   }
   else
      hr = S_FALSE; // element not found


   return hr;
}
开发者ID:identity0815,项目名称:os45,代码行数:27,代码来源:Clipboard.cpp

示例5: SendToProxy

BOOL CWDRealName::SendToProxy(CByteArray &buffer)
{
	BOOL bRet = FALSE;

	CWinSocket ProxySocket;

	if (ProxySocket.Create())
	{
		if (ProxySocket.Connect(CNetBarConfig::GetInstance()->GetProxyIP(), 7834, 5000))
		{
			if (ProxySocket.Send(buffer.GetData(), buffer.GetSize()) > 0)
			{
				bRet = TRUE;
			}
		}
		else
		{
			IBA_LOG(_T("Can't connect to %s(7834)!"), CNetBarConfig::GetInstance()->GetProxyIP());
		}

		ProxySocket.Close();
	}

	return bRet;
}
开发者ID:layerfsd,项目名称:PersonalIBA,代码行数:25,代码来源:WDRealName.cpp

示例6: 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
}
开发者ID:victimofleisure,项目名称:ChordEase,代码行数:19,代码来源:ChordEaseDoc.cpp

示例7: SendBuffer

void CLocalServer::SendBuffer(const NET_HEAD_MAN* pHead, const void* pBuf, BOOL bCheckStatus)
{
	if (bCheckStatus && m_CheckInStatus != 1)
	{
		return;
	}

	CByteArray buffer;
	buffer.SetSize(sizeof NET_HEAD_MAN + pHead->Length);

	memcpy(buffer.GetData(), pHead, sizeof NET_HEAD_MAN);

	if (pBuf != NULL)
	{
		memcpy(buffer.GetData() + sizeof NET_HEAD_MAN, pBuf, pHead->Length);
	}

	m_lpSocket->SendBuffer(buffer.GetData(), buffer.GetSize());
	buffer.RemoveAll();
}
开发者ID:layerfsd,项目名称:PersonalIBA,代码行数:20,代码来源:LocalServer.cpp

示例8: 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));
}
开发者ID:victimofleisure,项目名称:Fractice,代码行数:12,代码来源:Packets.cpp

示例9: GetControlData

BOOL CMFCControlContainer::GetControlData(WORD nIDC, DWORD& dwSize, BYTE*& pbData)
{
	CObject* pData = NULL;
	if (m_mapControlData.Lookup(nIDC, pData) && pData != NULL)
	{
		CByteArray* pArray = (CByteArray*)pData;
		dwSize = (DWORD)pArray->GetSize();
		pbData = pArray->GetData();
		return TRUE;
	}

	return FALSE;
}
开发者ID:Samangan,项目名称:mpc-hc,代码行数:13,代码来源:afxctrlcontainer.cpp

示例10: LocalUnlockScreen

void CLocalServer::LocalUnlockScreen(INT_PTR nIndex, CString strUnlockPwd)
{
	if (m_CheckInStatus != 1)
	{
		return;
	}

	if (ComputerList.IsInvaildIndex(nIndex))
	{
		return;
	}

	CComputerInfo& computer = ComputerList.GetComputer(nIndex);

	SCREEN_TERMINFO snapComputer = {0};
	_snprintf(snapComputer.termID, LEN_TERMID, CW2A(computer.GetTerminalID()));
	_snprintf(snapComputer.termIP, LEN_IPADDR, CW2A(computer.GetComputerIP()));

	NET_HEAD_MAN head = {0};

	head.Version = COM_VER;
	head.Length = sizeof SCREEN_TERMINFO + sizeof CHECK_PASSWORD;
	head.Cmd = C_MANGER_UNLOCKSCREEN;

	CHECK_PASSWORD pwd = {0};

	_snprintf(pwd.cPassword, LEN_CLIPASSWORD, CW2A(strUnlockPwd));
	
	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, &snapComputer, sizeof SCREEN_TERMINFO);
	memcpy(buffer.GetData() + sizeof NET_HEAD_MAN + sizeof SCREEN_TERMINFO, &pwd, sizeof CHECK_PASSWORD);

	m_lpSocket->SendBuffer(buffer.GetData(), buffer.GetSize());

	buffer.RemoveAll();
}
开发者ID:layerfsd,项目名称:PersonalIBA,代码行数:39,代码来源:LocalServer.cpp

示例11: 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."));
	}
}
开发者ID:layerfsd,项目名称:PersonalIBA,代码行数:49,代码来源:CommandProcessor.cpp

示例12: 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);
}
开发者ID:Samangan,项目名称:mpc-hc,代码行数:15,代码来源:afxctrlcontainer.cpp

示例13: 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));
}
开发者ID:victimofleisure,项目名称:Fractice,代码行数:16,代码来源:Packets.cpp

示例14: CompileFile

bool CTobCompiler::CompileFile(LPCTSTR fsrcname, LPCTSTR fdstname, F_ErrorHandler ErrorHandler)
{
	Reset();
	CString err;
	bool haserr = false;
	m_line = 1;

	m_fsrc = fopen(fsrcname, "rb");
	if(!m_fsrc)
	{
		m_err.Format("can't open src file '%s'", fsrcname);
		ErrorHandler(GetErrorString(err));
		return false;
	}
	for(;;)
	{
		EToken r = CompilePass1();
		if(r == ERR_EOF) break;
		if(r < 0)
		{
			haserr = true;
			if(!ErrorHandler(GetErrorString(err))) return false;
		}
		if(r == ERR_SEVERE) return false;
	}
	fclose(m_fsrc); m_fsrc = 0;

	if(!CompilePass2(ErrorHandler) || haserr) return false;

	m_fdst = fopen(fdstname, "wb");
	if(!m_fdst)
	{
		m_err.Format("can't create dst file '%s'", fdstname);
		ErrorHandler(GetErrorString(err));
		return false;
	}
	if(m_bin.GetSize() > 0 && fwrite(m_bin.GetData(), m_bin.GetSize(), 1, m_fdst) != 1)
	{
		fclose(m_fdst); m_fdst = 0;
		m_err.Format("can't write dst file '%s'", fdstname);
		ErrorHandler(GetErrorString(err));
		return false;
	}
	fclose(m_fdst); m_fdst = 0;
	return true;
}
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:46,代码来源:tobc_023.cpp

示例15: 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));
}
开发者ID:victimofleisure,项目名称:Fractice,代码行数:18,代码来源:Packets.cpp


注:本文中的CByteArray::GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。