I am using C++/CLI to create a GUI that controls an external GPIB device. The GUI has a textbox where the user can enter a voltage. I am able to read the voltage from the textbox like this...
String^ v1 = textBox1->Text;
Assuming the user properly enters a decimal number into the textbox, I need to concatenate this value with some other text and produce a const void* to pass to the gpib library command.
So basically my question is how can I convert from String^ to const void*? I am able to convert String^ to a Double like this...
Double volt1 = Double::Parse(textBox1->Text);
So a solution for how to convert a Double to a const void* would work as well.
It's odd that your external library wants
const void*and not a character pointer, but assuming it wants an ANSI string, you can use themarshal_contextclass to convert yourString^to aconst char*pointer:(Example code taken from here).
Of course if your library wanted a Unicode string you would use
marshal_as<const wchar_t*>instead.