Пример #1
0
//获得参数
void __cdecl CDataBase::GetParameterValue(LPCTSTR pszParamName, _variant_t & vtValue)
{
	//效验参数
	ASSERT(pszParamName!=NULL);

	//获取参数
	try 
	{
		vtValue.Clear();
		vtValue=m_DBCommand->Parameters->Item[pszParamName]->Value;
	}
	catch (CComError & ComError) { SetErrorInfo(ErrorType_Other,GetComErrorDescribe(ComError)); }

	return;
}
Пример #2
0
Result XMLGetAttribute(_variant_t& out, VARTYPE destType, MSXML::IXMLDOMElementPtr pEl, const string& sAttribute)
{
	Result r = XMLGetAttribute(out, pEl, sAttribute);
	if(r.Succeeded())
	{
		try
		{
			out.ChangeType(destType);
		}
		catch(_com_error& e)
		{
			r.Fail(Format("Error converting %s attribute to its destination type. % %").s(sAttribute).s(e.ErrorMessage()).s(e.Description()).Str());
		}
	}
	return r;
}
Пример #3
0
void XPCDispParams::InsertParam(_variant_t & var)
{
#ifdef DEBUG
    NS_ASSERTION(!mInserted, 
                 "XPCDispParams::InsertParam cannot be called more than once");
    mInserted = PR_TRUE;
#endif
    // Bump the pointer back and increment the arg count
    --mDispParams.rgvarg;
    mRefBuffer -= sizeof(VARIANT);
    ++mDispParams.cArgs;
    // Assign the value
    mDispParams.rgvarg[0] = var.Detach();
    // initialize the ref buffer
    memset(mRefBuffer, 0, sizeof(VARIANT));
}
Пример #4
0
bool RegUtils::GetNextValue(const HKEY& hKey, int iKeyIndex, CStdString& sName, _variant_t& vtData)
{
	TCHAR	szValueName[MAX_PATH];
	DWORD	dwValueNameSize = MAX_PATH;
	DWORD	dwValueDataSize = MAX_PATH;
	BYTE	byteValueData[MAX_PATH];
	
	DWORD dwType = REG_NONE;
	
	ZeroMemory(szValueName, MAX_PATH);
	ZeroMemory(byteValueData, MAX_PATH);

	sName = _T("");
	vtData.Clear();

	if (RegEnumValue(hKey, iKeyIndex, szValueName, &dwValueNameSize, NULL, &dwType, byteValueData, &dwValueDataSize) == ERROR_SUCCESS)
	{
		switch (dwType)
		{
		case REG_SZ:
			vtData = (TCHAR*)byteValueData;
			sName = szValueName;
			break;

		case REG_DWORD:
			vtData = (DWORD)*byteValueData;
			sName = szValueName;
			break;

		default:
			LOG_WS_ERROR(_T("Unexpected type returned from the registry"));
			_ASSERT(_T("Unexpected type returned from the registry") == 0);
			return false;
		}
		return true;
	}
	return false;
}
Пример #5
0
//*****************************************************************************
//* Function Name: WrapInSafeArray
//*   Description: Wrap a buffer in a SAFEARRAY. This function sets up a
//*                SAFEARRAY data structure (p_sa) to describe a buffer
//*                (without copying the data). It then sets up a smart variant
//*                (p_svar) to contain the SAFEARRAY. The SAFEARRAY is set up
//*                with flags such that the data is not deallocated when the
//*                smart variant is destructed/cleared.
//*****************************************************************************
static void WrapInSafeArray (
	SAFEARRAY&	p_sa,
	_variant_t&	p_svar,
	LPCVOID		p_lpv,
	int			p_cb)
{
	ZeroMemory (&p_sa, sizeof (p_sa));

	p_sa.cDims					= 1;
	p_sa.fFeatures				= FADF_AUTO | FADF_FIXEDSIZE;
	p_sa.cbElements				= 1;
	p_sa.pvData					= const_cast<LPVOID>(p_lpv);
	p_sa.rgsabound[0].cElements	= p_cb;
	p_sa.rgsabound[0].lLbound	= 0;

	try {
		p_svar.Clear ();
	}
	catch (const _com_error&) {
	}

	V_VT (&p_svar)		= VT_ARRAY | VT_UI1;
	V_ARRAY (&p_svar)	= &p_sa;
}