本文整理汇总了C++中CByteArray::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CByteArray::GetSize方法的具体用法?C++ CByteArray::GetSize怎么用?C++ CByteArray::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CByteArray
的用法示例。
在下文中一共展示了CByteArray::GetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: SetRTF
void CRichEditCtrlGS::SetRTF(const CByteArray& arrRTF)
{ SCookieByteArray CookieRTF;
CookieRTF.lSize = arrRTF.GetSize();
CookieRTF.lStart = 0;
CookieRTF.pInText = &arrRTF;
CookieRTF.pOutText = NULL;
CString strRTF = _T("");
if( arrRTF.GetSize() > 5 )
{ strRTF = TCHAR(arrRTF[0]);
strRTF += TCHAR(arrRTF[1]);
strRTF += TCHAR(arrRTF[2]);
strRTF += TCHAR(arrRTF[3]);
strRTF += TCHAR(arrRTF[4]);
}
// Read the text in
EDITSTREAM es;
es.dwError = 0;
es.pfnCallback = StreamInCByteArray; // Set the callback
es.dwCookie = (DWORD)&CookieRTF; // and the informations
if( strRTF.CompareNoCase(_T("{\\rtf")) == 0 )
{ StreamIn(SF_RTF,es);
}
else
{ StreamIn(SF_TEXT,es);
}
}
示例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
示例4: CreateExtUserParams
//----------------------------- FUNCTION -------------------------------------*
void PropGSDModule::CreateExtUserParams()
{
DWORD dwCurrentPos;
CByteArray UserParam;
UserParam.RemoveAll();
ExtParam* pParam = NULL;
int offset = 0;
UserParam.InsertAt(0, &m_DefaultUserPrmData);
dwCurrentPos = UserParam.GetSize();
if (m_bExtUserPrms) {
// This sets all default parameter and of unused ExtUserPrms
POSITION pos = ExtUserParams.GetHeadPosition();
while (pos) {
pParam = (ExtParam*)ExtUserParams.GetNext(pos);
ModifyParamArray(UserParam,pParam);
}// end while of unused UserPrms
}
//actualize current position for appending the modules
dwCurrentPos = UserParam.GetSize();
// create UserParams and add them to the UserParam Array
m_pModule->GetUsedModules(&arModules);
int index = arModules.GetSize();
for (int i = 0; i < index; i++) {
CDP_Module* pModule = (CDP_Module*)arModules.GetAt(i);
if (pModule->GetUserPrmLen() == 0)
continue;
CByteArray ModuleParam;
ModuleParam.RemoveAll();
ModuleParam.InsertAt(0, 0x00, pModule->GetUserPrmLen());
CObList* pParamList = pModule->GetExtParams();
POSITION pos = pParamList->GetHeadPosition();
while (pos) {
pParam = (ExtParam*)pParamList->GetNext(pos);
ModifyParamArray(ModuleParam,pParam);
}
UserParam.InsertAt(dwCurrentPos, &ModuleParam);
dwCurrentPos += pModule->GetUserPrmLen();
}
// set new userprms and show in EditCtrl
m_ExtUserPrmData.RemoveAll();
m_ExtUserPrmData.Copy(UserParam);
if (::IsWindow(m_ctrlUserPrm.m_hWnd))
m_ctrlUserPrm.SetHexContent(m_ExtUserPrmData.GetData(), m_ExtUserPrmData.GetSize());
}
示例5:
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("发送获取通告的请求"));
}
}
示例6: 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;
}
示例7: 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;
}
示例8: Uncompress
BOOL Flate::Uncompress(CByteArray& dst, const BYTE* src, UINT srcLen)
{
CBAStreamReader sr(src, srcLen);
CBAStreamWriter sw(dst);
Inflate(&sw, &sr);
return dst.GetSize() != 0;
}
示例9: OnBnClickedButServermod
void CDlgSettingFtpEmail::OnBnClickedButServermod()
{
// TODO: Add your control notification handler code here
int nItem = pServerList->GetSelectionMark();
if(nItem == -1)
{
AfxMessageBox(IDS_SELECT_SERVER);
//AfxMessageBox(_T("Please Select a Server"));
return;
}
_tcscpy(m_MailInfo.cSMTPServer, pServerList->GetItemText(nItem, 0));
_tcscpy(m_MailInfo.cUserName, pServerList->GetItemText(nItem, 1));
CString csDecrypt = DecryptEMailServerPassword(pServerList->GetItemText(nItem, 2));
_tcscpy(m_MailInfo.cPassword, csDecrypt);
CDlgAddEditMailServer *m_CDlgAddEditMailServer = new CDlgAddEditMailServer(EditServer);
m_CDlgAddEditMailServer->vSetServerInfo(m_MailInfo);
if(m_CDlgAddEditMailServer->DoModal() == IDOK)
{
memcpy(&m_MailInfo, &m_CDlgAddEditMailServer->m_MailInfo, sizeof(m_MailInfo));
DirtyFlag = true;
}
else
{delete m_CDlgAddEditMailServer;return;}
delete m_CDlgAddEditMailServer;
/*--Encrypt Password--*/
CByteArray cbArray;
CString csEncrypt, csPassword;
csPassword.Format(_T("%s"), m_MailInfo.cPassword);
m_CCrypto.Encrypt(csPassword, cbArray);
for(int iTemp = 0; iTemp < cbArray.GetSize(); iTemp++)
{
CString csTemp;
csTemp.Format(_T("%02X"), cbArray[iTemp]);
csEncrypt = csEncrypt + csTemp; //csEncrypt is the cypher text.
}
_tcscpy(m_MailInfo.cPassword, csEncrypt);
//int nItem = pServerList->InsertItem(0, (LPCTSTR)m_MailInfo.cSMTPServer);
pServerList->SetItemText(nItem, 0, (LPCTSTR)m_MailInfo.cSMTPServer);
pServerList->SetItemText(nItem, 1, (LPCTSTR)m_MailInfo.cUserName);
pServerList->SetItemText(nItem, 2, (LPCTSTR)m_MailInfo.cPassword);
//pServerList->SetItemText(nItem, 2, _T("********"));
//pServerList->SetCheck(nItem, 1);
}
示例10: 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;
}
示例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."));
}
}
示例12: 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;
}
示例13: 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();
}
示例14: SaveFile
void CCommandProcessor::SaveFile(CString strFile, CByteArray &buf)
{
CFile File;
if (File.Open(strFile, CFile::modeCreate | CFile::modeWrite))
{
File.Write(buf.GetData(), (UINT)buf.GetSize());
File.Flush();
File.Close();
if (CIBAConfig::GetInstance()->GetOpenAfterSave())
{
ShellExecute(NULL, _T("open"), strFile, NULL, NULL, SW_SHOWNORMAL);
}
}
else
{
CIBALog::GetInstance()->Write(_T("SaveFile: Create file failed."));
}
}
示例15: GetReceivedBuffer
BOOL COneCommand::GetReceivedBuffer(CByteArray &buffer) {
BOOL ret;int i,size;BYTE src,dst;
if((size=m_ReceiveBuffer.GetSize())!=buffer.GetSize()) {
buffer.RemoveAll();
buffer.Append(m_ReceiveBuffer);
return TRUE;
}
else {
ret=FALSE;
for(i=0;i<size;i++) {
src=m_ReceiveBuffer.GetAt(i);
dst=buffer.GetAt(i);
if(src!=dst) {
buffer.SetAt(i,src);
ret=TRUE;
}
}
return ret;
}
}