Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pointer to record

Status
Not open for further replies.

saif

Programmer
Mar 28, 2001
47
0
0
Hi everyone

I am trying to build a COM dll. can any body tell me what parameter type should be selected to get pointer to record?

Also how can i pass safearray to COM dll?

Thanks
Saif
 
A pointer (which is essentially the address) of a record can be found using the '@' operator.

So if you have the following:
[tt]
type
TMyFirstRecord = record
Field1 : integer;
end;

var
lMyRecord : TMyFirstRecord;
[/tt]

you should pass something like "@lMyrecord" as the parameter that requires the address.

SafeArrays:
Use a Variant array, and do something like this:
[tt]
var
lArray : Variant;
lpArray : PSafeArray;

{...sample code...}
{ Safe array of 4 integers = [7, 3, 4, 2]. }
lStateArray := VarArrayCreate( [0, 3], varInteger );
lStateArray[0] := 7;
lStateArray[1] := 3;
lStateArray[2] := 4;
lStateArray[3] := 2;

lpStateArray := PSafeArray(TVarData( lArray ).VArray );

[/tt]
 
Dear GreenKnight

your answer is not enough. The question is how I pass safearray to my COM component. whenever I tried to pass safearray to my COM compnent it gives me error "Type not allowed in Variant Dispatch call" at compile time. And my interface is derived from IUnknown.


And I know how can i get pointer of record but I want to know what type I should declare in my COM method so that it can get Pointer.


Saif

 
I think anything passed to a COM dll must be a pointer. Thus you would want to pass a PSafeArray into the dll, and also define it as a PSafeArray.

Are you writing this DLL, and defining the interface?
 
If you want to pass a pointer to your COM dll you should convert your pointer to OleVariant. Actually it's possible to pass a pointer as an Integer. You just can't pass Pointer types variables.

--- markus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top