?
Solved

pointers, OLEVariant, Arrays of OLEVariant

Posted on 2001-09-13
4
Medium Priority
?
1,470 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 400 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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

649 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