Solved

Sending data using OLE interfaces

Posted on 1998-03-27
3
183 Views
Last Modified: 2010-04-06
I'm writing an ActiveX DLL and I need to send a data structure consisting of a number of classes in a linked list through it's interfaces.  How can I convert this into a data type that OLE can understand?
0
Comment
Question by:BigMadDrongo
3 Comments
 
LVL 4

Expert Comment

by:d003303
Comment Utility
Yo,
implement the IEnum interface and enumerate through the linked list. The classes you want to pass over should be COM objects with a type library. This as an ultra-short comment. If you have questions, just ask.

Slash/d003303
0
 
LVL 3

Accepted Solution

by:
williams2 earned 200 total points
Comment Utility
Delphi OLE has a strange understanding of arrays (linked lists). To assign an array to a OleVariant, you need to insert the elements into a TSafeArray. It's a generel suggestion due to the complex handling of variants. (please look up SafeArrays or TSafeArray in the Delphi Help index list). To send special objects, you can first build a record with all simple attributes and send them through the interface as a TSafeArray of Bytes (length = SizeOf(Record) ) and then reassemble the structure. Another approach is to use the class'es .SaveToStream/.LoadFromStream' methods which provides all necessary data in one structure. You could also use the .WriteComponent and .ReadComponent method.
Handling Objects with OLE is not trivial, and the solution generelly depends on which system you want do develop.

Regards
Williams
0
 

Author Comment

by:BigMadDrongo
Comment Utility
First you have to simplify a datastructure, so you will be able to trace your data's. Stringlists can be saved as one nullterminated string (use the getText function). Try putting all data's you have into one record. I can help you with these routines. I have tested them, and they work fine.

The Addr is the address pointer to the record. (Like ^Record).

  Function RecToOleVariant(Addr: Pointer; Const RSize: Word): OleVariant;
  var
    p: PByteArray;
    i: Integer;
  Begin
    Result:= VarArrayCreate([0, RSize-1], varByte);
    p:= Addr;
    For i:= 0 to RSize-1 do Result[i]:= p[i];
  End;

  Procedure OleVariantToRec(Data: OleVariant; addr: Pointer; RSize: Word);
  var
    p: PByteArray;
    i: Integer;
  Begin
    p:= addr;
    For i:= 0 to RSize-1 do p[i]:= Data[i];
  End;

When you use linked lists (chained lists), you should consider a record ID (Identifing a class) and build up your data by some recursive method.

If like to know more, please leave a comment.

Regards
Williams
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now