• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1228
  • Last Modified:

Delphi, OleVariant shows as Unknown type: 18928

I have an Activex component that I'm calling from Delphi, in VB the return value that i'm looking for is easy to read
Private Sub m_rs_onReportCreationNotification(ByVal repordId As String, orderIds() As String, examIds() As String, ByVal succeeded As Boolean)
    On Error GoTo ErrorHandler
   
    Dim order, exam As Variant
    Dim logorders, logexams, state As String
   
    For Each order In orderIds
       logorders = logorders + order + ", "
    Next


In Delphi

procedure TForm4.ReportStation1onReportCreationNotification(ASender: TObject;
  const a_sReportId: WideString; var a_asOrderIds, a_psExamIds: OleVariant;
  a_bSucceeded: WordBool);
begin

The a_asOrderIds show as Variant Array of uknown.

How do I get to the values inside a_asOrderIds?

0
peterviau
Asked:
peterviau
1 Solution
 
ThievingSixCommented:
You might want to use VarCast()/VarCastOLE()/VariantToDynArrat()

VarToDynArray: procedure(var DynArray: Pointer; const V: Variant; TypeInfo: Pointer);
VarCast: procedure(var Dest: Variant; const Source: Variant; VarType: Integer);
VarCastOle: procedure(var Dest: Variant; const Source: Variant; VarType: Integer);

So something like(I have never actually tryed this):

var VAOrderIDS Array of String

VarToDynArray(@VAOrderIDS,a_asOrderIds);

Then access VAOrderIDS.

This is all in theory of course.


0
 
peterviauAuthor Commented:
Unfortunatly VarToDynArray is a free pascal function call, I did not find anything like it in Delphi.
0
 
ThievingSixCommented:
Include Variants in your uses. I found it in delphi 7.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
ziolkoCommented:
ry this:

  if VarIsArray(a_asOrderIds) then
    for cnt := VarArrayLowBound(a_asOrderIds, 1) to VarArrayHighBound(a_asOrderIds, 1) do
      s := s + VarToStr(a_asOrderIds[cnt]);
  ShowMessage(s);


ziolko.
0
 
peterviauAuthor Commented:
I ended up switching to Delphi .net, it allowed em to use array of string.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now