本文整理汇总了C++中CAtlStringW类的典型用法代码示例。如果您正苦于以下问题:C++ CAtlStringW类的具体用法?C++ CAtlStringW怎么用?C++ CAtlStringW使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAtlStringW类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
bool
CDeviceView::EnableSelectedDevice(
_In_ bool Enable,
_Out_ bool &NeedsReboot
)
{
CDeviceNode *Node = dynamic_cast<CDeviceNode *>(GetSelectedNode());
if (Node == nullptr) return false;
if (Enable == false)
{
CAtlStringW str;
if (str.LoadStringW(g_hThisInstance, IDS_CONFIRM_DISABLE))
{
if (MessageBoxW(m_hMainWnd,
str,
Node->GetDisplayName(),
MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) != IDYES)
{
return false;
}
}
}
return Node->EnableDevice(Enable, NeedsReboot);
}
示例3: InitializeEnumerationContext
// Initialize the enumeration context
VOID WpdObjectEnumerator::InitializeEnumerationContext(
WpdObjectEnumeratorContext* pEnumeratorContext,
CAtlStringW strParentObjectID)
{
if (pEnumeratorContext == NULL)
{
return;
}
// Initialize the enumeration context with the parent object identifier
pEnumeratorContext->m_strParentObjectID = strParentObjectID;
// Our sample driver has a very simple object structure where we know
// how many children are under each parent.
// The eumeration context is initialized below with this information.
if (strParentObjectID.CompareNoCase(L"") == 0)
{
// Clients passing an 'empty' string for the parent are asking for the
// 'DEVICE' object. We should return 1 child in this case.
pEnumeratorContext->m_TotalChildren = 1;
}
else if (strParentObjectID.CompareNoCase(WPD_DEVICE_OBJECT_ID) == 0)
{
// The device object contains 1 child (the storage object).
pEnumeratorContext->m_TotalChildren = 1;
}
// If the sensor objects have children, add them here...
else
{
// The sensor object contains 0 children.
pEnumeratorContext->m_TotalChildren = 0;
}
}
示例4: memset
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);
}
示例5: _DBPropSet
HRESULT CDBHistory::UpdateHistory(HDBCONNECTION hDBConnection,
int nIndex,
LPCWSTR lpszComment,
BSTR* pbstrResult)
{
HRESULT hr = E_FAIL;
IMT::CDBConnection* pDBConnection = reinterpret_cast<IMT::CDBConnection*>(hDBConnection);
if (pDBConnection != NULL)
{
ATL::CCommand<ATL::CDynamicAccessor> Command;
ATL::CDBPropSet _DBPropSet(DBPROPSET_ROWSET);
pDBConnection->GetRowsetProperties(&_DBPropSet);
CAtlStringW strCommand;
strCommand.Format(QUERY_HISTORY_UPDATE, lpszComment, nIndex);
hr = Command.Open(ATL::CSession(*pDBConnection), strCommand, &_DBPropSet);
if (hr != S_OK)
{
if (pbstrResult != NULL)
IMT::GetDBErrorString(hr, pbstrResult);
}
else
{
TRACE(_T(":::[CDBHistory]-[UPDATE] SUCCEEDED :::\n"));
}
}
return hr;
}
示例6: _ASSERTE
HRESULT CDBConnection::OpenDataSource(LPCWSTR lpszPathFileName, LPCWSTR lpszUserName, LPCWSTR lpszPassword)
{
_ASSERTE(lpszPathFileName != NULL);
_ASSERTE(lpszUserName != NULL);
_ASSERTE(lpszPassword != NULL);
USES_CONVERSION;
HRESULT hr = E_FAIL;
if (lpszPathFileName != NULL && lpszUserName != NULL && lpszPassword != NULL)
{
if (::PathFileExists(lpszPathFileName))
{
CAtlStringW strConnection;
strConnection.Format(
#if defined(USES_JET_OLEDB_DRIVER)
L"Provider=Microsoft.Jet.OLEDB.4.0;"
#else
L"Provider=Microsoft.ACE.OLEDB.12.0;"
#endif
L"Data Source=%s;"
L"User ID=%s;"
L"Mode=Share Deny None;"
L"Extended Properties=\"\";"
L"Jet OLEDB:System database=\"\";"
L"Jet OLEDB:Registry Path=\"\";"
L"Jet OLEDB:Database Password=\"%s\";"
L"Jet OLEDB:Engine Type=5;"
L"Jet OLEDB:Database Locking Mode=1;"
L"Jet OLEDB:Global Partial Bulk Ops=2;"
L"Jet OLEDB:Global Bulk Transactions=1;"
L"Jet OLEDB:New Database Password=\"\";"
L"Jet OLEDB:Create System Database=False;"
L"Jet OLEDB:Encrypt Database=False;"
L"Jet OLEDB:Don't Copy Locale on Compact=False;"
L"Jet OLEDB:Compact Without Replica Repair=False;"
L"Jet OLEDB:SFP=False"
, lpszPathFileName, lpszUserName, lpszPassword);
hr = Open(LPCWSTR(strConnection));
if (FAILED(hr))
{
#ifdef _DEBUG
ATL::AtlTraceErrorRecords(hr);
#endif
}
}
else
hr = HRESULT_FROM_WIN32(::GetLastError());
}
else
hr = E_POINTER;
return hr;
}
示例7: CoTaskMemFree
LRESULT CPropertyEditWindow::OnAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
CPropertyAddDialog dialog;
// Add the property categories
for(size_t i = 0; i < m_arrPropertyInfo.GetCount(); i++)
{
if(m_arrPropertyInfo.GetAt(i)->IsWriteable() == S_OK)
{
LPWSTR szPropertyCategory;
TED_ATTRIBUTE_CATEGORY Category;
m_arrPropertyInfo.GetAt(i)->GetPropertyInfoName(&szPropertyCategory, &Category);
dialog.AddPropertyCategory(szPropertyCategory, Category, (DWORD) i);
CoTaskMemFree(szPropertyCategory);
}
}
// Fill dialog properties
if(dialog.DoModal() == IDOK)
{
DWORD dwIndex = dialog.GetChosenCategory();
CAtlStringW strName = dialog.GetChosenProperty();
CAtlStringW strValue = dialog.GetValue();
ITedPropertyInfo* pPropertyInfo = m_arrPropertyInfo.GetAt(dwIndex);
for(DWORD i = 0; i < TEDGetAttributeListLength(); i++)
{
if(TEDGetAttributeName(i) == strName)
{
DWORD dwPropertyCount;
pPropertyInfo->GetPropertyCount(&dwPropertyCount);
pPropertyInfo->SetProperty(dwPropertyCount, strName.GetBuffer(), TEDGetAttributeType(i), strValue.GetBuffer());
RECT clientRect;
GetClientRect(&clientRect);
DWORD dwViewWidth = clientRect.right - clientRect.left - 5;
RECT rectNextLabel;
rectNextLabel.top = 5 + (ms_LabelHeight * dwPropertyCount);
rectNextLabel.left = 5;
rectNextLabel.right = rectNextLabel.left + dwViewWidth / 2;
rectNextLabel.bottom = rectNextLabel.top + ms_LabelHeight;
CreatePropertyInterfaceForIndex(dwIndex, dwPropertyCount, rectNextLabel);
ResizeChildren();
break;
}
}
}
return 0;
}
示例8: cstrExtension
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;
}
示例9: CHECK_POINTER_RETURN_VALUE_IF_FAIL
HRESULT CDefaultRecordGraphBuilder::CreateAudioSrcFilter(IBaseFilter** ppSrcFilter)
{
CHECK_POINTER_RETURN_VALUE_IF_FAIL(ppSrcFilter, E_POINTER);
HRESULT hr = E_FAIL;
CFSharePtr<FTL::CFDShowHardwareMgr> spAudioCaptureHardwareMgr(new FTL::CFDShowHardwareMgr());
DX_VERIFY_EXCEPT1(spAudioCaptureHardwareMgr->Refresh(&CLSID_AudioInputDeviceCategory), S_FALSE);
if (S_OK == hr)
{
CAtlStringW wstrAudioInputString;
if (m_Param.strAudioInputName.IsEmpty())
{
//get first -- TODO: use enum
FTL::HardwareMonikerInfoContainer& rHardwares = spAudioCaptureHardwareMgr->GetAllHardwares();
if (!rHardwares.empty())
{
wstrAudioInputString = (*rHardwares.begin())->wachFriendlyName;
//m_spAudioCaptureHardwareMgr->GetDefault
}
}
else
{
//User Save audio
wstrAudioInputString = CT2W(m_Param.strAudioInputName);
}
if (!wstrAudioInputString.IsEmpty())
{
CComPtr<IBaseFilter> spAudioSrcFilter;
DX_VERIFY(spAudioCaptureHardwareMgr->GetBindObject(wstrAudioInputString, IID_IBaseFilter, (void **)&spAudioSrcFilter));
if (SUCCEEDED(hr))
{
DX_VERIFY(m_spGraphBuilder->AddFilter(spAudioSrcFilter, wstrAudioInputString));
if (SUCCEEDED(hr))
{
*ppSrcFilter = spAudioSrcFilter.Detach();
//(*ppSrcFilter)->AddRef();
}
}
else
{
//maybe user change audio device ?
}
}
}
return hr;
}
示例10: _DBPropSet
HRESULT CDBHistroy_BIT::AddHistoryBIT(HDBCONNECTION hDBConnection,
DB_BIT dbBIT,
BSTR* pbstrResult)
{
HRESULT hr = E_FAIL;
IMT::CDBConnection* pDBConnection = reinterpret_cast<IMT::CDBConnection*>(hDBConnection);
if (pDBConnection != NULL)
{
ATL::CCommand<ATL::CDynamicAccessor> Command;
ATL::CDBPropSet _DBPropSet(DBPROPSET_ROWSET);
pDBConnection->GetRowsetProperties(&_DBPropSet);
CAtlStringW strCommand;
strCommand.Format(QUERY_H_BIT_INSERT,
dbBIT.dbHistory.dateTime.year,
dbBIT.dbHistory.dateTime.month,
dbBIT.dbHistory.dateTime.day,
dbBIT.dbHistory.dateTime.hour,
dbBIT.dbHistory.dateTime.minute,
dbBIT.dbHistory.dateTime.second,
dbBIT.wszInstrumentName,
dbBIT.dbHistory.nBIT,
dbBIT.wszInspectionItem,
dbBIT.dbHistory.lPresentedResult,
dbBIT.dbHistory.wszComment,
dbBIT.bMainSection);
hr = Command.Open(ATL::CSession(*pDBConnection), strCommand, &_DBPropSet);
if (hr != S_OK)
{
if (pbstrResult != NULL)
IMT::GetDBErrorString(hr, pbstrResult);
}
else
{
TRACE(_T(":::[CDBHistroy_BIT]-[INSERT] SUCCEEDED :::\n"));
}
}
/*SELECT MAX(rowId) FROM property */
return hr;
}
示例11: _DBPropSet
HRESULT CDBHistroy_External::AddHistoryExternal(HDBCONNECTION hDBConnection,
DB_EXTERNAL dbExternal,
BSTR* pbstrResult)
{
HRESULT hr = E_FAIL;
IMT::CDBConnection* pDBConnection = reinterpret_cast<IMT::CDBConnection*>(hDBConnection);
if (pDBConnection != NULL)
{
ATL::CCommand<ATL::CDynamicAccessor> Command;
ATL::CDBPropSet _DBPropSet(DBPROPSET_ROWSET);
pDBConnection->GetRowsetProperties(&_DBPropSet);
CAtlStringW strCommand;
strCommand.Format(QUERY_H_EXTERNAL_INSERT,
dbExternal.dbHistory.dateTime.year,
dbExternal.dbHistory.dateTime.month,
dbExternal.dbHistory.dateTime.day,
dbExternal.dbHistory.dateTime.hour,
dbExternal.dbHistory.dateTime.minute,
dbExternal.dbHistory.dateTime.second,
dbExternal.wszInspectionItem,
dbExternal.wszLRUPort,
dbExternal.wszCable,
dbExternal.wszInspectionSignal,
dbExternal.wszInterlockPort,
dbExternal.dbHistory.bResult,
dbExternal.dbHistory.wszID,
dbExternal.dbHistory.wszComment);
hr = Command.Open(ATL::CSession(*pDBConnection), strCommand, &_DBPropSet);
if (hr != S_OK)
{
if (pbstrResult != NULL)
IMT::GetDBErrorString(hr, pbstrResult);
}
else
{
TRACE(_T(":::[CDBHistroy_External]-[INSERT] SUCCEEDED :::\n"));
}
}
return hr;
}
示例12: OnOK
LRESULT CPropertyEditWindow::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
bool fAllSucceeded = true;
for(size_t i = 0; i < m_arrPropertyInfo.GetCount(); i++)
{
ITedPropertyInfo* pPropertyInfo = m_arrPropertyInfo.GetAt(i);
PropertyInfoDisplay* pDisplay = m_arrPropertyInfoDisplay.GetAt(i);
for(size_t j = 0; j < pDisplay->m_arrLabels.GetCount(); j++)
{
VARTYPE vt = pDisplay->m_arrVartypes.GetAt(j);
if(vt == VT_EMPTY || vt == VT_UNKNOWN || vt == (VT_VECTOR | VT_UI1)) continue;
LPWSTR strName, strValue;
// Get label text (property name)
int nameLen = pDisplay->m_arrLabels.GetAt(j)->GetWindowTextLength();
strName = new WCHAR[nameLen + 1];
if(NULL == strName) continue;
pDisplay->m_arrLabels.GetAt(j)->GetWindowText(strName, nameLen + 1);
// Get edit text (property value)
int valueLen = pDisplay->m_arrEdits.GetAt(j)->GetWindowTextLength();
strValue = new WCHAR[valueLen + 1];
if(NULL == strValue) { delete[] strName; continue; }
pDisplay->m_arrEdits.GetAt(j)->GetWindowText(strValue, valueLen + 1);
HRESULT hr = pPropertyInfo->SetProperty((DWORD) j, strName, vt, strValue);
if( FAILED(hr) && fAllSucceeded)
{
CAtlStringW strError;
strError.FormatMessage(IDS_E_SAVE_PROP, hr);
MessageBox(strError, LoadAtlString(IDS_ERROR), MB_OK);
fAllSucceeded = false;
}
delete[] strName;
delete[] strValue;
}
}
return 0;
}
示例13: HRESULT_FROM_WIN32
HRESULT WpdService::CheckRequestFilename(
_In_ LPCWSTR pszRequestFilename)
{
HRESULT hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
CAtlStringW strRequestFilename = pszRequestFilename;
// For simplicity, the request filename happens to be the same as the service object ID
if (strRequestFilename.CompareNoCase(m_pGattService->GetRequestFilename()) == 0)
{
hr = S_OK;
}
else
{
CHECK_HR(hr, "Unknown request filename %ws received", pszRequestFilename);
}
return hr;
}
示例14: GetLastError
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);
}
示例15: GetAccessScope
ACCESS_SCOPE FakeDevice::GetAccessScope(
_In_ IPortableDeviceValues* pParams)
{
ACCESS_SCOPE Scope = FULL_DEVICE_ACCESS;
LPWSTR pszFileName = NULL;
// For simplicity, our request filename is the same as the the service object ID
if (pParams && (pParams->GetStringValue(PRIVATE_SAMPLE_DRIVER_REQUEST_FILENAME, &pszFileName) == S_OK))
{
CAtlStringW strRequestFilename = pszFileName;
// For simplicity, our request filename is the same as the the service object ID
// Case-insensitive comparison is required
if (strRequestFilename.CompareNoCase(m_ContactsService.GetRequestFilename()) == 0)
{
Scope = CONTACTS_SERVICE_ACCESS;
}
}
CoTaskMemFree(pszFileName);
return Scope;
}