Jump to content
  • Advertisement
Sign in to follow this  
silverphyre673

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

This topic is 4038 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!