本文整理汇总了C++中BAIL_ON_FAILURE函数的典型用法代码示例。如果您正苦于以下问题:C++ BAIL_ON_FAILURE函数的具体用法?C++ BAIL_ON_FAILURE怎么用?C++ BAIL_ON_FAILURE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BAIL_ON_FAILURE函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: BAIL_ON_FAILURE
//
// convert unicode string to cipher type
//
HRESULT
Wstr2CipherType
(
_In_ LPCWSTR pszSrc,
_Out_ PIHV_CIPHER_TYPE pCipherType
)
{
HRESULT hr = S_OK;
DWORD dwIndex = 0;
if ( (!pCipherType) || (!pszSrc) )
{
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
}
for ( dwIndex = 0; dwIndex < MAX_CIPHER_TYPES; dwIndex++ )
{
if ( 0 == wcscmp( gppszIhvCipherTypes[dwIndex], pszSrc ) )
{
(*pCipherType) = (IHV_CIPHER_TYPE) dwIndex;
BAIL( );
}
}
// String not found.
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
error:
return hr;
}
开发者ID:0xhack,项目名称:Windows-driver-samples,代码行数:36,代码来源:profile.cpp
示例2: BAIL_ON_FAILURE
HRESULT
CIhvSecurityProfile::GetFullSecurityFlag
(
BOOL* pbUseFullSecurity
)
{
HRESULT hr = S_OK;
BSTR bstrData = NULL;
hr =
GetTextFromNode
(
SEC_FSFLAG_XPATH,
&bstrData
);
BAIL_ON_FAILURE( hr );
hr =
Wstr2Bool
(
bstrData,
pbUseFullSecurity
);
BAIL_ON_FAILURE( hr );
error:
SYS_FREE_STRING( bstrData );
return hr;
}
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:29,代码来源:IHVSampleProfile.cpp
示例3: BAIL_ON_FAILURE
//
// convert unicode string to auth type
//
HRESULT
Wstr2AuthType
(
IN LPCWSTR pszSrc,
OUT PIHV_AUTH_TYPE pAuthType
)
{
HRESULT hr = S_OK;
DWORD dwIndex = 0;
if ( (!pAuthType) || (!pszSrc) )
{
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
}
for ( dwIndex = 0; dwIndex < MAX_AUTH_TYPES; dwIndex++ )
{
if ( 0 == wcscmp( gppszIhvAuthTypes[dwIndex], pszSrc ) )
{
(*pAuthType) = (IHV_AUTH_TYPE) dwIndex;
BAIL( );
}
}
// String not found.
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
error:
return hr;
}
开发者ID:kcrazy,项目名称:winekit,代码行数:36,代码来源:profile.cpp
示例4: BAIL_ON_FAILURE
HRESULT
CIhvConnectivityProfile::GetNativeData
(
LPVOID* ppvData
)
{
HRESULT hr = S_OK;
PIHV_CONNECTIVITY_PROFILE pIhvProfile = NULL;
BSTR bstrParam2 = NULL;
if ( !ppvData )
{
hr = E_INVALIDARG;
BAIL_ON_FAILURE( hr );
}
pIhvProfile = (PIHV_CONNECTIVITY_PROFILE) malloc( sizeof( IHV_CONNECTIVITY_PROFILE ) );
if ( !pIhvProfile )
{
hr = E_OUTOFMEMORY;
BAIL_ON_FAILURE( hr );
}
ZeroMemory( pIhvProfile, sizeof( IHV_CONNECTIVITY_PROFILE ) );
hr =
GetParamBSTR
(
&bstrParam2
);
BAIL_ON_FAILURE( hr );
hr =
Wstr2Wstr
(
bstrParam2,
&(pIhvProfile->pszParam2)
);
BAIL_ON_FAILURE( hr );
hr =
GetParamDWORD
(
&(pIhvProfile->dwParam1)
);
BAIL_ON_FAILURE( hr );
// Transfering local cache to OUT parameter.
(*ppvData) = pIhvProfile;
pIhvProfile = NULL;
error:
if ( pIhvProfile )
{
free( pIhvProfile->pszParam2 ); // NULL Safe.
free( pIhvProfile );
}
SYS_FREE_STRING( bstrParam2 );
return hr;
}
开发者ID:kcrazy,项目名称:winekit,代码行数:59,代码来源:IHVSampleProfile.cpp
示例5: ASSERT
// base function to obtain text from
// node described by XPATH.
HRESULT
CIhvProfileBase::GetTextFromNode
(
IN LPCWSTR pszQuery,
OUT BSTR* pbstrText
)
{
HRESULT hr = S_OK;
BSTR bstrQuery = NULL;
IXMLDOMNode* pQueryNode = NULL;
ASSERT( pszQuery );
ASSERT( pbstrText );
// if node is NULL, return empty string.
if ( !m_pRootNode )
{
hr =
Wstr2Bstr
(
L"",
pbstrText
);
BAIL( );
}
hr =
Wstr2Bstr
(
pszQuery,
&bstrQuery
);
BAIL_ON_FAILURE( hr );
hr = m_pRootNode->selectSingleNode( bstrQuery, &pQueryNode );
BAIL_ON_FAILURE( hr );
if (!pQueryNode)
{
hr = E_UNEXPECTED;
BAIL_ON_FAILURE( hr );
}
hr = pQueryNode->get_text( pbstrText );
BAIL_ON_FAILURE( hr );
if ( !(*pbstrText) )
{
hr = E_UNEXPECTED;
BAIL_ON_FAILURE( hr );
}
error:
RELEASE_INTERFACE( pQueryNode );
SYS_FREE_STRING( bstrQuery );
return hr;
}
开发者ID:0xhack,项目名称:Windows-driver-samples,代码行数:59,代码来源:profile.cpp
示例6: sizeof
DWORD
ConvertStringToKey
(
BYTE* pbKeyData,
DWORD* pdwKeyLen
)
{
DWORD dwResult = ERROR_SUCCESS;
HRESULT hr = S_OK;
CHAR szKey[ MAX_KEY_STRING_LENGTH + 2 ] = {0};
DWORD dwKeyStringLen = 0;
DWORD dwIndex = 0;
if
(
(!pbKeyData) ||
(!pdwKeyLen) ||
( 0 == (*pdwKeyLen) ) ||
( (*pdwKeyLen) % sizeof( WCHAR ) )
)
{
dwResult = ERROR_INVALID_PARAMETER;
BAIL_ON_WIN32_ERROR( dwResult );
}
dwKeyStringLen = (DWORD) wcslen( (LPWSTR) pbKeyData );
if ( MAX_KEY_STRING_LENGTH < dwKeyStringLen )
{
dwResult = ERROR_BAD_FORMAT;
BAIL_ON_WIN32_ERROR( dwResult );
}
// Converting the UNICODE string to
// ANSI string in scratch pad.
hr =
StringCchPrintfA
(
szKey,
MAX_KEY_STRING_LENGTH + 1,
"%S",
(WCHAR*) pbKeyData
);
BAIL_ON_FAILURE( hr );
ASSERT( dwKeyStringLen == (DWORD) strlen( szKey ));
if ( ( 5 == dwKeyStringLen ) || ( 13 == dwKeyStringLen ) )
{
// Copying the ANSI string back to original buffer.
hr =
StringCchPrintfA
(
(CHAR*) pbKeyData,
(*pdwKeyLen),
"%s",
szKey
);
BAIL_ON_FAILURE( hr );
// The strings are direct representations
// of the Wep Key and can be directly returned.
(*pdwKeyLen) = dwKeyStringLen;
TRACE_MESSAGE_VAL( "Received WEP key of length = ", (*pdwKeyLen) );
BAIL( );
}
if (( 10 != dwKeyStringLen ) && ( 26 != dwKeyStringLen ))
{
// Wrong length input
dwResult = ERROR_BAD_FORMAT;
BAIL_ON_WIN32_ERROR( dwResult );
}
for( dwIndex = 0; dwIndex < (dwKeyStringLen / 2); dwIndex++ )
{
dwResult =
ConvertHexCharToNibble
(
szKey[ 2 * dwIndex ],
TRUE,
&(pbKeyData[ dwIndex ])
);
BAIL_ON_WIN32_ERROR( dwResult );
dwResult =
ConvertHexCharToNibble
(
szKey[ 1 + (2 * dwIndex) ],
FALSE,
&(pbKeyData[ dwIndex ])
);
BAIL_ON_WIN32_ERROR( dwResult );
}
(*pdwKeyLen) = dwKeyStringLen / 2;
//.........这里部分代码省略.........
开发者ID:kcrazy,项目名称:winekit,代码行数:101,代码来源:ihvwep.cpp
示例7: WlanHostedNetworkQuerySecondaryKey
HRESULT
CWlanManager::GetHostedNetworkKey(
CAtlString& strKey
)
{
HRESULT hr = S_OK;
DWORD dwError = ERROR_SUCCESS;
BOOL bIsPassPhrase = FALSE;
BOOL bPersistent = FALSE;
PUCHAR pucSecondaryKey = NULL;
DWORD dwSecondaryKeyLength = 0;
WCHAR strSecondaryKey[WLAN_MAX_NAME_LENGTH];
// get the user security key
dwError = WlanHostedNetworkQuerySecondaryKey(
m_WlanHandle,
&dwSecondaryKeyLength,
&pucSecondaryKey,
&bIsPassPhrase,
&bPersistent,
NULL,
NULL
);
BAIL_ON_WIN32_ERROR(dwError, hr);
int cchKey = 0;
if (dwSecondaryKeyLength > 0)
{
// Must be passphrase
_ASSERT(bIsPassPhrase);
// convert the key
if (bIsPassPhrase)
{
#pragma prefast(suppress:26035, "If the key is a pass phrase, it is guaranteed to be null-terminated.")
cchKey = MultiByteToWideChar(
CP_ACP,
MB_ERR_INVALID_CHARS,
(LPCSTR)pucSecondaryKey,
dwSecondaryKeyLength,
strSecondaryKey,
sizeof(strSecondaryKey) / sizeof(strSecondaryKey[0]) -1
);
}
}
if(cchKey == 0)
{
// secondary key is not set or not passphrase
// set a temporary one
CAtlString strTmpKey = L"HostedNetwork12345";
hr = SetHostedNetworkKey(strTmpKey);
BAIL_ON_FAILURE(hr);
strKey = strTmpKey;
}
else
{
// got the key
strKey = strSecondaryKey;
}
error:
if (pucSecondaryKey != NULL)
{
WlanFreeMemory(pucSecondaryKey);
pucSecondaryKey = NULL;
}
return hr;
}
开发者ID:Ippei-Murofushi,项目名称:WindowsSDK7-Samples,代码行数:72,代码来源:WlanMgr.cpp
示例8: GetDefaultXml
HRESULT
CIhvProfileBase::LoadXml
(
IN BSTR bstrProfileData
)
{
HRESULT hr = S_OK;
IXMLDOMDocument* pDOMDoc = NULL;
IXMLDOMElement* pDocElem = NULL;
BSTR bstrIhvProfile = NULL;
VARIANT_BOOL vfSuccess;
if ( !bstrProfileData )
{
hr = GetDefaultXml( &bstrIhvProfile );
BAIL_ON_FAILURE( hr );
}
else
{
bstrIhvProfile = bstrProfileData;
}
if ( m_pRootNode )
{
hr = E_UNEXPECTED;
BAIL_ON_FAILURE( hr );
}
hr =
CoCreateInstance
(
CLSID_DOMDocument,
NULL,
CLSCTX_ALL,
IID_IXMLDOMDocument,
(LPVOID *) &pDOMDoc
);
BAIL_ON_FAILURE( hr );
hr =
pDOMDoc->loadXML
(
bstrIhvProfile,
&vfSuccess
);
BAIL_ON_FAILURE( hr );
if ( VARIANT_TRUE != vfSuccess )
{
hr = E_UNEXPECTED;
BAIL_ON_FAILURE( hr );
}
hr =
pDOMDoc->get_documentElement
(
&pDocElem
);
BAIL_ON_FAILURE( hr );
// Caching the pointer to the document element
// in a member variable.
m_pRootNode = pDocElem;
pDocElem = NULL;
error:
if ( !bstrProfileData )
{
SYS_FREE_STRING( bstrIhvProfile );
}
RELEASE_INTERFACE( pDOMDoc );
RELEASE_INTERFACE( pDocElem );
return hr;
}
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:75,代码来源:IHVSampleProfile.cpp
注:本文中的BAIL_ON_FAILURE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论