Click here to Skip to main content
13,298,551 members (77,523 online)
Rate this:
Please Sign up or sign in to vote.
I made an DLL in C sharp and added to my VC++ project in visual studio,a method of my DLL on calling return the status as "success" or what the error is.

I did some thing like this

char *a=interfacepointer->DLL Function

I get the garbage value in variable "a".
When i check it through my C# code the output is like this :-

<string xmlns="">Success</string>


<string xmlns="">Unknown database 'nhms_temp11'</string>

I should get the Value as "SUCESS" or "Unknown database 'nhms_temp11'"

What should i do?
Posted 9-Oct-12 3:52am
Malli_S 9-Oct-12 9:27am
What mechanism are you using to call the managed dll in native c++ project? Using interop ?
Tarun Batra 9-Oct-12 10:07am
using COM,i solved the problem
Tejas Vaishnav 9-Oct-12 9:32am
Not clear. please give more details...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Because char *a is a pointer, not a variable. The "garbage" as you call it is the memory address of your data.
In order to see that data you have to dereference your pointer again. Pointers[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Do like this
BSTR s1=interfacepointer->DLL Function
std::wcout <<s1<<std::endl ;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171207.1 | Last Updated 9 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100