本文整理汇总了C++中CComBSTR::CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C++ CComBSTR::CopyTo方法的具体用法?C++ CComBSTR::CopyTo怎么用?C++ CComBSTR::CopyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComBSTR
的用法示例。
在下文中一共展示了CComBSTR::CopyTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EncodeStrokeToXML
void CStrokeRecognition::EncodeStrokeToXML(std::vector<BasicStroke> &rgStrokes, BSTR* StrokeResult)
{
CComBSTR strokeXML;
char szTmp[1024];
strokeXML = "<?xml version=\"1.0\"?><output><strokes candidatenum=\"1\">";
sprintf(szTmp, "<candidate similarity=\"1\" strokenum=\"%d\">", rgStrokes.size());
strokeXML += szTmp;
for (unsigned int i = 0; i < rgStrokes.size(); i++)
{
switch (rgStrokes[i].iStrokeType)
{
case PRIMITIVE_SEGMENT:
{
sprintf(szTmp, "<line><startpt x=\"%d\" y=\"%d\"/><endpt x=\"%d\" y=\"%d\"/></line>",
rgStrokes[i].segment.startPoint.x, rgStrokes[i].segment.startPoint.y,
rgStrokes[i].segment.endPoint.x, rgStrokes[i].segment.endPoint.y);
strokeXML += szTmp;
}
break;
case PRIMITIVE_ARC:
{
double x1, y1, x2, y2;
double cx, cy, a, b;
cx = (rgStrokes[i].arc.rcBounding.left + rgStrokes[i].arc.rcBounding.right) / 2;
cy = (rgStrokes[i].arc.rcBounding.top + rgStrokes[i].arc.rcBounding.bottom) / 2;
a = (rgStrokes[i].arc.rcBounding.right - rgStrokes[i].arc.rcBounding.left) / 2;
b = (rgStrokes[i].arc.rcBounding.bottom - rgStrokes[i].arc.rcBounding.top) / 2;
CalcEllipsePointByAngle(cx, cy, a, b, 0, ConvertToEllipseAngle(rgStrokes[i].arc.startAngle, a, b), x1, y1);
CalcEllipsePointByAngle(cx, cy, a, b, 0, ConvertToEllipseAngle(rgStrokes[i].arc.endAngle, a, b), x2, y2);
if (rgStrokes[i].arc.endAngle - rgStrokes[i].arc.startAngle >= 1.9 * PI)
{
sprintf(szTmp, "<arc rotate=\"%f\"><startpt x=\"%d\" y=\"%d\"/><endpt x=\"%d\" y=\"%d\"/><ltpt x=\"%d\" y=\"%d\"/><rbpt x=\"%d\" y=\"%d\"/></arc>",
(float)(rgStrokes[i].arc.rotateAngle),
(int)x1, (int)y1, (int)x1, (int)y1,
rgStrokes[i].arc.rcBounding.left, rgStrokes[i].arc.rcBounding.top,
rgStrokes[i].arc.rcBounding.right, rgStrokes[i].arc.rcBounding.bottom);
}
else
{
sprintf(szTmp, "<arc rotate=\"%f\"><startpt x=\"%d\" y=\"%d\"/><endpt x=\"%d\" y=\"%d\"/><ltpt x=\"%d\" y=\"%d\"/><rbpt x=\"%d\" y=\"%d\"/></arc>",
(float)(rgStrokes[i].arc.rotateAngle),
(int)x1, (int)y1, (int)x2, (int)y2,
rgStrokes[i].arc.rcBounding.left, rgStrokes[i].arc.rcBounding.top,
rgStrokes[i].arc.rcBounding.right, rgStrokes[i].arc.rcBounding.bottom);
}
strokeXML += szTmp;
}
break;
}
}
strokeXML += "</candidate></strokes></output>";
strokeXML.CopyTo(StrokeResult);
}
示例2: CallJScript
bool CWebPage::CallJScript(const CString strFunc, const CStringArray& paramArray,CComVariant* pVarResult)
{
CComPtr<IDispatch> spScript;
if(!GetJScript(spScript))
{
ShowError(_T("Cannot GetScript"));
return false;
}
CComBSTR bstrMember(strFunc);
DISPID dispid = NULL;
HRESULT hr = spScript->GetIDsOfNames(IID_NULL,&bstrMember,1,
LOCALE_SYSTEM_DEFAULT,&dispid);
if(FAILED(hr))
{
ShowError(GetSystemErrorMessage(hr));
return false;
}
const int arraySize = paramArray.GetSize();
DISPPARAMS dispparams;
memset(&dispparams, 0, sizeof dispparams);
dispparams.cArgs = arraySize;
dispparams.rgvarg = new VARIANT[dispparams.cArgs];
for(int i = 0; i < arraySize; i++)
{
CComBSTR bstr = paramArray.GetAt(arraySize - 1 - i); // back reading
bstr.CopyTo(&dispparams.rgvarg[i].bstrVal);
dispparams.rgvarg[i].vt = VT_BSTR;
}
dispparams.cNamedArgs = 0;
EXCEPINFO excepInfo;
memset(&excepInfo, 0, sizeof excepInfo);
CComVariant vaResult;
UINT nArgErr = (UINT)-1; // initialize to invalid arg
hr = spScript->Invoke(dispid,IID_NULL,0,
DISPATCH_METHOD,&dispparams,&vaResult,&excepInfo,&nArgErr);
delete [] dispparams.rgvarg;
if(FAILED(hr))
{
ShowError(GetSystemErrorMessage(hr));
return false;
}
if(pVarResult)
{
*pVarResult = vaResult;
}
return true;
}
示例3: CallJScript
//调用JS函数
CComVariant CHTMLContainerDlg::CallJScript(const CString strFunc, const CStringArray& paramArray)
{
//Getting IDispatch for Java Script objects
CComPtr<IDispatch> spScript;
if(!GetJScript(spScript))
{
::OutputDebugString(_T("Cannot GetScript"));
return false;
}
//Find dispid for given function in the object
CComBSTR bstrMember(strFunc);
DISPID dispid = NULL;
HRESULT hr = spScript->GetIDsOfNames(IID_NULL,&bstrMember,1,
LOCALE_SYSTEM_DEFAULT,&dispid);
if(FAILED(hr)) {
return false;
}
const int arraySize = paramArray.GetSize();
//Putting parameters
DISPPARAMS dispparams;
memset(&dispparams, 0, sizeof dispparams);
dispparams.cArgs = arraySize;
dispparams.rgvarg = new VARIANT[dispparams.cArgs];
dispparams.cNamedArgs = 0;
for( int i = 0; i < arraySize; i++)
{
CComBSTR bstr = paramArray.GetAt(arraySize - 1 - i); // back reading
bstr.CopyTo(&dispparams.rgvarg[i].bstrVal);
dispparams.rgvarg[i].vt = VT_BSTR;
}
EXCEPINFO excepInfo;
memset(&excepInfo, 0, sizeof excepInfo);
CComVariant vaResult;
UINT nArgErr = (UINT)-1; // initialize to invalid arg
//Call JavaScript function
hr = spScript->Invoke(dispid,IID_NULL,0,
DISPATCH_METHOD,&dispparams,
&vaResult,&excepInfo,&nArgErr);
delete [] dispparams.rgvarg;
if(FAILED(hr)) {
return false;
}
return vaResult;
}
示例4: EncodeToXML
void CTracker::EncodeToXML(std::vector<TrackPoint> rgPoints, BSTR* TrackXML)
{
CComBSTR xml;
char szTmp[1024];
xml = "<?xml version=\"1.0\"?>";
sprintf(szTmp, "<input ptnum=\"%d\">", rgPoints.size());
xml += szTmp;
for (unsigned int i = 0; i < rgPoints.size(); i++)
{
sprintf(szTmp, "<packet x=\"%d\" y=\"%d\" t=\"%d\"/>", rgPoints[i].x, rgPoints[i].y, rgPoints[i].time);
xml += szTmp;
}
xml += "</input>";
xml.CopyTo(TrackXML);
}
示例5: get_RecognitionParam
STDMETHODIMP CStrokeRecognition::get_RecognitionParam(BSTR* pVal)
{
double Segment_Error_Threshold;
double Arc_Error_Threshold;
double Arc_Min_Length;
double Arc_Min_Curve;
double Stroke_Min_Length;
double Min_Turning_Angle;
double Segmentation_Penalty;
char szTmp[1024];
CComBSTR szParam;
GetFittingParam(Segment_Error_Threshold, Arc_Error_Threshold, Arc_Min_Length, Arc_Min_Curve, Stroke_Min_Length, Min_Turning_Angle, Segmentation_Penalty);
sprintf(szTmp, "<param Segment_Error_Threshold=\"%f\" Arc_Error_Threshold=\"%f\" Arc_Min_Length=\"%f\" Arc_Min_Curve=\"%f\" Stroke_Min_Length=\"%f\" Min_Turning_Angle=\"%f\" Segmentation_Penalty=\"%f\"/>", (float)Segment_Error_Threshold, (float)Arc_Error_Threshold, (float)Arc_Min_Length, (float)Arc_Min_Curve, (float)Stroke_Min_Length, (float)Min_Turning_Angle, (float)Segmentation_Penalty);
szParam = "<?xml version=\"1.0\"?>";
szParam += szTmp;
szParam.CopyTo(pVal);
return S_OK;
}
示例6: GetFileInfo
//.........这里部分代码省略.........
if (pBitrate) *pBitrate = pVih->dwBitRate;
}
else if (mt.formattype == FORMAT_VideoInfo2)
{
_ASSERT(FALSE); // not supported yet
}
else if (mt.formattype == FORMAT_MPEG2Video )
{
_ASSERT(FALSE); // not supported yet
}
}
FreeMediaType(mt);
}
else if (major_type == MEDIATYPE_Audio)
{
// audio stream is available
if (pAudioStreamAvailable) *pAudioStreamAvailable = TRUE;
// get audio stream length
pDet->get_StreamLength(&dAudioDuration);
AM_MEDIA_TYPE mt;
hr = pDet->get_StreamMediaType(&mt);
if (SUCCEEDED(hr) && mt.formattype == FORMAT_WaveFormatEx)
{
WAVEFORMATEX *pWav = (WAVEFORMATEX*)(mt.pbFormat);
nAudioLengthBytes = (long)(pWav->nAvgBytesPerSec * dAudioDuration);
}
}
}
// calculate the actual bitrate
if (nFileSize && pBitrate)
{
double d = max(dAudioDuration, dVideoDuration);
*pBitrate = (long)(float)((float)nFileSize / d);
*pBitrate *= 8;
/*
nVideoLengthBytes = nFileSize - nAudioLengthBytes;
long nBytesPerSecond = (long)(float)((float)nVideoLengthBytes / dVideoDuration);
if (nBytesPerSecond == 0 && nAudioLengthBytes && pBitrate)
{
if (pBitrate)
{
*pBitrate = (long)(float)((float)nFileSize / dAudioDuration);
*pBitrate *= 8;
}
}
else if (pBitrate && *pBitrate == 0)
*pBitrate = nBytesPerSecond * 8;
*/
}
// use the longer duration of the two as the duration
if (pDuration)
{
if (dAudioDuration > dVideoDuration)
*pDuration = dAudioDuration;
else
*pDuration = dVideoDuration;
}
// save poster frame if required
if (pPosterFramePath && bVideoStream == TRUE)
{
// get path in tmp dir
TCHAR szTmp[MAX_PATH];
GetTempPath(MAX_PATH, szTmp);
_tcscat(szTmp, _T("erdposter.bmp"));
// copy the file to the buffer
CComBSTR str = szTmp;
str.CopyTo(pPosterFramePath);
// make sure no such file
DeleteFile(szTmp);
// get the filename in ansi
char* pstrFile = W2A(Filename);
_strlwr(pstrFile); // make lower
// if the file has asf or wmv, in it, don't seek, else
// it will freeze. So write at pos 0, while for others
// we write at 1sec
if (videoSubType == MEDIASUBTYPE_Asf ||
strstr(pstrFile, "asf") ||
strstr(pstrFile, "wmv"))
{
pDet->WriteBitmapBits(0, 163, 112, str);
}
else
pDet->WriteBitmapBits(1, 163, 112, str);
}
return hr;
}
示例7: GetFileInfo
HRESULT CMediaFileList::GetFileInfo(BSTR Filename, double *pFramerate, double *pDuration, VARIANT_BOOL *pVideoStreamAvailable, VARIANT_BOOL *pAudioStreamAvailable, long *pWidth, long *pHeight, long *pBitrate, BSTR *pPosterFramePath)
{
if (pFramerate)
*pFramerate = 0;
if (pVideoStreamAvailable)
*pVideoStreamAvailable = VARIANT_TRUE;
if (pAudioStreamAvailable)
*pAudioStreamAvailable = VARIANT_TRUE;
if (pWidth)
*pWidth = 0;
if (pHeight)
*pHeight = 0;
if (pDuration)
*pDuration = 0;
HRESULT hr = S_OK;
CComPtr<IMediaDet> pDet;
hr = pDet.CoCreateInstance(__uuidof(MediaDet));
if (FAILED(hr))
return S_OK;
hr = pDet->put_Filename(Filename);
if (FAILED(hr))
return S_OK;
if (pVideoStreamAvailable)
*pVideoStreamAvailable = VARIANT_FALSE;
if (pAudioStreamAvailable)
*pAudioStreamAvailable = VARIANT_FALSE;
GUID videoSubtype = {0};
long iAudioStream = 0;
long lStreams;
bool bFound = false;
hr = pDet->get_OutputStreams(&lStreams);
for (long i = 0; i < lStreams; i++)
{
GUID major_type;
hr = pDet->put_CurrentStream(i);
hr = pDet->get_StreamType(&major_type);
if (major_type == MEDIATYPE_Video) // Found a video stream.
{
if (pVideoStreamAvailable)
*pVideoStreamAvailable = VARIANT_TRUE;
if (pFramerate)
pDet->get_FrameRate(pFramerate);
if (pDuration)
pDet->get_StreamLength(pDuration);
AM_MEDIA_TYPE mt;
hr = pDet->get_StreamMediaType(&mt);
VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER*)(mt.pbFormat);
videoSubtype = mt.subtype;
if (pWidth)
*pWidth = pVih->bmiHeader.biWidth;
if (pHeight)
*pHeight = pVih->bmiHeader.biHeight;
if (pBitrate)
*pBitrate = pVih->dwBitRate;
if (pHeight)
if (*pHeight < 0) *pHeight *= -1;
FreeMediaType(mt);
}
else if (major_type == MEDIATYPE_Audio)
{
iAudioStream = i;
if (pAudioStreamAvailable)
*pAudioStreamAvailable = VARIANT_TRUE;
if (lStreams == 1 || pDuration && *pDuration == 0)
if (pDuration)
pDet->get_StreamLength(pDuration);
}
}
if (pPosterFramePath)
{
char szTmp[MAX_PATH];
GetTempPath(MAX_PATH, szTmp);
strcat(szTmp, "videdit_poster.bmp");
DeleteFile(szTmp);
CComBSTR str = szTmp;
str.CopyTo(pPosterFramePath);
//.........这里部分代码省略.........