Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Using Managed C++  (Read 930 times)

0 Members and 1 Guest are viewing this topic.
Using Managed C++
« on: July 19, 2006, 05:01:51 am »
  • The Broken King
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1259
Okay, so for whatever reason, you're using managed C++. And you have a managed String (String ^) or an array of wide characters (widechar_t). For whatever reason, you need to convert that data into a char*. Well, you look through code on the internet, and you find a lot of discussion on how to do it, but no one really has a simple answer. They're all functions that, when you plug them into your code, you find don't actually work. So what do you do?

You use this function:

(char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(YOUR DATA HERE).ToPointer();

Now, the question that I have: Why couldn't they have simply put this in the System::Convert namespace, like all the other convert functions? Wouldn't that have been really cool? It would have saved me four hours of coding and googling, that's for sure.

Although really, I don't know why it took me so long to find it. If you look at the function name, it's really quite a simple path to follow exploring your intellisense to find that.

(No seriously, whoever originally found that function deserves a medal or something.)
« Last Edit: March 01, 2007, 01:04:46 am by 4Sword »
Logged
  • Broken Kings [Temp Site]
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.191 seconds with 36 queries.

anything