Solved

Variant String Problems

Posted on 2002-03-17
4
385 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

735 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