C++ A2T类(方法)实例源码

下面列出了C++ A2T 类(方法)源码代码实例,从而了解它的用法。

作者:jf421    项目:src2-tes   
void CScanMgrDlg::InitExamData()
{
	USES_CONVERSION;
	m_comboSubject.ResetContent();
	if (_pCurrExam_)
	{
		m_strExamName = A2T(_pCurrExam_->strExamName.c_str());

		if (_pCurrSub_)
		{
			int i = 0;
			int nShowSubject = -1;
			for (auto pSubject : _pCurrExam_->lSubjects)
			{
				m_comboSubject.AddString(A2T(pSubject->strSubjName.c_str()));
				int nCount = m_comboSubject.GetCount();
				m_comboSubject.SetItemDataPtr(nCount - 1, pSubject);
				if (_pCurrSub_ == pSubject)
					nShowSubject = i;
				i++;
			}
			m_comboSubject.SetCurSel(nShowSubject);
		}
	}

	UpdateChildDlgInfo();

	UpdateData(FALSE);
}

作者:Aleksei-Iagu    项目:arcobjects-sdk-community-sample   
LRESULT CLogoMarkerPropertyPage::OnVScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	USES_CONVERSION;
	HWND hThisSB = (HWND)lParam;
	
	if (LOWORD(wParam) == SB_ENDSCROLL)
		return 0; //reject spurious messages

	//get position
	int nPos = (int)::SendMessage(hThisSB, UDM_GETPOS, 0, 0L);
	char  sText[10];
	if (hThisSB == m_hSpnSize)
	{
		sprintf_s( sText, sizeof(sText), "%.2f\0", (double)nPos);
		::SetWindowText(m_hEdtSize, A2T(sText));
	}
	else if (hThisSB == m_hSpnXOffset)
	{
		sprintf_s( sText, sizeof(sText), "%+.2f\0", (double)nPos);
		::SetWindowText(m_hEdtXOffset, A2T(sText));	
	}
	else if (hThisSB == m_hSpnYOffset)
	{
		sprintf_s( sText, sizeof(sText), "%+.2f\0", (double)nPos);
		::SetWindowText(m_hEdtYOffset, A2T(sText));	
	}
/*	else if (hThisSB == m_hSpnAngle)
	{
		sprintf( sText, "%.2f\0", (double)nPos / 100);
		::SetWindowText(m_hEdtSize, sText);
	}*/
	return 0;

}

作者:Randy09080    项目:Githu   
void CPositionInquryResultMsg::ParseJSon(const char* json)
{
    USES_CONVERSION;

    Json::Reader reader;
    Json::Value root;

    if (reader.parse(json, root))
    {
        Error = root["errcode"].asInt();
        ErrMsg = A2T(root["errmsg"].asString().c_str());

        Json::Value data = root["data"];
        BP = data["bp"].asDouble();
        InitBp = data["init_bp"].asDouble();
        ColosPl = data["close_pl"].asDouble();
        TradeFee = data["trade_fee"].asDouble();

        Json::Value hold = data["hold"];
        for (UINT i = 0; i < hold.size(); i++)
        {
            Json::Value &current = hold[i];
            CPositionData *SPositionData = new CPositionData;
            PositionDatas.push_back(SPositionData);

            SPositionData->StockID = A2T(current["stock_id"].asString().c_str());
            SPositionData->Volume = current["volume"].asInt();
            SPositionData->Amount = current["amount"].asDouble();
            SPositionData->ArgPrice = current["avg_price"].asDouble();
        }
    }
}

作者:Conti-Meissne    项目:busmaste   
/**
* \brief         connects to the channels and initiates read thread.
* \param         void
* \return        S_OK for success, S_FALSE for failure
*/
HRESULT CDIL_CAN_MHS::CAN_StartHardware(void)
{
USES_CONVERSION;
HRESULT hResult;
char str[100];

//VALIDATE_VALUE_RETURN_VAL(sg_bCurrState, STATE_HW_INTERFACE_SELECTED, ERR_IMPROPER_STATE);
if (!str_has_char(sg_MhsCanCfg.CanSnrStr))
  sprintf(str, "Snr=%s", sg_MhsCanCfg.CanSnrStr);
else
  str[0]='\0';
if (!CanDeviceOpen(0, str))
  {
  (void)CanSetOptions("CanTxAckEnable=1");
  // **** CAN Bus Start
  if (CanSetMode(0, OP_CAN_START, CAN_CMD_FIFOS_ERROR_CLEAR) >= 0)
    hResult = S_OK;
  else
    {
    hResult = S_FALSE;
    sg_pIlog->vLogAMessage(A2T(__FILE__), __LINE__, _T("could not start the controller in running mode"));
    }
  sg_bCurrState = STATE_CONNECTED;
  }
else
  {
  //log the error for open port failure
  sg_pIlog->vLogAMessage(A2T(__FILE__), __LINE__, _T("error opening \"Tiny-CAN\" interface"));
  hResult = ERR_LOAD_HW_INTERFACE;
  }
return(hResult);
}

作者:jf421    项目:src2-tes   
void CExamInfoMgrDlg::InitSearchData()
{
	std::vector<std::string> vecSub;
	vecSub.push_back("全部");
	std::vector<std::string> vecGrade;
	vecGrade.push_back("全部");

	//获取列表中所有科目名称信息、年级信息
	int nAllExamItems = 0;
	for (auto examObj : g_lExamList)
	{
		pEXAMINFO pExam = examObj;
		for (auto subObj : examObj->lSubjects)
		{
			pEXAM_SUBJECT pSub = subObj;
			bool bFind = false;
			for (auto strSubName : vecSub)
			{
				if (pSub->strSubjName == strSubName)
				{
					bFind = true;
					break;
				}
			}
			if (!bFind && pSub->strSubjName != "")
				vecSub.push_back(pSub->strSubjName);
		}

		bool bFindGrade = false;
		for (auto strGrade : vecGrade)
		{
			if (pExam->strGradeName == strGrade)
			{
				bFindGrade = true;
				break;
			}
		}
		if (!bFindGrade && pExam->strGradeName != "")
			vecGrade.push_back(pExam->strGradeName);

		nAllExamItems = pExam->lSubjects.size();
	}
	m_nAllExamListItems = nAllExamItems;

	m_comboSubject.ResetContent();
	m_comboGrade.ResetContent();

	USES_CONVERSION;
	for (auto strSubName : vecSub)
		m_comboSubject.AddString(A2T(strSubName.c_str()));
	for (auto strGrade : vecGrade)
		m_comboGrade.AddString(A2T(strGrade.c_str()));

	m_comboSubject.AdjustDroppedWidth();
	m_comboGrade.AdjustDroppedWidth();

	m_comboSubject.SetCurSel(0);
	m_comboGrade.SetCurSel(0);
}

作者:PPNa    项目:GPST   
int Matrix_T::transposeTest(void)
{
	TestUtil testFramework("Matrix", "Transpose", __FILE__, __LINE__);

	gpstk::Matrix<double> A1T(2,2),A2T(3,3),A3T(4,4),A4T(4,5);
	gpstk::Matrix<double> CompareA1T(2,2),CompareA2T(3,3),CompareA3T(4,4),CompareA4T(5,4);
	A1T = gpstk::transpose(A1);
	A2T = gpstk::transpose(A2);
	A3T = gpstk::transpose(A3);
	A4T = gpstk::transpose(A4);

	double temp4[4] = {2,-3,5,-7};
	double temp5[9] = {1,3,-5,0,1,-1,-2,-2,9};
	double temp6[16] = {2,1,0,0,3,0,2,2,1,3,-3,3,5,1,2,1};
	double temp7[20] = {8,7,1,-78,5,-9,7,24,18,5,10,20,-2,0,11,-68,1.5,7,47,0};		

	CompareA1T = temp4;
	CompareA2T = temp5;
	CompareA3T = temp6;
	CompareA4T = temp7;

	int badCount = 0;

	//testFramework.assert(AT == CompareAT, testMesg, __LINE__);
	for(int i = 0; i < A1T.rows(); i++)
		for(int j = 0; j < A1T.cols(); j++)
     			if (A1T(i,j) != CompareA1T(i,j)) {badCount++;}
	failDescriptionStream << "Check if gpstk::transpose(A1) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A2T.rows(); i++)
		for(int j = 0; j < A2T.cols(); j++)
     			if (A2T(i,j) != CompareA2T(i,j)) {badCount++;}
	failDescriptionStream << "Check if gpstk::transpose(A2) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A3T.rows(); i++)
		for(int j = 0; j < A3T.cols(); j++)
     			if (A3T(i,j) != CompareA3T(i,j)) {badCount++;}
	failDescriptionStream << "Check if gpstk::transpose(A3) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A4T.rows(); i++)
		for(int j = 0; j < A4T.cols(); j++)
     			if (A4T(i,j) != CompareA4T(i,j)) {badCount++;}
	failDescriptionStream << "Check if gpstk::transpose(A4) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter      	

  	return testFramework.countFails();
  }

作者:Aleksei-Iagu    项目:arcobjects-sdk-community-sample   
/////////////////////////////////////////////////////////////////////////////
// IPropertyPage
STDMETHODIMP CLogoMarkerPropertyPage::Show(UINT nCmdShow)
{
	USES_CONVERSION;

	// If we are showing the property page propulate it
	// from the Marker symbol object.
	if ((nCmdShow & (SW_SHOW|SW_SHOWDEFAULT)))
	{
		//colors
		IColorPtr ipColor;
		m_ipLogoMarker->get_ColorTop(&ipColor);
		ipColor->get_RGB(&m_colTop);
		::SendMessage(m_hRchTop, EM_SETBKGNDCOLOR, 0, 
															(LPARAM) m_colTop);

		m_ipLogoMarker->get_ColorRight(&ipColor);
		ipColor->get_RGB(&m_colRight);
		::SendMessage(m_hRchRight, EM_SETBKGNDCOLOR, 0, 
															(LPARAM) m_colRight);
	
		m_ipLogoMarker->get_ColorLeft(&ipColor);
		ipColor->get_RGB(&m_colLeft);
		::SendMessage(m_hRchLeft, EM_SETBKGNDCOLOR, 0, 
															(LPARAM) m_colLeft);
		
		m_ipLogoMarker->get_ColorBorder(&ipColor);
		ipColor->get_RGB(&m_colBorder);
		::SendMessage(m_hRchBorder, EM_SETBKGNDCOLOR, 0, 
															(LPARAM) m_colBorder);
		
		//angle, size and offsets
		char  sText[10];
		double dText;
		IMarkerSymbolPtr ipMSymbol(m_ipLogoMarker);
		ipMSymbol->get_Size(&dText);
		sprintf_s( sText, sizeof(sText), "%.2f\0", dText);
		::SendMessage(m_hSpnSize, UDM_SETPOS, 0, MAKELPARAM((int)(dText), 0));
		::SetWindowText(m_hEdtSize, A2T(sText));
		ipMSymbol->get_Angle(&dText);
		sprintf_s( sText, sizeof(sText), "%d\0", (int)dText);
		::SendMessage(m_hSpnAngle, UDM_SETPOS, 0, MAKELPARAM((int)(dText), 0));
		::SetWindowText(m_hEdtAngle, A2T(sText));
		ipMSymbol->get_XOffset(&dText);
		sprintf_s( sText, sizeof(sText), "%+.2f\0", dText);
		::SendMessage(m_hSpnXOffset, UDM_SETPOS, 0, MAKELPARAM((int)(dText), 0));
		::SetWindowText(m_hEdtXOffset, A2T(sText));
		ipMSymbol->get_YOffset(&dText);
		sprintf_s( sText, sizeof(sText), "%+.2f\0", dText);
		::SendMessage(m_hSpnYOffset, UDM_SETPOS, 0, MAKELPARAM((int)(dText), 0));
		::SetWindowText(m_hEdtYOffset, A2T(sText));

		m_bShown = true;
	}

	// Let the IPropertyPageImpl deal with displaying the page
	return IPropertyPageImpl<CLogoMarkerPropertyPage>::Show(nCmdShow);
}

作者:MarkYangU    项目:HP-Socke   
void PostOnHeader(CONNID dwConnID, LPCSTR lpszHeaderName, LPCSTR lpszHeaderValue, LPCTSTR lpszName)
{
	USES_CONVERSION;

	int content_len		= (int)(strlen(lpszHeaderName) + strlen(lpszHeaderValue) + 10);
	LPTSTR lpszContent	= new TCHAR[content_len];

	wsprintf(lpszContent, _T("%s: %s"), A2T(lpszHeaderName), A2T(lpszHeaderValue));
	info_msg* msg = info_msg::Construct(dwConnID, EVT_ON_HEADER, content_len, lpszContent, lpszName);

	PostInfoMsg(msg);
}

作者:MarkYangU    项目:HP-Socke   
void PostOnRequestLine(CONNID dwConnID, LPCSTR lpszMethod, USHORT usUrlFieldSet, LPCSTR lpszUrl, LPCTSTR lpszName)
{
	USES_CONVERSION;

	int content_len		= (int)(strlen(lpszMethod) + strlen(lpszUrl) + 20);
	LPTSTR lpszContent	= new TCHAR[content_len];

	wsprintf(lpszContent, _T("[%s/0x%02X] : %s"), A2T(lpszMethod), usUrlFieldSet, A2T(lpszUrl));
	info_msg* msg = info_msg::Construct(dwConnID, EVT_ON_REQUEST_LINE, content_len, lpszContent, lpszName);

	PostInfoMsg(msg);
}

作者:jf421    项目:src2-tes   
bool CZipObj::ZipFile(CString strSrcPath, CString strDstPath, CString strExtName /*= _T(".zip")*/)
{
	USES_CONVERSION;
	//	CString modelName = strSrcPath.Right(strSrcPath.GetLength() - strSrcPath.ReverseFind('\\') - 1);
	CString zipName = strDstPath + strExtName;
	std::string strUtf8ZipName = CMyCodeConvert::Gb2312ToUtf8(T2A(zipName));

	try
	{
		Poco::File p(strUtf8ZipName);	//T2A(zipName)
		if (p.exists())
			p.remove(true);
	}
	catch (Poco::Exception)
	{
	}

	//	std::string strModelPath = T2A(strSrcPath);
	std::string strUtf8ModelPath = CMyCodeConvert::Gb2312ToUtf8(T2A(strSrcPath));
	try
	{
		Poco::File p2(strUtf8ModelPath);	//T2A(zipName)
		if (!p2.exists())
		{
			std::string strErr = Poco::format("需要压缩的原文件夹(%s)不存在。", T2A(strSrcPath));
			RecordLog(strErr);
			return false;
		}
	}
	catch (Poco::Exception)
	{
	}

	HZIP hz = CreateZip(zipName, _strPwd.c_str());

	Poco::DirectoryIterator it(strUtf8ModelPath);	//strModelPath
	Poco::DirectoryIterator end;
	while (it != end)
	{
		Poco::Path p(it->path());
		//		std::string strZipFileName = p.getFileName();
		std::string strPath = CMyCodeConvert::Utf8ToGb2312(p.toString());
		std::string strZipFileName = CMyCodeConvert::Utf8ToGb2312(p.getFileName());
		CString strZipPath = A2T(strPath.c_str());
		CString strName = A2T(strZipFileName.c_str());
		//		ZipAdd(hz, A2T(strZipFileName.c_str()), A2T(p.toString().c_str()));
		ZipAdd(hz, strName, strZipPath);
		it++;
	}
	CloseZip(hz);

	return true;
}

作者:haowaiwa    项目:tes   
void main()
{
  USES_CONVERSION;

	if (__argc != 2)
	{
		printf("Usage: CPing HostName | IPAddress\n");
		return;
	}

#ifdef CPING_USE_ICMP
{
	CPing p1;
	CPingReply pr1;
	if (p1.Ping1(A2T(__argv[1]), pr1))
	{
		hostent* phostent = gethostbyaddr((char *)&pr1.Address.S_un.S_addr, 4, PF_INET);
		printf("%d.%d.%d.%d [%s], replied in RTT:%dms\n", 
					 pr1.Address.S_un.S_un_b.s_b1, pr1.Address.S_un.S_un_b.s_b2, pr1.Address.S_un.S_un_b.s_b3, 
					 pr1.Address.S_un.S_un_b.s_b4, phostent->h_name, pr1.RTT);
	}
	else
	  printf("Failed in call to ping, GetLastError returns: %d", GetLastError());
}
#endif

#ifdef CPING_USE_WINSOCK2
{
	for(int i=0;i<4;i++)
	{
		CPing p2;
		CPingReply pr2;
		if (p2.Ping2(A2T(__argv[1]), pr2))
		{
			hostent* phostent = gethostbyaddr((char *)&pr2.Address.S_un.S_addr, 4, PF_INET);
			if(phostent == NULL)
				printf("%d.%d.%d.%d, replied in RTT:%dms\n", 
				pr2.Address.S_un.S_un_b.s_b1, pr2.Address.S_un.S_un_b.s_b2, pr2.Address.S_un.S_un_b.s_b3, 
				pr2.Address.S_un.S_un_b.s_b4, pr2.RTT);
			else
				printf("%d.%d.%d.%d [%s], replied in RTT:%dms\n", 
				pr2.Address.S_un.S_un_b.s_b1, pr2.Address.S_un.S_un_b.s_b2, pr2.Address.S_un.S_un_b.s_b3, 
				pr2.Address.S_un.S_un_b.s_b4, phostent->h_name, pr2.RTT);
		}
		else
			printf("Failed in call to ping, GetLastError returns: %d", GetLastError());
	}
	}	
#endif
}

作者:matrix20    项目:V   
void CIPFindDlg::GetCurSelIPMask(char *ip, char *mask)
{
	USES_CONVERSION;

	CString strMsg = MSG_CUR_ADAPTER;
	strMsg += "IP:";
	strMsg += A2T(ip);
	strMsg += " Mask:";
	strMsg += A2T(mask);

	SetDlgItemText(IDC_STATIC_ADAPTER_MSG, strMsg);

	m_strFindIP = ip;
	m_strFindMask = mask;
}

作者:BackupTheBerlio    项目:nextem   
void CPPgProxy::LoadSettings()
{
	USES_CONVERSION;
	CheckDlgButton(IDC_ASCWOP,(thePrefs.IsProxyASCWOP() ));
	((CButton*)GetDlgItem(IDC_ENABLEPROXY))->SetCheck(proxy.UseProxy);
	((CButton*)GetDlgItem(IDC_ENABLEAUTH))->SetCheck(proxy.EnablePassword);
	((CComboBox*)GetDlgItem(IDC_PROXYTYPE))->SetCurSel(proxy.type);
	GetDlgItem(IDC_PROXYNAME)->SetWindowText(proxy.name);
	CString buffer;
	buffer.Format(_T("%ld"),proxy.port);
	GetDlgItem(IDC_PROXYPORT)->SetWindowText(buffer);
	GetDlgItem(IDC_USERNAME_A)->SetWindowText(A2T(proxy.user));
	GetDlgItem(IDC_PASSWORD)->SetWindowText(A2T(proxy.password));
	OnBnClickedEnableproxy();
}

作者:jf421    项目:src2-tes   
void CLostCornerDlg::InitData()
{
	if (!m_pPapers) return;

	m_lcLostCornerPaper.DeleteAllItems();
	m_lcLostCornerPaper.DeleteAllItems();

	USES_CONVERSION;
	for (auto pPaper : m_pPapers->lPaper)
	{
		bool bInsert = false;
		for (auto pPic : pPaper->lPic)
		{
			if (pPic->lLostCorner.size())
			{
				if (!bInsert)
				{
					bInsert = true;
					//添加进试卷列表控件
					int nCount = m_lcLostCornerPaper.GetItemCount();
					char szCount[10] = { 0 };
					sprintf_s(szCount, "%d", pPaper->nIndex);	//nCount + 1
					m_lcLostCornerPaper.InsertItem(nCount, NULL);
					m_lcLostCornerPaper.SetItemText(nCount, 0, (LPCTSTR)A2T(szCount));
					m_lcLostCornerPaper.SetItemText(nCount, 1, (LPCTSTR)A2T(pPaper->strSN.c_str()));
					//显示备注信息,为何出现在此列表
					std::string strDetailInfo;
					strDetailInfo = Poco::format("折角%d个", (int)pPic->lLostCorner.size());
					m_lcLostCornerPaper.SetItemText(nCount, 2, (LPCTSTR)A2T(strDetailInfo.c_str()));
					m_lcLostCornerPaper.SetItemData(nCount, (DWORD_PTR)pPaper);

					CString strTips = _T("双击显示此试卷信息");
					m_lcLostCornerPaper.SetItemToolTipText(nCount, 0, (LPCTSTR)strTips);
					m_lcLostCornerPaper.SetItemToolTipText(nCount, 1, (LPCTSTR)strTips);
					m_lcLostCornerPaper.SetItemToolTipText(nCount, 2, (LPCTSTR)strTips);
				}
			}
		}		
	}
	if (m_lcLostCornerPaper.GetItemCount() > 0)
	{
		m_nCurrentPaperID = 0;
		m_lcLostCornerPaper.GetItemColors(m_nCurrentPaperID, 0, crPaperOldText, crPaperOldBackground);

		pST_PaperInfo pPaper = (pST_PaperInfo)m_lcLostCornerPaper.GetItemData(m_nCurrentPaperID);
		ShowPaperDetail(pPaper);
	}
}

作者:okiga    项目:dbli   
BOOL CSqlite3Recordset::GetField(short iIndex, LPTSTR pData, UINT cchMax)
{
   _ASSERTE(IsOpen());
   _ASSERTE(iIndex>=0 && iIndex<m_nCols);
   if( IsEOF() ) return FALSE;
   if( iIndex < 0 || iIndex >= m_nCols ) return FALSE;
   if( m_lType == DB_OPEN_TYPE_FORWARD_ONLY ) {
#if !defined(UNICODE)
      USES_CONVERSION;
      _tcsncpy(pData, A2T( (char*)::sqlite3_column_text(m_pVm, iIndex) ), cchMax);
#else  // UNICODE
      _tcsncpy(pData, (WCHAR*) ::sqlite3_column_text16(m_pVm, iIndex), cchMax);
#endif // UNICODE
   }
   else {
      LPSTR pstr = m_ppSnapshot[ ((m_iPos + 1) * m_nCols) + iIndex ];
      if( pstr == NULL ) {
         _tcscpy(pData, _T(""));
      }
      else {
         USES_CONVERSION;
         LPCSTR pstr = m_ppSnapshot[ ((m_iPos + 1) * m_nCols) + iIndex ];
         _tcsncpy(pData, A2CT(pstr), cchMax);
      }
   }
   return TRUE;
}

作者:gawadep    项目:kh323phon   
int  _access(const char *sName, int mode)
{
	USES_CONVERSION;
	WIN32_FIND_DATA FindFileData;

        PString test(sName);
        if (test[test.GetLength() - 1] == '.' && test[test.GetLength() - 2] == PDIR_SEPARATOR)
            test.Delete(test.GetLength() - 2, 2);

        HANDLE file = FindFirstFile(A2T((const char*) test), &FindFileData);
	if (file == INVALID_HANDLE_VALUE ) return -1;
	FindClose(file);
	switch(mode)
	{
		//checking for the existance
		case 0: return 0;
		//checking for read permission
		case 4: return 0;
		//checking for write permission
		case 2: return (FindFileData.dwFileAttributes&FILE_ATTRIBUTE_READONLY) ? -1 : 0;
		//checking for read and write permission
		case 6: return (FindFileData.dwFileAttributes&FILE_ATTRIBUTE_READONLY) ? -1 : 0;
	}
	return -1;
}

作者:broftk    项目:mess-cv   
static int wince_mess_vprintf(char *fmt, va_list arg)
{
	int length;
	int old_length;
	LPTSTR new_messages;
	LPCTSTR tbuffer;
	char buffer[256];

	/* get into a buffer */
	length = vsnprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), fmt, arg);
	tbuffer = A2T(buffer);

	/* output to debugger */
	OutputDebugString(tbuffer);

	/* append the buffer to the rest of the messages */
	old_length = messages ? tcslen(messages) : 0;
	new_messages = realloc(messages, (old_length + tcslen(tbuffer) + 1) * sizeof(TCHAR));
	if (new_messages)
	{
		messages = new_messages;
		tcscpy(messages + old_length, tbuffer);
	}
	return length;
}

作者:do    项目:CrashRp   
int CUtility::GenerateGUID(CString& sGUID)
{
  int status = 1;
  sGUID.Empty();

  USES_CONVERSION;

  // Create GUID

  UCHAR *pszUuid = 0; 
  GUID *pguid = NULL;
  pguid = new GUID;
  if(pguid!=NULL)
  {
    HRESULT hr = CoCreateGuid(pguid);
    if(SUCCEEDED(hr))
    {
      // Convert the GUID to a string
      hr = UuidToStringA(pguid, &pszUuid);
      if(SUCCEEDED(hr) && pszUuid!=NULL)
      { 
        status = 0;
        sGUID = A2T((char*)pszUuid);
        RpcStringFreeA(&pszUuid);
      }
    }
    delete pguid; 
  }

  return status;
}

作者:Synapsewar    项目:coc   
BOOL win_association_exists(const struct win_association_info *assoc)
{
	BOOL rc = FALSE;
	TCHAR buf[1024];
	TCHAR expected[1024];
	HKEY key1 = NULL;
	HKEY key2 = NULL;

	// first check to see if the extension is there at all
	if (RegOpenKey(HKEY_CLASSES_ROOT, A2T(assoc->file_class), &key1))
		goto done;

	if (RegOpenKey(key1, TEXT("shell\\open\\command"), &key2))
		goto done;

	if (reg_query_string(key2, buf, sizeof(buf) / sizeof(buf[0])))
		goto done;

	get_open_command(assoc, expected, sizeof(expected) / sizeof(expected[0]));
	rc = !_tcscmp(expected, buf);

done:
	if (key2)
		RegCloseKey(key2);
	if (key1)
		RegCloseKey(key1);
	return rc;
}

作者:open2cer    项目:Open2C-ER   
BOOL CCrystalEditView::DoDropText(COleDataObject *pDataObject, const CPoint &ptClient)
{
	HGLOBAL hData = pDataObject->GetGlobalData(CF_TEXT);
	if (hData == NULL)
		return FALSE;

	CPoint ptDropPos = ClientToText(ptClient);
	if (IsDraggingText() && IsInsideSelection(ptDropPos))
	{
		SetAnchor(ptDropPos);
		SetSelection(ptDropPos, ptDropPos);
		SetCursorPos(ptDropPos);
		EnsureVisible(ptDropPos);
		return FALSE;
	}

	LPSTR pszText = (LPSTR) ::GlobalLock(hData);
	if (pszText == NULL)
		return FALSE;

	int x, y;
	USES_CONVERSION;
	m_pTextBuffer->InsertText(this, ptDropPos.y, ptDropPos.x, A2T(pszText), y, x, CE_ACTION_DRAGDROP); //	[JRT]
	CPoint ptCurPos(x, y);
	ASSERT_VALIDTEXTPOS(ptCurPos);
	SetAnchor(ptDropPos);
	SetSelection(ptDropPos, ptCurPos);
	SetCursorPos(ptCurPos);
	EnsureVisible(ptCurPos);

	::GlobalUnlock(hData);
	return TRUE;
}


问题


面经


文章

微信
公众号

扫码关注公众号