本文整理汇总了C++中CAtlStringW::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ CAtlStringW::GetLength方法的具体用法?C++ CAtlStringW::GetLength怎么用?C++ CAtlStringW::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAtlStringW
的用法示例。
在下文中一共展示了CAtlStringW::GetLength方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strUrlW
CNetRequestImpl::CNetRequestImpl(const char* method, const String& strUrl)
{
pszErrFunction = NULL;
hInet = NULL, hConnection = NULL, hRequest = NULL;
memset(&uri, 0, sizeof(uri) );
m_pInstance = this;
CAtlStringW strUrlW(strUrl.c_str());
do
{
if ( !isLocalHost(strUrl.c_str()) && !SetupInternetConnection(strUrlW) )
{
pszErrFunction = L"SetupInternetConnection";
break;
}
hInet = InternetOpen(_T("rhodes-wm"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
if ( !hInet )
{
pszErrFunction = L"InternetOpen";
break;
}
DWORD dwUrlLength = 1024;
CAtlStringW strCanonicalUrlW;
if ( !InternetCanonicalizeUrl( strUrlW, strCanonicalUrlW.GetBuffer(dwUrlLength), &dwUrlLength, 0) )
{
pszErrFunction = _T("InternetCanonicalizeUrl");
break;
}
strCanonicalUrlW.ReleaseBuffer();
alloc_url_components( &uri, strCanonicalUrlW );
if( !InternetCrackUrl( strCanonicalUrlW, strCanonicalUrlW.GetLength(), 0, &uri ) )
{
pszErrFunction = L"InternetCrackUrl";
break;
}
hConnection = InternetConnect( hInet, uri.lpszHostName, uri.nPort, _T("anonymous"), NULL,
INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
pszErrFunction = L"InternetConnect";
break;
}
strReqUrlW = uri.lpszUrlPath;
strReqUrlW += uri.lpszExtraInfo;
hRequest = HttpOpenRequest( hConnection, CAtlStringW(method), strReqUrlW, NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE, NULL );
if ( !hRequest )
{
pszErrFunction = L"HttpOpenRequest";
break;
}
}while(0);
}
示例2: GetImageType
DWORD IGFrame::GetImageType (LPCWSTR lpPicturePath)
{
CAtlStringW cstrExtension (lpPicturePath);
if (cstrExtension.GetLength() < 5)
return CXIMAGE_FORMAT_UNKNOWN;
cstrExtension = cstrExtension.Right (4);
// supported file extenstion length may be 2, 3 or 4
if (cstrExtension.GetAt (0) == L'.')
cstrExtension = cstrExtension.Right (3);
else if (cstrExtension.GetAt (1) == L'.')
cstrExtension = cstrExtension.Right (2);
cstrExtension.MakeUpper();
if (cstrExtension == L"BMP")
return CXIMAGE_FORMAT_BMP;
else if (cstrExtension == L"JPG")
return CXIMAGE_FORMAT_JPG;
else if (cstrExtension == L"PNG")
return CXIMAGE_FORMAT_PNG;
else if (cstrExtension == L"ICO")
return CXIMAGE_FORMAT_ICO;
else if (cstrExtension == L"GIF")
return CXIMAGE_FORMAT_GIF;
else if (cstrExtension == L"TIF")
return CXIMAGE_FORMAT_TIF;
else if (cstrExtension == L"IG")
return CXIMAGE_FORMAT_IG;
return CXIMAGE_FORMAT_UNKNOWN;
}
示例3: DisplayStringProperty
// Displays a property assumed to be in string form.
void DisplayStringProperty(
IPortableDeviceValues* pProperties,
REFPROPERTYKEY key,
PCWSTR pszKey)
{
PWSTR pszValue = NULL;
HRESULT hr = pProperties->GetStringValue(key,&pszValue);
if (SUCCEEDED(hr))
{
// Get the length of the string value so we
// can output <empty string value> if one
// is encountered.
CAtlStringW strValue;
strValue = pszValue;
if (strValue.GetLength() > 0)
{
printf("%ws: %ws\n",pszKey, pszValue);
}
else
{
printf("%ws: <empty string value>\n", pszKey);
}
}
else
{
printf("%ws: <Not Found>\n", pszKey);
}
// Free the allocated string returned from the
// GetStringValue method
CoTaskMemFree(pszValue);
pszValue = NULL;
}
示例4: ErrorMessage
void CNetRequestImpl::ErrorMessage(LPCTSTR pszFunction)
{
// Retrieve the system error message for the last-error code
LPTSTR pszMessage = NULL;
DWORD dwLastError = GetLastError();
DWORD dwLen = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
//FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_FROM_HMODULE|
FORMAT_MESSAGE_IGNORE_INSERTS,
GetModuleHandle( _T("wininet.dll") ),
dwLastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&pszMessage,
0, NULL );
CAtlStringW strExtError;
if ( dwLastError == ERROR_INTERNET_EXTENDED_ERROR )
{
DWORD dwInetError =0, dwExtLength = 0;
InternetGetLastResponseInfo( &dwInetError, NULL, &dwExtLength );
if ( dwExtLength > 0 )
{
InternetGetLastResponseInfo( &dwInetError, strExtError.GetBuffer(dwExtLength+1), &dwExtLength );
strExtError.ReleaseBuffer();
}
}
rho::LogMessage oLogMsg(__FILE__, __LINE__, L_ERROR, LOGCONF(), getLogCategory() );
oLogMsg + "Call " + pszFunction + " failed. With code : " + dwLastError;
if ( pszMessage )
oLogMsg + ".Message: " + pszMessage;
if ( strExtError.GetLength() )
oLogMsg + ".Extended info: " + strExtError.GetString();
if ( pszMessage )
LocalFree(pszMessage);
}
示例5: Draw
void CVisualNode::Draw(CVisualDrawContext & Ctx)
{
RECT rect;
size_t n;
Ctx.SelectSmallFont();
if(IsSelected())
{
Ctx.SelectPen(m_clrSelectedBorder, 2);
}
else
{
Ctx.SelectPen(m_clrLine, 1);
}
// select colors
Ctx.SelectSolidBrush(m_clrFill);
// draw rect
Ctx.MapRect(m_Rect, rect);
Rectangle(Ctx.DC(), rect.left, rect.top, rect.right, rect.bottom);
if(!m_strLabel.IsEmpty())
{
COLORREF oldColor = SetTextColor(Ctx.DC(), m_clrLine);
Ctx.SelectSolidBrush(RGB(0, 0, 0));
SetBkColor(Ctx.DC(), m_clrFill);
rect.left += 5;
rect.right -= 5;
rect.top +=5;
DrawText(Ctx.DC(), m_strLabel, m_strLabel.GetLength(), &rect, DT_WORDBREAK);
SetTextColor(Ctx.DC(), oldColor);
}
if(m_fTopoError)
{
COLORREF oldColor = SetTextColor(Ctx.DC(), m_clrErrorText);
rect.top += 10;
CAtlStringW errString = LoadAtlString(IDS_E_TOPO_RESOLUTION);
DrawText(Ctx.DC(), errString, errString.GetLength(), &rect, DT_WORDBREAK);
SetTextColor(Ctx.DC(), oldColor);
}
Ctx.PushState();
Ctx.ShiftCoordinates(m_Rect.x(), m_Rect.y());
// draw pins
for(n = 0; n < m_InputPins.GetCount(); n++)
{
m_InputPins.GetAt(n)->Draw(Ctx);
}
for(n = 0; n < m_OutputPins.GetCount(); n++)
{
m_OutputPins.GetAt(n)->Draw(Ctx);
}
Ctx.PopState();
Ctx.DeselectSmallFont();
}
示例6: RegisterForEventNotifications
void RegisterForEventNotifications(IPortableDevice* pDevice)
{
HRESULT hr = S_OK;
PWSTR pszEventCookie = NULL;
CPortableDeviceEventsCallback* pCallback = NULL;
if (pDevice == NULL)
{
return;
}
// Check to see if we already have an event registration cookie. If so,
// then avoid registering again.
// NOTE: An application can register for events as many times as they want.
// This sample only keeps a single registration cookie around for
// simplicity.
if (g_strEventRegistrationCookie.GetLength() > 0)
{
printf("This application has already registered to receive device events.\n");
return;
}
// Create an instance of the callback object. This will be called when events
// are received.
if (hr == S_OK)
{
pCallback = new (std::nothrow) CPortableDeviceEventsCallback();
if (pCallback == NULL)
{
hr = E_OUTOFMEMORY;
printf("Failed to allocate memory for IPortableDeviceEventsCallback object, hr = 0x%lx\n",hr);
}
}
// Call Advise to register the callback and receive events.
if (hr == S_OK)
{
hr = pDevice->Advise(0, pCallback, NULL, &pszEventCookie);
if (FAILED(hr))
{
printf("! Failed to register for device events, hr = 0x%lx\n",hr);
}
}
// Save the event registration cookie if event registration was successful.
if (hr == S_OK)
{
g_strEventRegistrationCookie = pszEventCookie;
}
// Free the event registration cookie, if one was returned.
if (pszEventCookie != NULL)
{
CoTaskMemFree(pszEventCookie);
pszEventCookie = NULL;
}
if (hr == S_OK)
{
printf("This application has registered for device event notifications and was returned the registration cookie '%ws'", g_strEventRegistrationCookie.GetString());
}
// If a failure occurs, remember to delete the allocated callback object, if one exists.
if (pCallback != NULL)
{
pCallback->Release();
}
}
示例7: strUrlW
CNetRequestImpl::CNetRequestImpl(CNetRequest* pParent, const char* method, const String& strUrl, IRhoSession* oSession, Hashtable<String,String>* pHeaders)
{
m_pParent = pParent;
m_pParent->m_pCurNetRequestImpl = this;
m_pHeaders = pHeaders;
m_bCancel = false;
m_pSession = oSession;
pszErrFunction = NULL;
hInet = NULL, hConnection = NULL, hRequest = NULL;
memset(&uri, 0, sizeof(uri) );
m_strUrl = strUrl;
CAtlStringW strUrlW(strUrl.c_str());
LOG(INFO) + "Method: " + method + ";Url: " + strUrl;
do
{
if ( !URI::isLocalHost(strUrl.c_str()) && !SetupInternetConnection(strUrlW) )
{
pszErrFunction = L"SetupInternetConnection";
break;
}
hInet = InternetOpen(_T("rhodes-wm"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
if ( !hInet )
{
pszErrFunction = L"InternetOpen";
break;
}
DWORD dwUrlLength = 1024;
CAtlStringW strCanonicalUrlW;
if ( !InternetCanonicalizeUrl( strUrlW, strCanonicalUrlW.GetBuffer(dwUrlLength), &dwUrlLength, 0) )
{
pszErrFunction = _T("InternetCanonicalizeUrl");
break;
}
strCanonicalUrlW.ReleaseBuffer();
alloc_url_components( &uri, strCanonicalUrlW );
if( !InternetCrackUrl( strCanonicalUrlW, strCanonicalUrlW.GetLength(), 0, &uri ) )
{
pszErrFunction = L"InternetCrackUrl";
break;
}
hConnection = InternetConnect( hInet, uri.lpszHostName, uri.nPort, _T("anonymous"), NULL,
INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
pszErrFunction = L"InternetConnect";
break;
}
strReqUrlW = uri.lpszUrlPath;
strReqUrlW += uri.lpszExtraInfo;
DWORD dwFlags = INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_NO_COOKIES;
if ( uri.lpszScheme && wcsicmp(uri.lpszScheme,L"https")==0)
dwFlags |= INTERNET_FLAG_SECURE;
hRequest = HttpOpenRequest( hConnection, CAtlStringW(method), strReqUrlW, NULL, NULL, NULL, dwFlags, NULL );
if ( !hRequest )
{
pszErrFunction = L"HttpOpenRequest";
break;
}
if (oSession!=null)
{
String strSession = oSession->getSession();
LOG(INFO) + "Cookie : " + strSession;
if ( strSession.length() > 0 )
{
String strHeader = "Cookie: " + strSession + "\r\n";
if ( !HttpAddRequestHeaders( hRequest, common::convertToStringW(strHeader).c_str(), -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
pszErrFunction = L"HttpAddRequestHeaders";
}
}
}while(0);
}