Solved

problem on DCOM application?

Posted on 2002-04-15
4
171 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now