windows - Get string memory location C++/CLI -
I have a method in a Windows Forms application where I get the contents of the text box and store it in the string. I would like to get the memory spot where the string is stored. In the console application, it works with This is what the function looks like: and string data but I am not able to get memory space in this situation.
Private: System :: Zero Button 1_Click (System :: Object ^ Sender, System :: EventArgues ^ E) {string} ^ Maestring = text box 1-> Text; // myString}
string myString
Is a managed item. You can not retrieve the original resident for managed objects using the operator's address ( & amp;
).
Instead, you can use this to pin the object so that it can not be transferred by the garbage collector, as long as pin_ptr
is in the scope .
pin_ptr
But assuming that the code in question is not exaggerated for the purposes of an illustration, I do not know why you want to do this just in the first place one Create unmanaged objects, and then retrieve your address as you normally would for & amp;
with the operator.
Comments
Post a Comment