Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sending data using OLE interfaces

Posted on 1998-03-27
3
Medium Priority
?
218 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

609 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