![]() |
#1
|
|||
|
|||
![]()
I am using a third-party DLL which has a function that takes PSafeArray type as a parameter. Here is my code:
[DELPHI].................................................. ......... var Data : PSafeArray; begin oReader.Get_iSeADate(Data);[/DELPHI] Now how to retrieve the array values of "Data" variable? I tried this but I got a compiling error: Code:
Data[1].pvData; Abdulaziz Jasser |
#2
|
|||
|
|||
![]()
All is done through a variant, the PSafeArray isn't an array directly. The array is in the VArray.
Code:
var arr: Variant; i: Integer; begin TVarData(arr).VType := varOleStr OR varArray; TVarData(arr).VPointer:= Data; for i := VarArrayLowBound(arr, 1) to VarArrayHighBound(arr, 1) do Showmessage(arr[I]); Data := nil; end; There is no place like 127.0.0.1 |
#3
|
|||
|
|||
![]()
I got an error on the "Showmessage(arr[I]);". Do I have to do something with "Data: variable before passing it to the function that fill it with the data? I mean to I have to create it or initialize it? Also I am expecting integer values to filled in the "Data" variable. Does that make any difference? I am completely lost with PsafeArray. This is my first time to use it and I couldn’t find any help on the web.
Regards, Abdulaziz Jasser |
#4
|
|||
|
|||
![]()
Thanks Norrit for trying to help. But I found the solution my self. I don't need to use a “Variant” variable to retrieve the data from the array. I found some useful Delphi's function in the ActiveX unit that deals with SafeArray type. Here is a sample of my code:
.................................................. ......... var Data : PSafeArray; i : Integer; iLow, iHigh : Integer; iValue : Integer; begin oReader.Get_iSeADate(Data); SafeArrayGetLBound(Data,1,iLow); SafeArrayGetUBound(Data,1,iHigh); for i:=iLow to iHigh do begin SafeArrayGetElement(Data,i,iValue); Showmessage( IntToStr(iValue) ); end; Regards, Abdulaziz Jasser |
![]() |
Thread Tools | |
Display Modes | |
|
|