📄 vartype.c
字号:
*
* PARAMS
* strIn [I] Source
* lcid [I] LCID for the conversion
* dwFlags [I] Flags controlling the conversion (VAR_ flags from "oleauto.h")
* psOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: E_INVALIDARG, if any parameter is invalid
* DISP_E_OVERFLOW, if the value will not fit in the destination
* DISP_E_TYPEMISMATCH, if the type cannot be converted
*/
HRESULT WINAPI VarI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, SHORT* psOut)
{
return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, psOut, VT_I2);
}
/************************************************************************
* VarI2FromDisp (OLEAUT32.55)
*
* Convert a VT_DISPATCH to a VT_I2.
*
* PARAMS
* pdispIn [I] Source
* lcid [I] LCID for conversion
* psOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: E_INVALIDARG, if pdispIn is invalid,
* DISP_E_OVERFLOW, if the value will not fit in the destination,
* DISP_E_TYPEMISMATCH, if the type cannot be converted
*/
HRESULT WINAPI VarI2FromDisp(IDispatch* pdispIn, LCID lcid, SHORT* psOut)
{
return VARIANT_FromDisp(pdispIn, lcid, psOut, VT_I2, 0);
}
/************************************************************************
* VarI2FromBool (OLEAUT32.56)
*
* Convert a VT_BOOL to a VT_I2.
*
* PARAMS
* boolIn [I] Source
* psOut [O] Destination
*
* RETURNS
* S_OK.
*/
HRESULT WINAPI VarI2FromBool(VARIANT_BOOL boolIn, SHORT* psOut)
{
return _VarI2FromBool(boolIn, psOut);
}
/************************************************************************
* VarI2FromI1 (OLEAUT32.205)
*
* Convert a VT_I1 to a VT_I2.
*
* PARAMS
* cIn [I] Source
* psOut [O] Destination
*
* RETURNS
* S_OK.
*/
HRESULT WINAPI VarI2FromI1(signed char cIn, SHORT* psOut)
{
return _VarI2FromI1(cIn, psOut);
}
/************************************************************************
* VarI2FromUI2 (OLEAUT32.206)
*
* Convert a VT_UI2 to a VT_I2.
*
* PARAMS
* usIn [I] Source
* psOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarI2FromUI2(USHORT usIn, SHORT* psOut)
{
return _VarI2FromUI2(usIn, psOut);
}
/************************************************************************
* VarI2FromUI4 (OLEAUT32.207)
*
* Convert a VT_UI4 to a VT_I2.
*
* PARAMS
* ulIn [I] Source
* psOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarI2FromUI4(ULONG ulIn, SHORT* psOut)
{
return _VarI2FromUI4(ulIn, psOut);
}
/************************************************************************
* VarI2FromDec (OLEAUT32.208)
*
* Convert a VT_DECIMAL to a VT_I2.
*
* PARAMS
* pDecIn [I] Source
* psOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: E_INVALIDARG, if the source value is invalid
* DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarI2FromDec(DECIMAL *pdecIn, SHORT* psOut)
{
LONG64 i64;
HRESULT hRet;
hRet = VarI8FromDec(pdecIn, &i64);
if (SUCCEEDED(hRet))
hRet = _VarI2FromI8(i64, psOut);
return hRet;
}
/************************************************************************
* VarI2FromI8 (OLEAUT32.346)
*
* Convert a VT_I8 to a VT_I2.
*
* PARAMS
* llIn [I] Source
* psOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarI2FromI8(LONG64 llIn, SHORT* psOut)
{
return _VarI2FromI8(llIn, psOut);
}
/************************************************************************
* VarI2FromUI8 (OLEAUT32.347)
*
* Convert a VT_UI8 to a VT_I2.
*
* PARAMS
* ullIn [I] Source
* psOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarI2FromUI8(ULONG64 ullIn, SHORT* psOut)
{
return _VarI2FromUI8(ullIn, psOut);
}
/* UI2
*/
/************************************************************************
* VarUI2FromUI1 (OLEAUT32.257)
*
* Convert a VT_UI1 to a VT_UI2.
*
* PARAMS
* bIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* S_OK.
*/
HRESULT WINAPI VarUI2FromUI1(BYTE bIn, USHORT* pusOut)
{
return _VarUI2FromUI1(bIn, pusOut);
}
/************************************************************************
* VarUI2FromI2 (OLEAUT32.258)
*
* Convert a VT_I2 to a VT_UI2.
*
* PARAMS
* sIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarUI2FromI2(SHORT sIn, USHORT* pusOut)
{
return _VarUI2FromI2(sIn, pusOut);
}
/************************************************************************
* VarUI2FromI4 (OLEAUT32.259)
*
* Convert a VT_I4 to a VT_UI2.
*
* PARAMS
* iIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarUI2FromI4(LONG iIn, USHORT* pusOut)
{
return _VarUI2FromI4(iIn, pusOut);
}
/************************************************************************
* VarUI2FromR4 (OLEAUT32.260)
*
* Convert a VT_R4 to a VT_UI2.
*
* PARAMS
* fltIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarUI2FromR4(FLOAT fltIn, USHORT* pusOut)
{
return VarUI2FromR8(fltIn, pusOut);
}
/************************************************************************
* VarUI2FromR8 (OLEAUT32.261)
*
* Convert a VT_R8 to a VT_UI2.
*
* PARAMS
* dblIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*
* NOTES
* See VarI8FromR8() for details concerning rounding.
*/
HRESULT WINAPI VarUI2FromR8(double dblIn, USHORT* pusOut)
{
if (dblIn < -0.5 || dblIn > (double)UI2_MAX)
return DISP_E_OVERFLOW;
VARIANT_DutchRound(USHORT, dblIn, *pusOut);
return S_OK;
}
/************************************************************************
* VarUI2FromDate (OLEAUT32.262)
*
* Convert a VT_DATE to a VT_UI2.
*
* PARAMS
* dateIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarUI2FromDate(DATE dateIn, USHORT* pusOut)
{
return VarUI2FromR8(dateIn, pusOut);
}
/************************************************************************
* VarUI2FromCy (OLEAUT32.263)
*
* Convert a VT_CY to a VT_UI2.
*
* PARAMS
* cyIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*
* NOTES
* Negative values >= -5000 will be converted to 0.
*/
HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT* pusOut)
{
ULONG i = UI2_MAX + 1;
VarUI4FromCy(cyIn, &i);
return _VarUI2FromUI4(i, pusOut);
}
/************************************************************************
* VarUI2FromStr (OLEAUT32.264)
*
* Convert a VT_BSTR to a VT_UI2.
*
* PARAMS
* strIn [I] Source
* lcid [I] LCID for the conversion
* dwFlags [I] Flags controlling the conversion (VAR_ flags from "oleauto.h")
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
* DISP_E_TYPEMISMATCH, if the type cannot be converted
*/
HRESULT WINAPI VarUI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, USHORT* pusOut)
{
return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pusOut, VT_UI2);
}
/************************************************************************
* VarUI2FromDisp (OLEAUT32.265)
*
* Convert a VT_DISPATCH to a VT_UI2.
*
* PARAMS
* pdispIn [I] Source
* lcid [I] LCID for conversion
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: E_INVALIDARG, if the source value is invalid
* DISP_E_OVERFLOW, if the value will not fit in the destination
* DISP_E_TYPEMISMATCH, if the type cannot be converted
*/
HRESULT WINAPI VarUI2FromDisp(IDispatch* pdispIn, LCID lcid, USHORT* pusOut)
{
return VARIANT_FromDisp(pdispIn, lcid, pusOut, VT_UI2, 0);
}
/************************************************************************
* VarUI2FromBool (OLEAUT32.266)
*
* Convert a VT_BOOL to a VT_UI2.
*
* PARAMS
* boolIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* S_OK.
*/
HRESULT WINAPI VarUI2FromBool(VARIANT_BOOL boolIn, USHORT* pusOut)
{
return _VarUI2FromBool(boolIn, pusOut);
}
/************************************************************************
* VarUI2FromI1 (OLEAUT32.267)
*
* Convert a VT_I1 to a VT_UI2.
*
* PARAMS
* cIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarUI2FromI1(signed char cIn, USHORT* pusOut)
{
return _VarUI2FromI1(cIn, pusOut);
}
/************************************************************************
* VarUI2FromUI4 (OLEAUT32.268)
*
* Convert a VT_UI4 to a VT_UI2.
*
* PARAMS
* ulIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarUI2FromUI4(ULONG ulIn, USHORT* pusOut)
{
return _VarUI2FromUI4(ulIn, pusOut);
}
/************************************************************************
* VarUI2FromDec (OLEAUT32.269)
*
* Convert a VT_DECIMAL to a VT_UI2.
*
* PARAMS
* pDecIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: E_INVALIDARG, if the source value is invalid
* DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarUI2FromDec(DECIMAL *pdecIn, USHORT* pusOut)
{
LONG64 i64;
HRESULT hRet;
hRet = VarI8FromDec(pdecIn, &i64);
if (SUCCEEDED(hRet))
hRet = _VarUI2FromI8(i64, pusOut);
return hRet;
}
/************************************************************************
* VarUI2FromI8 (OLEAUT32.378)
*
* Convert a VT_I8 to a VT_UI2.
*
* PARAMS
* llIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarUI2FromI8(LONG64 llIn, USHORT* pusOut)
{
return _VarUI2FromI8(llIn, pusOut);
}
/************************************************************************
* VarUI2FromUI8 (OLEAUT32.379)
*
* Convert a VT_UI8 to a VT_UI2.
*
* PARAMS
* ullIn [I] Source
* pusOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarUI2FromUI8(ULONG64 ullIn, USHORT* pusOut)
{
return _VarUI2FromUI8(ullIn, pusOut);
}
/* I4
*/
/************************************************************************
* VarI4FromUI1 (OLEAUT32.58)
*
* Convert a VT_UI1 to a VT_I4.
*
* PARAMS
* bIn [I] Source
* piOut [O] Destination
*
* RETURNS
* S_OK.
*/
HRESULT WINAPI VarI4FromUI1(BYTE bIn, LONG *piOut)
{
return _VarI4FromUI1(bIn, piOut);
}
/************************************************************************
* VarI4FromI2 (OLEAUT32.59)
*
* Convert a VT_I2 to a VT_I4.
*
* PARAMS
* sIn [I] Source
* piOut [O] Destination
*
* RETURNS
* Success: S_OK.
* Failure: E_INVALIDARG, if the source value is invalid
* DISP_E_OVERFLOW, if the value will not fit in the destination
*/
HRESULT WINAPI VarI4FromI2(SHORT sIn, LONG *piOut)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -