Ioannis,
Consider the code:
wchar_t __pin *p= &(someCommand->ToCharArray())[0];
_wsystem(p);
p=0;
I need to pin the wchar_t __gc [] because I need to pass it to
_wsystem() which takes a wchar_t *.
Does the above code pin the whole wchar_t __gc[]?
Yep. From the MC++ spec, section 7.7 "Pinning Pointers":
"Pinning a sub-object defined in a managed object has the effect of pinning
the entire object. For example, if any element of an array is pinned, then
the whole array is also pinned. There are no extensions to the language for
declaring a pinned array. To pin an array, declare a pinning pointer to its
element type, and pin one of its elements.".
--
Tomas Restrepo
to****@mvps.org