Board index » cppbuilder » VARIANT-TVariant

VARIANT-TVariant

Suppose that you want pass a bitmap data (or a generic stream bytes) to
client from out-of-process server COM , how can you do? The Borland Builder
5 documentation says: ... the type library editor supports the following IDL
types in a type library:

IDL TYPE: void
VARIANT TYPE: VT_VOID
Automation compatible: YES

I've try to:

void* p = CoTaskMemAlloc( 500 );
TVariant v = p  ( doesn't work );

void* p = CoTaskMemAlloc( 500 );
TVariant v;
v.vt = VT_VOID;
v.pvRecord = p;  ( compile and link but doesn't work );

Do you have any idea? Thanks in advance for any help

 

Re:VARIANT-TVariant


Hopefully, this helps.

void* p = CoTaskMemAlloc( 500 );
TVariant v;
v.byref = p;

This should work.

  Sherwin

By the way:
Here is my quick test:

//BEGIN TEST***********/
#include "utilcls.h"

void SomeFunc()
{
  void* p = CoTaskMemAlloc( 500 );
  TVariant v;

  char * text_str = "Hello World!";
  p = text_str;
  v.byref = p;
  ShowMessage((const char *)v.byref );

Quote
}

//END TEST***********/
Quote
"Mauro Tronto" <mauro.tro...@telecomitalia.it> wrote:
>Suppose that you want pass a bitmap data (or a generic stream bytes) to
>client from out-of-process server COM , how can you do? The Borland Builder
>5 documentation says: ... the type library editor supports the following IDL
>types in a type library:

>IDL TYPE: void
>VARIANT TYPE: VT_VOID
>Automation compatible: YES

>I've try to:

>void* p = CoTaskMemAlloc( 500 );
>TVariant v = p  ( doesn't work );

>void* p = CoTaskMemAlloc( 500 );
>TVariant v;
>v.vt = VT_VOID;
>v.pvRecord = p;  ( compile and link but doesn't work );

>Do you have any idea? Thanks in advance for any help

Re:VARIANT-TVariant


Thanks for the quickly response, but the problem is when you marshaling the
code. In the client I don't receive the void data that I've try to pass by
the COM server. In your example you show the data by the showmessage. I have
write the same code in my COM server BEFORE return from method, and I show
the void data correct.

Look the example below (SERVER COM SIDE)

STDMETHODIMP CMauro::prendi_map(VARIANT* mymap)
{
    void* p = CoTaskMemAlloc( 100 );

    strcpy( (char*)p, "Borland C++ Builder" );
    mymap->vt    = VT_BYREF;
    mymap->byref = p;

    ShowMessage(  (char*)mymap->byref );        // This work correctly year,
in the server side!

    return S_OK;   // when marshaling data, I don't receive data in the
client

Quote
}

"sdh" <s...@sdh.com> ha scritto nel messaggio news:3b4d9b2d$1_1@dnews...
Quote

> Hopefully, this helps.

> void* p = CoTaskMemAlloc( 500 );
> TVariant v;
> v.byref = p;

> This should work.

>   Sherwin

> By the way:
> Here is my quick test:

> //BEGIN TEST***********/
> #include "utilcls.h"

> void SomeFunc()
> {
>   void* p = CoTaskMemAlloc( 500 );
>   TVariant v;

>   char * text_str = "Hello World!";
>   p = text_str;
>   v.byref = p;
>   ShowMessage((const char *)v.byref );
> }
> //END TEST***********/

> "Mauro Tronto" <mauro.tro...@telecomitalia.it> wrote:
> >Suppose that you want pass a bitmap data (or a generic stream bytes) to
> >client from out-of-process server COM , how can you do? The Borland
Builder
> >5 documentation says: ... the type library editor supports the following
IDL
> >types in a type library:

> >IDL TYPE: void
> >VARIANT TYPE: VT_VOID
> >Automation compatible: YES

> >I've try to:

> >void* p = CoTaskMemAlloc( 500 );
> >TVariant v = p  ( doesn't work );

> >void* p = CoTaskMemAlloc( 500 );
> >TVariant v;
> >v.vt = VT_VOID;
> >v.pvRecord = p;  ( compile and link but doesn't work );

> >Do you have any idea? Thanks in advance for any help

Other Threads