Solved

pointers, OLEVariant, Arrays of OLEVariant

Posted on 2001-09-13
4
1,454 Views
Last Modified: 2011-10-03
Can anybody point me to any documents which clearly explains how to use pointers with OLEVariant and Arrays of OLEVariant. I am being passed parameters of these types from a Server and need to extract the data that is being passed to my program. I am finding it all very confusing.

Thanks.
0
Comment
Question by:JohnMcGill
[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
4 Comments
 
LVL 9

Accepted Solution

by:
ITugay earned 100 total points
ID: 6479481
Hi JohnMcGill,

you can use typecasting to convert pointer to integer and back.

var
  V: OLEVariant;
  T: TEdit;

begin
  V := Integer(Edit1);

  TEdit(Integer(V)).Text := 'some text';
end;

----
Igor.
0
 
LVL 14

Assisted Solution

by:AvonWyss
AvonWyss earned 100 total points
ID: 6479560
Arrays passed along in OLE automation are often pointers to so-called safe arrays (PSafeArray). These are arrays of OLE-compatible variants (OLEVariant). If you get a pointer to a safe array, you can quickly convert it to a OLEVariant array and vice-versa:

function SafeArrayToVariant(SaveArray: PSafeArray): OleVariant;
begin
    TVarData(Result).VType:=varArray;
    TVarData(Result).VArray:=PVarArray(SaveArray);
end;

The other way around goes like this:

function VariantToSafeArray(const Arr: OleVariant): PSafeArray;
begin
   Assert(TVarData(Arr).VType=varArray);
   Result:=PSafeArray(TVarData(Arr).VArray);
end;

[...]
var
    Strings: OleVariant;
    Temp: PSafeArray;
[...]
    {I assume that Temp holds the PSafeArray)
    Strings:=SafeArrayToVariant(Temp);  

And when it is in the Variant, you can just use it like a normal Pascal array...:

   Edit1.Text:=Strings[0];  

Hope this helps!
0
 
LVL 17

Expert Comment

by:geobul
ID: 9307969
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

split points between ITugay and AvonWyss

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 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