| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"Claus77" |
| Date: |
23 Oct 2006 03:30:03 AM |
| Object: |
VARIANT type |
Hi there,
I've got a little problem with the following:
I'm just writing a com-application in C++ with VS-6, which should also
be
used with VB-Script, so I have to use variables of type VARIANT in my
functions in order to get no problems with VB-Script.
I try to transform them into C++-Variables somehow like this:
function a(VARIANT var)
bstr ch = var.bstr;
But C++ only puts the first character of the string into my variable
ch... Why?
What have I done wrong?
Thanks for your help,
Claus
.
|
|
| User: "Jim Langston" |
|
| Title: Re: VARIANT type |
23 Oct 2006 03:52:44 AM |
|
|
"Claus77" <cmassion@web.de> wrote in message
news:1161592203.696547.28250@h48g2000cwc.googlegroups.com...
Hi there,
I've got a little problem with the following:
I'm just writing a com-application in C++ with VS-6, which should also
be
used with VB-Script, so I have to use variables of type VARIANT in my
functions in order to get no problems with VB-Script.
I try to transform them into C++-Variables somehow like this:
function a(VARIANT var)
bstr ch = var.bstr;
But C++ only puts the first character of the string into my variable
ch... Why?
What have I done wrong?
Thanks for your help,
Claus
How is VARIANT defined?
How is bstr defined?
.
|
|
|
| User: "Claus77" |
|
| Title: Re: VARIANT type |
23 Oct 2006 04:12:01 AM |
|
|
How is VARIANT defined?
you mean this?:
typedef /* [wire_marshal] */ struct tagVARIANT VARIANT;
struct tagVARIANT
{
union
{
struct __tagVARIANT
{
VARTYPE vt;
WORD wReserved1;
WORD wReserved2;
WORD wReserved3;
union
{
LONGLONG llVal;
LONG lVal;
BYTE bVal;
SHORT iVal;
FLOAT fltVal;
DOUBLE dblVal;
VARIANT_BOOL boolVal;
_VARIANT_BOOL bool;
SCODE scode;
CY cyVal;
DATE date;
BSTR bstrVal;
IUnknown *punkVal;
IDispatch *pdispVal;
SAFEARRAY *parray;
BYTE *pbVal;
SHORT *piVal;
LONG *plVal;
LONGLONG *pllVal;
FLOAT *pfltVal;
DOUBLE *pdblVal;
VARIANT_BOOL *pboolVal;
_VARIANT_BOOL *pbool;
SCODE *pscode;
CY *pcyVal;
DATE *pdate;
BSTR *pbstrVal;
IUnknown **ppunkVal;
IDispatch **ppdispVal;
SAFEARRAY **pparray;
VARIANT *pvarVal;
PVOID byref;
CHAR cVal;
USHORT uiVal;
ULONG ulVal;
ULONGLONG ullVal;
INT intVal;
UINT uintVal;
DECIMAL *pdecVal;
CHAR *pcVal;
USHORT *puiVal;
ULONG *pulVal;
ULONGLONG *pullVal;
INT *pintVal;
UINT *puintVal;
struct __tagBRECORD
{
PVOID pvRecord;
IRecordInfo *pRecInfo;
} __VARIANT_NAME_4;
} __VARIANT_NAME_3;
} __VARIANT_NAME_2;
DECIMAL decVal;
} __VARIANT_NAME_1;
} ;
How is bstr defined?
bstr is a wchar_t*
.
|
|
|
|
|
| User: "Jim Langston" |
|
| Title: Re: VARIANT type |
23 Oct 2006 06:09:25 AM |
|
|
"Claus77" <cmassion@web.de> wrote in message
news:1161592203.696547.28250@h48g2000cwc.googlegroups.com...
Hi there,
I've got a little problem with the following:
I'm just writing a com-application in C++ with VS-6, which should also
be
used with VB-Script, so I have to use variables of type VARIANT in my
functions in order to get no problems with VB-Script.
I try to transform them into C++-Variables somehow like this:
function a(VARIANT var)
bstr ch = var.bstr;
In the definition of VARIANT you gave me, there is no bstr. So how can you
be using var.bst if bstr is not defined within VARIENT?
In the definition of bstr you gave me, it is a wchar_t*, or a wide char
pointer. So it would seem that you are assinging the pointer ch to point to
whatever bstr is, which is probably another wchar_t. You haven't copied
anything though.
You need to look at thwat bstr is pointing to, the text string I'm fairly
sure, but is it null terminated? If not, you need to get the length out of
your var and determine how long it is.
So basically what you want to do is copy the text that bstr is pointing to
into some C++ type string. I would probably go with a std::string, but you
could go with a char array. Then copy the contents. Since you haven't
given me a full defintion of VARIANT I can't help you with where the length
is stored in VARIANT.
Consider asking in a windows newsgroup if you can't figure it out.
But C++ only puts the first character of the string into my variable
ch... Why?
What have I done wrong?
Thanks for your help,
Claus
.
|
|
|
| User: "Claus77" |
|
| Title: Re: VARIANT type |
24 Oct 2006 03:43:43 AM |
|
|
ah, i've got it now on my own... thanks for your help,
if someone is interested in the solution, i can post it here...
greets,
claus
.
|
|
|
|
|

|
Related Articles |
|
|