?
Solved

Sending data using OLE interfaces

Posted on 1998-03-27
3
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Expert Comment

by:d003303
ID: 1360964
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 600 total points
ID: 1360965
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
ID: 1360966
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

800 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