Sign in to follow this  
silverphyre673

[.net] C++/CLR compared to MC++: __pin? NOT a "which is better" thread!

Recommended Posts

silverphyre673    454
I'm trying to use an unmanaged c++ class with some managed C++/CLR code that was generated by the MS VC++ 2005 express form designer. Specifically, I am attempting to embed an unmanaged class in a designer-generated form. It seems to be working fine. However, in one tutorial (on MC++), it mentioned that when passing arguments from managed C++ to the methods of the unmanaged class, I should use a __pin pointer, as in:
//In managed code
int someValue = 50;
int __pin* valuePtr = &someValue;
unmanagedClass.someMethod(*valuePtr);
Is this still true in c++/clr? If so, how do I do that? I can't find any documents talking about the replacement for the __pin keyword. Thanks a bunch!

Share this post


Link to post
Share on other sites
gharen2    520
Yes it's still true, and it's called pin_ptr in c++/clr.

For example, you need to use it to initialise a direct3d9 device natively:


pin_ptr<IDirect3DDevice9*> devicePtr = &mDirect3D9Device;
mDirect3D9->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, (HWND)mRootWindow->Handle.ToInt32(), dwBehaviorFlags, mPresentParams, (IDirect3DDevice9**)devicePtr ) ;







[Edited by - gharen2 on May 3, 2007 11:45:10 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this