Solved

Variant String Problems

Posted on 2002-03-17
4
372 Views
Last Modified: 2010-04-02
Hi,

I am using Borland C Builder 5. I am trying to create a custom collection class, but I am having
problems with strings and variants. My add method takes in a TVariant*
which I then copy into a global TVariant using the VariantCopy method
(after using the VariantInit method on the global TVariant). When I
return it, I simply return a pointer to the global TVariant. The problem
is when the variant contains a string. Supposedly the VariantCopy method
copies the string however this does not appear to be happening. From a
VB client, if I access the value from the same function as I added it, I
get the right string, but if I access it from another function, where
the string is out of scope, I get a different string. What am I doing
wrong??

Thanks,

Zaphod.
0
Comment
Question by:Z_Beeblebrox
4 Comments
 

Expert Comment

by:assermark
ID: 6876380
First, COM-support in BCB5 suffering from some serious bugs. If you intend do do some COM-programming in in BCB, and particular if your clients is not written in BCB, you should upgrade to ver.6, where (among other things) TVariant is exchanged to the VARIANT-structure.

In COM a client always should deallocate a returned string, and that is what your VB-client is doing. For that reason your server should return a copy, not a pointer to your local storage.

If you post some sourcecode it´s maby easyer to solve your problem.
0
 
LVL 7

Author Comment

by:Z_Beeblebrox
ID: 6878994
I figured it out, I was passing a pointer to the global variant and VB was changing it. So now I pass it a new variant.

Zaphod.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7085365
Hi Z_Beeblebrox,
You've requested to delete this question, but its status remains as 'Pending Delete' because one or more comments have been added.  Normally, the only way to fully delete such a Question is to post a message to Community Support and ask for assistance.

EE is making a one-time database sweep to purge the Pending Delete Questions automatically.  During this sweep:

    Z_Beeblebrox -- To allow the deletion to proceed:  Do nothing.
    EXPERTS -- Please DON'T POST a comment except to contest this deletion.

In the future, please refer to http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp#8 for instruction on deleting questions.

DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Accepted Solution

by:
Moondancer earned 0 total points
ID: 7104565
100 points refunded, moved to the PAQ and closed rather than deleted, since you added the solution and it may help others.
Moondancer - EE Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

708 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

13 Experts available now in Live!

Get 1:1 Help Now