I have been reading about the .NET framework for quite some time, and I found that Managed C++ allows mixing unmanaged and managed code. I've got a few questions about that.
Is it possible to use an unmanaged API (like unmanaged DirectShow or DirectX) in a managed application If so, are there any steps that need to be done to do this
Are managed API's like DirectX.NET also availible for Managed C++ If so, how do I know if I'm using the managed or unmanaged API
Now I've also got a problem with DirectShow. I installed the latest Platform SDK and tried to include <dshow.h>. When I did that, it said I needed <ddraw.h>. Since directdraw is a part of DirectX, I downloaded and installed the October DirectX SDK Update (211MB) and installed it.
Now when I include dshow.h in an unmanaged C++ application, it compiles but gives a few warnings. But when I include dshow.h in a Managed C++ application, I get this error loads of times:
Error 1 error C3641: 'StringCchCopyA' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe D:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Include\strsafe.h 221
Anyone know what's wrong here

Unmanaged DirectX with Managed C++
Dhirendra
In my opinion, what you see in forums are beginners who know .Net who try to learn DirectX because managed DirectX makes it accessible and easy to learn. They make obvious mistakes such making too many Draw() calls or locking buffers for too long or just plain drawing too much. Then when its slower than Half Life they blame MDX and complain loudly. Of course those kind of errors would slow down an unmanaged application just as much.
Pamish
Writing this post made me remember though, that I didn't test it on fullscreen, but in a window. So I just tested the samples in fullscreen, and it all ran perfectly. So I guess you're right there.
Is there a reason why the application runs much slower in a window than fullscreen with AA on
Roundtwoit
Where did you hear that MDX performance is terrible Its not. Unless you are trying to write the next halflife/quake you probably won't notice the difference. Most 3d game engines get their performance through smart algorithms rather than DX vs MDX perf.
Try running the MDX samples and the native samples and check out the very similar framerates.
Technically speaking native is going to be faster becuase managed code has an extra layer in between, but its a very thin layer and performance of that layer is a top priority in design and coding of MDX.
Gregor Bussmann
One can create and call unmanaged classes in Managed C++ right So won't this allow unmanaged DirectX to be used in Managed C++ applications
And the performance. I hear Managed DirectX's performance is terrible compared to unmanaged DirectX. If I program in Managed C++ and call unmanaged DirectX, will the performance be higher
Tatjana
But these applications are the samples distributed with the DirectX SDK! And the wierdest thing is that in windowed mode it runs at 4 fps, but in fullscreen they run at 75 fps.
hoosierboy
As far as I am aware, no. You could probably do some interoping between the api's but generally you would use the managed API's for the managed languages and the native DirectX api with unmanaged languages. Using the unsafe blocks in managed code gives you the added flexibility of performance tweaking but your code base shouldn't be written/coded entirely written in unsafe blocks as that defeats the purpose in my opinion. I am sure Mr. Weller will provide you with added and more valuable information regarding this topic.
"Are managed API's like DirectX.NET also availible for Managed C++ "
You get 2 parts to the API that you download. The native and managed API's. Managed c++ enables the developer to develop in c++ but in a managed environment using the .NET framework. With this said. If you are using Managed c++ you will be using the managed DirectX API. If you are using native c++ you will be using the native DirectX API set.
"how do I know if I'm using the managed or unmanaged API "
When using the Managed API the references that you add will point to a directory such as C:\Windows\Microsoft.NET\DirectX for Managed Code\... and so forth this clearly states that you are referencing the managed DirectX assemblies.
I hope this helps.
Take care bud.