本文整理汇总了C++中CAtlStringW::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ CAtlStringW::GetString方法的具体用法?C++ CAtlStringW::GetString怎么用?C++ CAtlStringW::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAtlStringW
的用法示例。
在下文中一共展示了CAtlStringW::GetString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readHeaders
boolean CNetRequestImpl::readHeaders(Hashtable<String,String>& oHeaders)
{
oHeaders.clear();
CAtlStringW strHeaders;
DWORD dwLen = 0;
DWORD nIndex = 0;
if( !HttpQueryInfo( hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, null, &dwLen, &nIndex) )
{
DWORD dwErr = ::GetLastError();
if ( dwErr != ERROR_INSUFFICIENT_BUFFER )
{
pszErrFunction = L"HttpQueryInfo";
return false;
}
}
if( !HttpQueryInfo( hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, strHeaders.GetBuffer(dwLen), &dwLen, &nIndex) )
{
pszErrFunction = L"HttpQueryInfo";
return false;
}
strHeaders.ReleaseBuffer();
int nStart = 0;
for(int nEnd = strHeaders.Find(L"\r\n", nStart); nEnd > 0; nStart = nEnd+2, nEnd = strHeaders.Find(L"\r\n", nStart) )
{
CAtlStringW strHeader = strHeaders.Mid(nStart, nEnd-nStart);
int nSep = strHeader.Find(':');
if (nSep < 0 )
continue;
CAtlStringW strName = strHeader.Mid(0, nSep);
strName.Trim();
strName.MakeLower();
CAtlStringW strValue = strHeader.Mid(nSep+1);
strValue.Trim();
oHeaders.put(common::convertToStringA(strName.GetString()),common::convertToStringA(strValue.GetString()));
}
return true;
}
示例2: 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);
}
示例3: makeClientCookie
String CNetRequestImpl::makeClientCookie()
{
DWORD nIndex = 0;
String cookie;
while(true)
{
CAtlStringW strCookie;
DWORD dwLen = 0;
if( !HttpQueryInfo( hRequest, HTTP_QUERY_SET_COOKIE, null, &dwLen, &nIndex) )
{
DWORD dwErr = ::GetLastError();
if ( dwErr == ERROR_HTTP_HEADER_NOT_FOUND )
break;
if ( dwErr != ERROR_INSUFFICIENT_BUFFER )
{
pszErrFunction = L"HttpQueryInfo";
break;
}
}
if( !HttpQueryInfo( hRequest, HTTP_QUERY_SET_COOKIE, strCookie.GetBuffer(dwLen), &dwLen, &nIndex) )
{
pszErrFunction = L"HttpQueryInfo";
break;
}
strCookie.ReleaseBuffer();
URI::parseCookie(common::convertToStringA(strCookie.GetString()).c_str(), cookie);
}
if (pszErrFunction)
return "";
// if ( cookie.strAuth.length() > 0 || cookie.strSession.length() >0 )
// return cookie.strAuth + ";" + cookie.strSession + ";";
return cookie;
}
示例4: WriteContentPropertiesBulk
//.........这里部分代码省略.........
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&pValues));
if (FAILED(hr))
{
printf("! Failed to CoCreate CLSID_PortableDeviceValues, hr = 0x%lx\n", hr);
}
// Get the Object ID whose properties we will set
if (hr == S_OK)
{
hr = pObjectIDs->GetAt(dwIndex, &pv);
if (FAILED(hr))
{
printf("! Failed to get next Object ID from list, hr = 0x%lx\n", hr);
}
}
// Save them into the IPortableDeviceValues so the driver knows which object this proeprty set belongs to
if (hr == S_OK)
{
hr = pValues->SetStringValue(WPD_OBJECT_ID, pv.pwszVal);
if (FAILED(hr))
{
printf("! Failed to set WPD_OBJECT_ID, hr = 0x%lx\n", hr);
}
}
// Set the new values. In this sample, we attempt to set the name property.
if (hr == S_OK)
{
CAtlStringW strValue;
strValue.Format(L"NewName%d", dwIndex);
hr = pValues->SetStringValue(WPD_OBJECT_NAME, strValue.GetString());
if (FAILED(hr))
{
printf("! Failed to set WPD_OBJECT_NAME, hr = 0x%lx\n", hr);
}
}
// Add this property set to the collection
if (hr == S_OK)
{
hr = pPropertiesToWrite->Add(pValues);
if (FAILED(hr))
{
printf("! Failed to add values to collection, hr = 0x%lx\n", hr);
}
}
PropVariantClear(&pv);
}
}
// 9) Call QueueSetValuesByObjectList to initialize the Asynchronous
// property operation.
if (SUCCEEDED(hr))
{
hr = pPropertiesBulk->QueueSetValuesByObjectList(pPropertiesToWrite,
pCallback,
&guidContext);
// 10) Call Start() to actually being the property operation
if(SUCCEEDED(hr))
{
// Cleanup any previously created global event handles.
if (g_hBulkPropertyOperationEvent != NULL)
{
示例5: 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();
}
}
示例6: UnregisterForEventNotifications
void UnregisterForEventNotifications(IPortableDevice* pDevice)
{
HRESULT hr = S_OK;
if (pDevice == NULL)
{
return;
}
hr = pDevice->Unadvise(g_strEventRegistrationCookie);
if (FAILED(hr))
{
printf("! Failed to unregister for device events using registration cookie '%ws', hr = 0x%lx\n",g_strEventRegistrationCookie.GetString(), hr);
}
if (hr == S_OK)
{
printf("This application used the registration cookie '%ws' to unregister from receiving device event notifications", g_strEventRegistrationCookie.GetString());
}
g_strEventRegistrationCookie = L"";
}