Using PInvoke vs .NET provided functions
From version to version of .NET the more function that's equal to P/Invoke is added to .NET
Now there are 2 questions in my mind.
1) Which one is prefer over the other in term of speed, normally I use .Net function but in开发者_JAVA技巧 tight loop I don't really know which one is going to be faster.
2) Is there any website that provide the list of counter-parts?
1) If there is a .NET function you should, of course, use it - unless you have a really good reason not to.
2) Yes, there is a page that maps Win32 API functions to .NET methods, though it's quite old - it applies to .NET 1.1. See http://msdn.microsoft.com/en-us/library/aa302340.aspx
Edit: There is no newer list that I'm aware of, but one trick you could try is opening the .NET framework assemblies (like mscorlib, System, etc.) in Reflector and searching for the Win32 method name. If the assembly invokes it internally you should be able to find it this way and then find where it's referenced to trace it to a public method that you can call, if there is any. If there isn't, at least you can copy the P/Invoke signature without having to figure it out.
精彩评论