convert from String* to const char*

bwells

Well-known member
Joined
Feb 25, 2003
Messages
84
How can I convert from a managed string (String*) to an unmanaged const char* to pass from a managed C++ class to a unmanaged C++ routine?
 
bool setSRAM( String* fname )
{
void* pfname = Marshal::StringToHGlobalAnsi(fname).ToPointer( );
char* ufname = (char*)pfname;

// do your stuff with ufname here

Marshal::FreeHGlobal((int)ufname);
}
 
Back
Top