Grupos de Google ya no admite nuevas publicaciones ni suscripciones de Usenet. El contenido anterior sigue siendo visible.

VariantChangeType() doesn't work well to convert VT_I8 to VT_DECIMAL and vice versa

Visto 24 veces
Saltar al primer mensaje no leído

Bae, Hyun-jik

no leída,
22 sept 2002, 21:58:2022/9/02
a
VariantChangeType() doesn't work well to convert VT_I8 to VT_DECIMAL and
vice versa. I tested it with _variant_t class(This class is included in
VS.NET) and I tracked the source code lines and found VariantChangeType()
returns error.
However, not every machine commits this error. My computer has Windows XP
and it works well. However, Windows 2000 Server machine cannot. I guess
VariantChangeType() is related to Windows OLE core so if OS doesn't support
it, there's no way but to wait for next upcoming Windows Update.
For workaround, recently, I made another function converting to VT_DECIMAL
to VT_I8 and vice versa, isolating VariantChangeType() for converting
between them. Of course, it is more generic way to find how
VariantChangeType() can convert them well.

Is there no way but to make another workaround function like below? The
other solutions? Please reply. Thanks in advance.

Bae, Hyun-jik

-----------------------

ADOVariant ToVariant(LONGLONG x)
{
DECIMAL d;
d.scale=0;
d.sign=0;
d.Hi32=0;
if(x<0)
{
d.sign=DECIMAL_NEG;
d.Lo64=-x;
}
else
{
d.sign=0;
d.Lo64=x;
}
_variant_t l=d;
return l;
}

ADOVariant ToVariant(ULONGLONG x)
{
DECIMAL d;
d.scale=0;
d.sign=0;
d.Hi32=0;
d.Lo64=x;
_variant_t l=d;
return l;
}

LONGLONG ToLongLong(const ADOVariant &r)
{
DECIMAL d=r;
if(d.scale!=0)
_com_issue_error(DISP_E_OVERFLOW);
if(d.sign!=0)
return -LONGLONG(d.Lo64);
else
return d.Lo64;
}

ULONGLONG ToULongLong(const ADOVariant &r)
{
DECIMAL d=r;
if(d.scale!=0)
_com_issue_error(DISP_E_OVERFLOW);
if(d.sign!=0)
return -LONGLONG(d.Lo64);
else
return d.Lo64;
}

0 mensajes nuevos