Solved

problem on DCOM application?

Posted on 2002-04-15
4
191 Views
Last Modified: 2013-11-20
sir,
   I have created DCom application using win98 as a server and client as win2000.
I want to pass array of strings using variant and safearry.
My problem is that when iam passing VT_ARRAY  from the client after initializing ,but the server is recieving as VT_EMPTY.

actually i want retrieve array of strings from the server .using VARIANT and SAFEARRAY.
so please kindly solve this problem ,rectify and give me the datails.
          from
           sudhaonlinemail@yahoo.com
0
Comment
Question by:venkaiah
4 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6942971
First you say that you are passing VT_ARRAY from the client to the server, but then you say that you want to send the array from the server to the client.  Which is it?

Are you able to pass other data types successfully?

Please post the code that is failing.

-- Dan
0
 

Accepted Solution

by:
Biffa earned 100 total points
ID: 8444971
The structure I normally use for passing arrays of string across COM interfaces is A VARIANT containing a SAFEARRAY of BSTR.  The use of these types in my applications is restricted because I need to keep compatibility with Automation data types, but this structure is a good, flexible, and compatible solution for passing any data.

The parameter type to use in the IDL for this parameter is VARIANT.

The following code sample shows how to create and populate the structure described above.

#define StringCount 10;

VARIANT vStrings;
VariantInit (&vString);

vStrings.vt = VT_ARRAY|VT_BSTR;
vStrings.parray = ::SafeArrayCreateVector (VT_BSTR, 0, StringCount);

hR = ::SafeArrayLock (vString.parray);
if (FAILED (hR)) <insert error handling here>;

BSTR* pBSTR = static_cast<BSTR*>(vRights.parray->pvData);

for (int i = 0; i<StringCount; i++)
     pBstr++ = ::SysAllocString("MyString");

hR = ::SafeArrayUnlock (vRights.parray);
if (FAILED (hR)) <insert error handling here>;

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question