?
Solved

problem on DCOM application?

Posted on 2002-04-15
4
Medium Priority
?
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 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