Solved

Passing structure in COM

Posted on 2002-06-02
7
221 Views
Last Modified: 2010-04-02
Hi,
Can I transfer my defined structure or a pointer to my structure as a COM paramter. I think that the user can recognize it from idl.
Thanks !
0
Comment
Question by:yonit
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:Chase707
ID: 7049597
yes,

in the idl file:

typedef struct MY_STRUCT
{
    int mystuff;
} MY_STRUCT;
...
interface IMyInterface : IUknown
{
   HRESULT myMethod( [in] MY_STRUCT* pStruct);
}
...

then just implement it in your component as normal.

Chase707
0
 

Accepted Solution

by:
vcppmfc earned 50 total points
ID: 7050350
Hi Chase707

Its right , but then i think you cann't access this structure in scripting language like VB.OR this structure should be marshaled proferly.
0
 

Author Comment

by:yonit
ID: 7050387
What can be done for VB?
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 4

Expert Comment

by:Chase707
ID: 7050394
In VB you can just define the structure using VB conventions before you call the method.  I do not know the VB language well, so I do not recall the exact syntax.

I think it's something like:
...
Type MY_STRUCT
   stuff as int
End Type
...

As long as your struct contains only Automation compatible types  (those defined in the VARIANT enum), then IDL will handle the details of marshalling your structures across processes.

0
 

Author Comment

by:yonit
ID: 7050408
Sorry. I ment to give the points to Chase707. Can it be changed ???
0
 
LVL 4

Expert Comment

by:Chase707
ID: 7050420
I'm not sure about changing it, but you can create another question called 'points for Chase707'.  Then when I post an answer, you can then accept it.  It will end up costing you 50 more points though.

Chase707
0
 

Author Comment

by:yonit
ID: 7050428
I will
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question