Welcome to MSDN Blogs Sign in | Join | Help

In VB6 we had the API Viewer, In VB .NET you get the P/Invoke Interop Assistant

VB6 programmers will remember a useful little utility called the API Viewer, the helped out when you needed to make a Windows API call.

clip_image002

There is now an equivalent tool for .NET, the P/Invoke Interop Assistant (http://www.codeplex.com/clrinterop ). Not surprisingly it does a little bit more, so as well as enabling you to look up the signature for a particular call, it will also translate snippets of C code.

clip_image004

Notice that it generates required structure definitions to go with your function call!

I also noticed that the P/Invoke Interop Assistant generated code that used the DllImport approach to setting up the API call. I expect this question has been answered loads of times before, but what are the advantages of using DllImport rather than Declare in your VB code? The obvious answer is that DllImport is a .NET way of doing things, but for VB6 programmers of the Declare statement looks much more natural. DllImport does offer much finer control over the way the call is made, but unless you need this fine control you can stick with Declare.

Published Friday, June 05, 2009 5:27 PM by Eric Nelson

Comments

Monday, June 08, 2009 8:18 AM by IUpdateable from Eric Nelson

# Summary of new Visual Basic Posts on Goto100

I have been sitting on a long list of part finished posts on Visual Basic “stuff” intended for my other

Anonymous comments are disabled
 
Page view tracker