Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by tomer dro » Sun, 18 Jul 1999 04:00:00



(please reply to the newgroup-thanks)

Hi,
Does visual basic can use custom only interface..?
I declare the following in my IDL

typedef struct tagSTRUCTURE
{
     int nVal;
     struct tagSTRUCTURE *pNext;

Quote:}STRUCTURE;

interface IDataStore : IUnknown
{
  [helpstring("method GetStructureList")] HRESULT GetStructureList([out]
STRUCTURE **pStructureList);

Quote:};

1.How do i use it from visual basic..?
2.How do use TYPE to declare such a structure in visual basic..?
  (circular dependencies..!!)

thanks

tomer

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Alexander Nickolo » Mon, 19 Jul 1999 04:00:00


You can't because the structure contains Automation-incompatible
type (pointer to another structure).

BTW, this is inefficient anyway - encapsulate the linked list in an
object of itself and manipulate it as ADT (abstract data type).
Then you only pass IUnknown or IDispatch or its primary
interface.

--
===============================
Alexander Nickolov, MCP
Panasonic Technologies Inc.
Speech Technology Laboratory

===============================


Quote:> (please reply to the newgroup-thanks)

> Hi,
> Does visual basic can use custom only interface..?
> I declare the following in my IDL

> typedef struct tagSTRUCTURE
> {
>      int nVal;
>      struct tagSTRUCTURE *pNext;
> }STRUCTURE;

> interface IDataStore : IUnknown
> {
>   [helpstring("method GetStructureList")] HRESULT GetStructureList([out]
> STRUCTURE **pStructureList);
> };

> 1.How do i use it from visual basic..?
> 2.How do use TYPE to declare such a structure in visual basic..?
>   (circular dependencies..!!)

> thanks

> tomer


 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by tomer dro » Tue, 20 Jul 1999 04:00:00


(please reply to the newgroup-thanks)

Alexander...why does the structure need to contain ole automation compatible
types,i am not using type library marshalling..!!??

thanks

tomer
korpro

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Alexander Nickolo » Tue, 20 Jul 1999 04:00:00


VB requires this. It reads it only through the type library and also, you
cannot represent pointer in VB AFAIK...

--
===============================
Alexander Nickolov, MCP
Panasonic Technologies Inc.
Speech Technology Laboratory

===============================


>(please reply to the newgroup-thanks)

>Alexander...why does the structure need to contain ole automation
compatible
>types,i am not using type library marshalling..!!??

>thanks

>tomer
>korpro

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Alexander Nickolo » Tue, 20 Jul 1999 04:00:00


Ah, I finally looked up the title of your original question :)...
Yes, VB can use custom interfaces provided the data types in all
methods are Automation compatible. If they are not, but can be
represented with close resemblants (like BOOL and DWORD
becoming long), then you describe a VB friendly version in a
type library with all types replaced with Automation ones. The
original interface must not be represented via type library and
the declaration must NOT include oleautomation (so the TLB
doesn't override the original marshaling support, but if it can
truly be rewritten this way, the Automation marshaling should
be ok too...). This all happens in a completely independent
IDL of course. But I'd advise against doing this! Better design
your interface with Automation compatible types only.

--
===============================
Alexander Nickolov, MCP
Panasonic Technologies Inc.
Speech Technology Laboratory

===============================


>VB requires this. It reads it only through the type library and also, you
>cannot represent pointer in VB AFAIK...

>--
>===============================
>Alexander Nickolov, MCP
>Panasonic Technologies Inc.
>Speech Technology Laboratory

>===============================


>>(please reply to the newgroup-thanks)

>>Alexander...why does the structure need to contain ole automation
>compatible
>>types,i am not using type library marshalling..!!??

>>thanks

>>tomer
>>korpro

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Marce » Wed, 21 Jul 1999 04:00:00


Hi, I've vbeen following your discussion, and I've got a question about the
usage of structs.
I want to use a struct containing only automation compatible types, like:

typedef tagMyStruct
{
    BSTR MyBstr;
    DATE MyDate;
    BOOL MyBool;

Quote:} MyStruct, *LPMyStruct

and use this as a method parameter, like :

interface IMyInterface : IDispatch
{
    [helpstring("method Notes")] HRESULT Notes([in] MyStruct InStruct, [out]
LPMyStruct OutStruct);

Quote:};

Is this possible, and if so, how can I access this from VB or VBA?

Marcel

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by tomer dro » Wed, 21 Jul 1999 04:00:00


(please replay to the newgroup-since i want to read your mail.. :)

As alexander said
you should create you structure as COM object
whice derived from IDispatch,and expose the structure's member as
properties,
this insure that you can use it either with VB and VBA(Script language)

if you only want to use from VB you can use custom interface(MIDL will
create the marshalling code for you)

tomer
korpro

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Marce » Wed, 21 Jul 1999 04:00:00



>(please replay to the newgroup-since i want to read your mail.. :)

I thought I did?!?

Quote:

>As alexander said
>you should create you structure as COM object
>whice derived from IDispatch,and expose the structure's member as
>properties,
>this insure that you can use it either with VB and VBA(Script language)

No, I want to use a struct to prevent network roundtrips. If I create a COM
object and supply all members as properties, each property access causes a
roundtrip, while, when I pass these members as a struct it takes just one
roiundtrip for the whole bunch.
I can compile an IDL file, and a COM project, using this technique, but It
seems that the members of the struct aren't available in VB.
Alexander ment to encapsulate the linked list in an object.
Quote:

>if you only want to use from VB you can use custom interface(MIDL will
>create the marshalling code for you)

>tomer
>korpro

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Jeff Koh » Wed, 21 Jul 1999 04:00:00



Quote:> Hi, I've vbeen following your discussion, and I've got a question about
the
> usage of structs.
> I want to use a struct containing only automation compatible types, like:

> typedef tagMyStruct
> {
>     BSTR MyBstr;
>     DATE MyDate;
>     BOOL MyBool;
> } MyStruct, *LPMyStruct

> and use this as a method parameter, like :

> interface IMyInterface : IDispatch
> {
>     [helpstring("method Notes")] HRESULT Notes([in] MyStruct InStruct,
[out]
> LPMyStruct OutStruct);
> };

> Is this possible, and if so, how can I access this from VB or VBA?

This should work fine as long as the struct is defined in the IDL and is
included in the type library. Here's an example from one of my IDL files:

 // EmployeeUDT struct
 typedef [ uuid (E57180A0-FD16-11d2-A834-000000000000) ]
 struct EmployeeUDT
 {
  LONG ID;
  BSTR FirstName;
  BSTR MiddleInitial;
  BSTR LastName;
  LONG DepartmentID;
  BSTR PagerPIN;
  BSTR MobileNumber;
  BSTR Email;
 } EmployeeUDT;

I'm not sure if the uuid is required or not, but that's how VB does it if
you declare a public type in a class module (i.e. a struct). Also not that
the struct has to either be declared or referenced inside the library
statement to get included in the typelib.

Jeff

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Alexander Nickolo » Wed, 21 Jul 1999 04:00:00


That's correct. The uuid is required for the IRecordInfo interface
implemented by Automation for marshaling the struct. This works
with NT4 SP4 or greater and Win95/98 DCOM 1.3 or greater.
The older Automation marshalers don't recognize structs. And
of course, the structure must be declared somehow in the TLB
so a reference is mandatory (but it usually is referenced in some
of the methods of your interface on your coclass, so it gets there).

To the original poster: BOOL is not an automation type. It is
actually long and you better put that to reduce confusion, or use
the Automation logical type VARIANT_BOOL.

--
===============================
Alexander Nickolov, MCP
Panasonic Technologies Inc.
Speech Technology Laboratory

===============================




>> Hi, I've vbeen following your discussion, and I've got a question about
>the
>> usage of structs.
>> I want to use a struct containing only automation compatible types, like:

>> typedef tagMyStruct
>> {
>>     BSTR MyBstr;
>>     DATE MyDate;
>>     BOOL MyBool;
>> } MyStruct, *LPMyStruct

>> and use this as a method parameter, like :

>> interface IMyInterface : IDispatch
>> {
>>     [helpstring("method Notes")] HRESULT Notes([in] MyStruct InStruct,
>[out]
>> LPMyStruct OutStruct);
>> };

>> Is this possible, and if so, how can I access this from VB or VBA?

>This should work fine as long as the struct is defined in the IDL and is
>included in the type library. Here's an example from one of my IDL files:

> // EmployeeUDT struct
> typedef [ uuid (E57180A0-FD16-11d2-A834-000000000000) ]
> struct EmployeeUDT
> {
>  LONG ID;
>  BSTR FirstName;
>  BSTR MiddleInitial;
>  BSTR LastName;
>  LONG DepartmentID;
>  BSTR PagerPIN;
>  BSTR MobileNumber;
>  BSTR Email;
> } EmployeeUDT;

>I'm not sure if the uuid is required or not, but that's how VB does it if
>you declare a public type in a class module (i.e. a struct). Also not that
>the struct has to either be declared or referenced inside the library
>statement to get included in the typelib.

>Jeff

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Alexander Nickolo » Wed, 21 Jul 1999 04:00:00


Quote:>Alexander ment to encapsulate the linked list in an object.

Exactly. Read my reply on the other subthread.

--
===============================
Alexander Nickolov, MCP
Panasonic Technologies Inc.
Speech Technology Laboratory

===============================

[snip]

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Marce » Thu, 22 Jul 1999 04:00:00


Thanx, I knew it should work. Have to upgrade my DCOM then.


>That's correct. The uuid is required for the IRecordInfo interface
>implemented by Automation for marshaling the struct. This works
>with NT4 SP4 or greater and Win95/98 DCOM 1.3 or greater.
>The older Automation marshalers don't recognize structs. And
>of course, the structure must be declared somehow in the TLB
>so a reference is mandatory (but it usually is referenced in some
>of the methods of your interface on your coclass, so it gets there).

>To the original poster: BOOL is not an automation type. It is
>actually long and you better put that to reduce confusion, or use
>the Automation logical type VARIANT_BOOL.

>--
>===============================
>Alexander Nickolov, MCP
>Panasonic Technologies Inc.
>Speech Technology Laboratory

>===============================




>>> Hi, I've vbeen following your discussion, and I've got a question about
>>the
>>> usage of structs.
>>> I want to use a struct containing only automation compatible types,
like:

>>> typedef tagMyStruct
>>> {
>>>     BSTR MyBstr;
>>>     DATE MyDate;
>>>     BOOL MyBool;
>>> } MyStruct, *LPMyStruct

>>> and use this as a method parameter, like :

>>> interface IMyInterface : IDispatch
>>> {
>>>     [helpstring("method Notes")] HRESULT Notes([in] MyStruct InStruct,
>>[out]
>>> LPMyStruct OutStruct);
>>> };

>>> Is this possible, and if so, how can I access this from VB or VBA?

>>This should work fine as long as the struct is defined in the IDL and is
>>included in the type library. Here's an example from one of my IDL files:

>> // EmployeeUDT struct
>> typedef [ uuid (E57180A0-FD16-11d2-A834-000000000000) ]
>> struct EmployeeUDT
>> {
>>  LONG ID;
>>  BSTR FirstName;
>>  BSTR MiddleInitial;
>>  BSTR LastName;
>>  LONG DepartmentID;
>>  BSTR PagerPIN;
>>  BSTR MobileNumber;
>>  BSTR Email;
>> } EmployeeUDT;

>>I'm not sure if the uuid is required or not, but that's how VB does it if
>>you declare a public type in a class module (i.e. a struct). Also not that
>>the struct has to either be declared or referenced inside the library
>>statement to get included in the typelib.

>>Jeff

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Tim Roger » Wed, 04 Aug 1999 04:00:00


Can someone explain to me what automation compliant means?  Does it mean it
is explicitly declared as a member of VARIANT, or can it mean an
object/interface derived from an explicit member of VARIANT?  My reason is
we are trying to stream files.  We have used a SAFEARRAY embedded in a
VARIANT and IStream.  IStream appears faster (not the issue here), but we
are concerned that IStream is not automation-compliant.  IStream derives
from IUnknown (duh), so does that mean it is automation compliant if we put
it in a VARIANT via the IUnknown*?  Our concern is being able to use our
objects whose interfaces define methods that have VARIANTS (with an
IUnknown* part of an IStream*) in VB, ASP, etc.  Any responses would be
appreciated.

Thanks,

Tim Rogers


>Ah, I finally looked up the title of your original question :)...
>Yes, VB can use custom interfaces provided the data types in all
>methods are Automation compatible. If they are not, but can be
>represented with close resemblants (like BOOL and DWORD
>becoming long), then you describe a VB friendly version in a
>type library with all types replaced with Automation ones. The
>original interface must not be represented via type library and
>the declaration must NOT include oleautomation (so the TLB
>doesn't override the original marshaling support, but if it can
>truly be rewritten this way, the Automation marshaling should
>be ok too...). This all happens in a completely independent
>IDL of course. But I'd advise against doing this! Better design
>your interface with Automation compatible types only.

>--
>===============================
>Alexander Nickolov, MCP
>Panasonic Technologies Inc.
>Speech Technology Laboratory

>===============================


>>VB requires this. It reads it only through the type library and also, you
>>cannot represent pointer in VB AFAIK...

>>--
>>===============================
>>Alexander Nickolov, MCP
>>Panasonic Technologies Inc.
>>Speech Technology Laboratory

>>===============================


>>>(please reply to the newgroup-thanks)

>>>Alexander...why does the structure need to contain ole automation
>>compatible
>>>types,i am not using type library marshalling..!!??

>>>thanks

>>>tomer
>>>korpro

 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Girish Bharadwaj[mv » Thu, 05 Aug 1999 04:00:00


automation compliant means the datatype used must be one of the
VARIANT.VTTYPEs. ie. it should be stuffable into a variant. In case of
IStream, sadly, that is not the case. i.e. Even though IStream is
derived from IUnknown, IStream itself is not automation compliant.
Hence, MIDL will complain about that. So, one way to go would be to
make an MBV object out of it and stuff that info into that. And make
that MBV object, automation compliant.
Or, you can send that SAFEARRAY itself.

On Tue, 3 Aug 1999 22:18:33 -0400, "Tim Rogers"


>Can someone explain to me what automation compliant means?  Does it mean it
>is explicitly declared as a member of VARIANT, or can it mean an
>object/interface derived from an explicit member of VARIANT?  My reason is
>we are trying to stream files.  We have used a SAFEARRAY embedded in a
>VARIANT and IStream.  IStream appears faster (not the issue here), but we
>are concerned that IStream is not automation-compliant.  IStream derives
>from IUnknown (duh), so does that mean it is automation compliant if we put
>it in a VARIANT via the IUnknown*?  Our concern is being able to use our
>objects whose interfaces define methods that have VARIANTS (with an
>IUnknown* part of an IStream*) in VB, ASP, etc.  Any responses would be
>appreciated.

>Thanks,

>Tim Rogers


>>Ah, I finally looked up the title of your original question :)...
>>Yes, VB can use custom interfaces provided the data types in all
>>methods are Automation compatible. If they are not, but can be
>>represented with close resemblants (like BOOL and DWORD
>>becoming long), then you describe a VB friendly version in a
>>type library with all types replaced with Automation ones. The
>>original interface must not be represented via type library and
>>the declaration must NOT include oleautomation (so the TLB
>>doesn't override the original marshaling support, but if it can
>>truly be rewritten this way, the Automation marshaling should
>>be ok too...). This all happens in a completely independent
>>IDL of course. But I'd advise against doing this! Better design
>>your interface with Automation compatible types only.

>>--
>>===============================
>>Alexander Nickolov, MCP
>>Panasonic Technologies Inc.
>>Speech Technology Laboratory

>>===============================


>>>VB requires this. It reads it only through the type library and also, you
>>>cannot represent pointer in VB AFAIK...

>>>--
>>>===============================
>>>Alexander Nickolov, MCP
>>>Panasonic Technologies Inc.
>>>Speech Technology Laboratory

>>>===============================


>>>>(please reply to the newgroup-thanks)

>>>>Alexander...why does the structure need to contain ole automation
>>>compatible
>>>>types,i am not using type library marshalling..!!??

>>>>thanks

>>>>tomer
>>>>korpro

Girish Bharadwaj [mvp].
Please do not email queries to me.
Post them in newsgroups.
Thank you.
 
 
 

Can VB 6.0 use custom only interface..??+VB TYPE circular dependencies.

Post by Alexander Nickolo » Thu, 05 Aug 1999 04:00:00


Or simply send IUnknown through the interface (to satisfy the Automation
marshaler) and QI at the client for IStream. Of course that's additional
network roundtrip...

--
===============================
Alexander Nickolov, MCP
Panasonic Technologies Inc.
Speech Technology Laboratory

===============================


>automation compliant means the datatype used must be one of the
>VARIANT.VTTYPEs. ie. it should be stuffable into a variant. In case of
>IStream, sadly, that is not the case. i.e. Even though IStream is
>derived from IUnknown, IStream itself is not automation compliant.
>Hence, MIDL will complain about that. So, one way to go would be to
>make an MBV object out of it and stuff that info into that. And make
>that MBV object, automation compliant.
>Or, you can send that SAFEARRAY itself.

>On Tue, 3 Aug 1999 22:18:33 -0400, "Tim Rogers"

>>Can someone explain to me what automation compliant means?  Does it mean
it
>>is explicitly declared as a member of VARIANT, or can it mean an
>>object/interface derived from an explicit member of VARIANT?  My reason is
>>we are trying to stream files.  We have used a SAFEARRAY embedded in a
>>VARIANT and IStream.  IStream appears faster (not the issue here), but we
>>are concerned that IStream is not automation-compliant.  IStream derives
>>from IUnknown (duh), so does that mean it is automation compliant if we
put
>>it in a VARIANT via the IUnknown*?  Our concern is being able to use our
>>objects whose interfaces define methods that have VARIANTS (with an
>>IUnknown* part of an IStream*) in VB, ASP, etc.  Any responses would be
>>appreciated.

>>Thanks,

>>Tim Rogers


>>>Ah, I finally looked up the title of your original question :)...
>>>Yes, VB can use custom interfaces provided the data types in all
>>>methods are Automation compatible. If they are not, but can be
>>>represented with close resemblants (like BOOL and DWORD
>>>becoming long), then you describe a VB friendly version in a
>>>type library with all types replaced with Automation ones. The
>>>original interface must not be represented via type library and
>>>the declaration must NOT include oleautomation (so the TLB
>>>doesn't override the original marshaling support, but if it can
>>>truly be rewritten this way, the Automation marshaling should
>>>be ok too...). This all happens in a completely independent
>>>IDL of course. But I'd advise against doing this! Better design
>>>your interface with Automation compatible types only.

>>>--
>>>===============================
>>>Alexander Nickolov, MCP
>>>Panasonic Technologies Inc.
>>>Speech Technology Laboratory

>>>===============================


>>>>VB requires this. It reads it only through the type library and also,
you
>>>>cannot represent pointer in VB AFAIK...

>>>>--
>>>>===============================
>>>>Alexander Nickolov, MCP
>>>>Panasonic Technologies Inc.
>>>>Speech Technology Laboratory

>>>>===============================


>>>>>(please reply to the newgroup-thanks)

>>>>>Alexander...why does the structure need to contain ole automation
>>>>compatible
>>>>>types,i am not using type library marshalling..!!??

>>>>>thanks

>>>>>tomer
>>>>>korpro

>Girish Bharadwaj [mvp].
>Please do not email queries to me.
>Post them in newsgroups.
>Thank you.