Daily : August 22, 2005

22 Aug

Code Snippet I : Wrapper for CLR string to native string marshalling

by Marco Mastropaolo

A frequent (too much frequent) need in Managed C++ is going from System::String objects to char* or wchar_t* strings. The boring side of the marshalling is that the memory allocated with the StringToHGlobalxxx functions should be freed with a matching call to FreeHGlobal. The solution is simple : using the power of C++ destructors we [...]