Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7616105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:48:34+00:00 2026-05-31T02:48:34+00:00

I have a com objects function having a C# return type of string string

  • 0

I have a com objects function having a C# return type of string

string getData();

In my C++ code I have

cpi->getData(); 

where cpi is a pointer to an instance of com object.

How do I get this returned data in a C++ variable?

—edit—

I also have another function called handlepacket(char* data).

How do I pass this cpi->getData returned string data to this function?

A C++ code piece will be very helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:48:35+00:00Added an answer on May 31, 2026 at 2:48 am

    The COM string type is BSTR. It has non-trivial memory-management rules. Luckily, the _bstr_t C++ class wraps BSTR and gives you reasonable semantics. So, _bstr_t foo = cpi->getData(); is the easiest way.

    You can pass this string to a handlepacket(wchar_t* data). The COM string type is Unicode text, not 8 bits data. If your getData function returns 8 bits data, it should have returned an array of bytes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For ex. i have c# COM object with such function: int GetString([In, Out, MarshalAs(UnmanagedType.LPStr)]ref
I have a COM object (C#, visual studio) with a function that takes a
I have a simple json string which contains a collection of objects http://sandapps.com/InAppAds/ads.json.txt When
I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
I have the following 2 objects: User and DomainUser User.java: package com.domain; import java.io.Serializable;
I have a COM object that I'm trying to use from C++ (not .NET),
I have an unmanaged COM object, and I would like to call it from
I have a native Visual C++ COM object and I need to make it
I have the following code which I use to load the xml object but
I am having trouble getting some data from a JSON object which I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.