🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #3020

Import Interface to a Variant

#3020
From: George Adamopoulos
Date: Mon, 03 Feb 2003 16:24
54 lines
2959 bytes
I would like to pack an interface to a variant in order to communicate with
an
existing COM Dll ( implemented using DELPHI ).

SAFEARRAY   *pSafeArray;                     // Declaring a SafeArray
Variant StoreParamsVar;                             // Declaring a Variant
SAFEARRAYBOUND abound[1];            // Declaring the bounds and elements of
the array

IDispatch *pdisp = NULL;                         // Dispatch Type

abound[0].lLbound = 0;                              // Array Bounds &
Elements
abound[0].cElements = 1;

IitPMtoOWStoreFromProdParams  *spProdParams;                        // This
is the COM Interface
spProdParams = CoitPMtoOWStoreFromProdParams::Create();      // Instatiation
of the COM Object

pSafeArray =::SafeArrayCreate(VT_DISPATCH, 1, abound);
// An Array of Type Dispatch
pSafeArray->fFeatures = FADF_AUTO | FADF_DISPATCH | 0x0040;

for (long i = ZERO_VALUE; i < ONE_VALUE; i++)

{
// filling the interface with Values
        spProdParams->nRequestSeries  = CStrInf.ReqSeries;
        spProdParams->nRequestID      = CStrInf.ReqID;
        spProdParams->dQtyScrapped    = ZERO_VALUE;
        spProdParams->dQtyShipped     = ZERO_VALUE;

        spProdParams->nCostCenter     = (*dbwrhouse)->WRHID;
        spProdParams->nProdMType      = (*dbobjects)->OBProdMType;
        spProdParams->nProductID      = (*dbobjects)->OBProduct;

        spProdParams->QueryInterface(IID_IDispatch, (void**)&pdisp);
// Querying Interface
        spProdParams->AddRef();
        SafeArrayPutElement(pSafeArray, &i, &spProdParams);
// Inserting Interface to SafeArray
    }

StoreParamsVar.vt = VT_DISPATCH | VT_ARRAY;
StoreParamsVar.parray = pSafeArray;

When the program reaches the QueryInterface line produces an access
violation error.
What I am really interesting is to find HOW CAN I INSERT AN INTERFACE OR A
STRUCTURE TO A VARIANT using C++ Builder.
Any suggestions are welcome.

Thanks in Advance.
Technical Details
Message-ID: <3e3d4596@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,232d2c9933760c33,start
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-02-02 08:26:05 PST
Reply-To: "George Adamopoulos" <cosmic20@teledomenet.gr>
From: "George Adamopoulos" <cosmic20@teledomenet.gr>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Import Interface to a Variant
Date: Mon, 3 Feb 2003 18:24:39 +0200
Lines: 56
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 213.142.132.85
Message-ID: <3e3d4596@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1044202902 213.142.132.85 (2 Feb 2003 08:21:42 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail