Link to home
Start Free TrialLog in
Avatar of jlaurin
jlaurin

asked on

How to resolve PSafeArray from dll

I have a dll wrapping a webservice call (C#.net).  
When I import the library to Delphi, the return type changes to PSafeArray.

Here's the signature from the TLB:
    procedure GetNumberRange(const connString: WideString; const nameCaller: WideString;
                             identCaller: Integer; const orderRef: WideString; countryCode: Word;
                             quantity: LongWord; oneRange: WordBool; numbers: PSafeArray); safecall;
Here's my call from Delphi (Same as an exmple I got here):
  a:  Variant;
begin
  bnds[0].LowBound := 0;
  bnds[0].ElementCount := 0;
  ws := CoResETag.Create();
  psa := SafeArrayCreate(varOLEStr,1,bnds);
 try
    ws.GetNumberRange(tbConnString.Text,tbNameCaller.Text,StrToInt(tbIdentCaller.Text),tbOrderRef.Text,     StrToInt(tbCountryCode.Text), StrToInt(tbQuantity.Text), true, psa);
/****/
I get:  Specified array was not of the expecting type  when executing this.
Help please
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

try this

var bound: TSafeArrayBound;
    sa: PSafeArray;

bound.lLbound := 0;
bound.cElements := 5;
sa := SafeArrayCreate(varVariant, 1, bound);

ziolko.
Avatar of jlaurin
jlaurin

ASKER

Nope.  Still getting the same error.
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin