'Introducing' PINVOKE.NET and its Visual Studio Add-In!

I guess I'm not cut out to be a journalist.

Two weeks ago when I decided to spend my weekend creating the PINVOKE.NET wiki, I had a great opportunity to awaken my blog from its deep slumber by announcing it to the world.  But Ben, Brad, Brian, Charlie, Chris, Corrado, Darth, Duncan, Ivan, James, Jesse, Jim, Joe, Josh, Julia, Ken, Peter, Phil, Sam, Sean, Shawn, Ted, Yorai, and numerous other people beat me to it!

This past weekend I put the finishing touches on a Visual Studio add-in that communicates with PINVOKE.NET via a Web service and uploaded it to gotdotnet.com.  As I waited for it to appear, I knew that this was my second chance to have an exclusive scoop on my blog.  Lo and behold, Kevin, Kent, Josh, Girish, and Paul let the cat out of the bag before I did!

Don't get me wrong… I'm flattered that so many people find this stuff blog-worthy!  Ever since preparing for PDC 2003 last September, I wanted to create such a site in order to help people with the PInvoke problem.  That's when I reserved the pinvoke.net domain name.  But it wasn't until an e-mail discussion on Thursday 4/15 about the difficulty of PInvoke that I put my foot down and was determined to get the site up and running by that Monday morning (4/19)!  That's also when it dawned on me that the wiki approach was the way to make this happen fast.  I'm grateful that I stumbled across the great work the FlexWiki folks have done.

So thank you for all of your great comments on the site, in e-mail, and in your blogs.  It gives me hope that the site is starting to achieve its objective.  And thank you especially for your contributions to the wiki!  As a community we've expanded the site from 6 to 25 DLLs, with approximately 1,700 signatures & types, including hundreds of pages with sample code, alternative managed APIs, VB signatures, and other helpful information.  All this in just two and a half weeks!  I want to highlight Craig Ellis in particular, who contributed 54 functions and 8 structures all in one sitting!

Therefore, I'm not going to introduce the site.  If you're somehow reading my blog but aren't familiar with it, please visit http://www.pinvoke.net for more information.  And don't worry, support for more browsers is still on my TODO list.  (Working on the site is reserved for my sparest of spare time!)

I do want to give a quick overview of what the Visual Studio add-in does, however.  After installing it from here, you'll get two new menu items when right-clicking in source code:

The Insert PInvoke Signatures… option opens a dialog, shown here with the results for the MessageBeep API:

Once you type in a function name and press Enter, you can get a description, PInvoke signature(s), and an alternative managed API from the PINVOKE.NET web service.  If you want more information (such as sample code or structure definitions), you can click on the link at the bottom.

But 'tis better to give than to receive, right?  If you want an easy way to contribute to the PINVOKE.NET project, highlight some code and select the Contribute PInvoke Signatures and Types… option:

You'll get the following dialog, which enables you to upload your content:

Let me know if you have any questions/comments, and enjoy!
Published 06 May 04 01:26 by Adam Nathan
Filed under:

Comments

# jledgard said on May 6, 2004 1:41 PM:
I think the perfect next step would be an option to paste in the code snippets into the editor as well if they exist. Optionally I could also see people wanting to include the pinvoke.net or MSDN help URL above the signature/sample code as a comment. This is really cool stuff though.
# Kevin Dente said on May 6, 2004 2:17 PM:
Hey man, I think I had the original scoop on this one. ;) Sorry, didn't mean to burst your bubble. Awesome, awesome stuff, and badly needed.
# Adam Nathan said on May 6, 2004 2:59 PM:
Ah, I missed that, so I've added your name above. :) Sorry about spoiling your contest idea!
# Kevin Dente said on May 6, 2004 3:16 PM:
You probably did me a favor. I didn't have the web service to work with that your add-in has, so it was getting ugly anyway. I'm sure I can come up with another idea or two for add-ins. ;)
# Code/Tea/Etc... said on May 7, 2004 3:14 AM:
# code4ward said on May 7, 2004 3:28 AM:
# Sam Gentile's Blog said on May 7, 2004 10:09 AM:
# Sam Gentile's Blog said on May 7, 2004 10:10 AM:
# David Levine said on May 8, 2004 4:56 AM:
Great tool, I wish I had it years ago. I've a couple of observations and questions ...

I browsed around looking at some of the APIs I have used and already spotted a few differences. Many are of the type where I used an int instead of a uint - small but perhaps significant - so it has already proved useful.

Also, I noticed that the signatures I looked at did not decorate the methods with attributes, such as SetLastError = true etc. Do any of them? Should these be there?

Is there a means of reporting differences, or starting a discussion about what the most appropriate signature should be? Should I just upload the signature I use and let someone (you?) sort it out?

It would be nice if there was a downloadable database so offline developement could use this tool.

# Adam Nathan said on May 8, 2004 5:35 PM:
Thanks, David. Yes, there can be many ways to define a PInvoke signature, and they can be equally correct. For example:

- Maybe you want to set PreserveSig=false in order to get exceptions instead of raw failure HRESULTs
- Maybe you want to use SuppressUnmanagedCodeSecurity because you've ruled out the possibility of a luring attack
- Maybe you can define the parameters differently because you're using the API in a limited scenario

The idea is that people should feel free to add additional versions of a signature, with a note explaining why. For an example, see http://pinvoke.net/jump.aspx/kernel32.GetVersionEx. Or if you know that an existing signature is just wrong, feel free to correct it. Or if you aren't sure, feel free to start a discussion on that function's page, and hopefully someone will come along with an answer.

In the case of SetLastError=true, I'd say it should be marked for all APIs that use that mechanism, although it turns out that the CLR exhibits SetLastError=true behavior for many Win32 DLLs anyway, regardless of how the signatures are marked. It's also interesting to note that the VB compiler always emits SetLastError=true when you use a Declare statement. So I'm now thinking that I should change the template to stick SetLastError=true in C# signatures by default.
# Miguel de Icaza said on May 9, 2004 10:52 AM:
Do you have a web service running, that we could say, hook
up from a client to retrieve this information?

Miguel
# Adam Nathan said on May 9, 2004 8:41 PM:
Yes, check out http://www.pinvoke.net/pinvokeservice.asmx.
# re-in-car-na-tion said on May 10, 2004 8:00 AM:
"Introducing" PINVOKE.NET and its Visual Studio Add-In! .NET????????WindowsAPI?????DllImport??????????????????????????????????????????????? ??????VS.NET????????????????????PINVOKE.NET??Web???????????????????????????????? ?????????????????????···...
# stripe said on May 10, 2004 6:21 AM:
Is there a proxy server friendly version of the client? I get the annoying 407 error, is the source code available so i can quickly add the few lines of code to make it use the proxy?
Ta
# Joe Cheng said on May 10, 2004 2:40 PM:
So so so SO great. Ever since the first day I started doing P/Invoke I wondered why there wasn't a repository for signatures... but the VS.NET add-in is a very welcome surprise.

Thanks, Adam, for your efforts (your book is a constant fixture on the desks of myself and my coworkers) and to everyone who has contributed signatures!
# Scott Galloway's Personal Blog said on May 10, 2004 6:55 PM:
# Wired Prairie said on May 11, 2004 8:26 AM:
I applaud Adam's creation, PINVOKE.NET, and its community driven repository of PINVOKE declarations for .NET. When I'm doing managed development and need to make some call into unmanaged territory, I'll be certain to look there first for assistance.
# stripe said on May 11, 2004 7:15 AM:
I have done a version that works behind proxy servers.

Download source code OR binary from
http://www.stripe.dsl.pipex.com/PInvokeAddin
# code4ward said on May 11, 2004 6:51 PM:
# Joseph J. Mele said on May 11, 2004 10:53 PM:
# Ryan Farley said on May 11, 2004 11:23 PM:
Truly awesome stuff, Adam. All I can say is that it is about time someone did something like this. Your efforts are really appreciated. Thanks!
# .NET4Office said on May 14, 2004 3:01 PM:
# Mick Doherty said on May 19, 2004 2:31 AM:
Very Nice...
I program in VB.Net but I prefer to use the <DllImport(....)> style of declare to the old VB Classic style.
How about adding that option?
# Mick Doherty said on May 19, 2004 4:57 AM:
Ok . I see that we must just add that variation. However, we cannot use Line Continuation.

<DllImport("UxTheme.dll", _
CallingConvention:=CallingConvention.Cdecl)> _
Function DrawThemeBackground( _
ByVal hTheme As IntPtr, _
ByVal hdc As IntPtr, _
ByVal iPartId As Integer, _
ByVal iStateId As Integer, _
ByRef pRect As RECT, _
ByRef pClipRect As RECT) As Integer
End Function

is much easier to read than

<DllImport("UxTheme.dll", CallingConvention:=CallingConvention.Cdecl)>Function DrawThemeBackground(ByVal hTheme As IntPtr, ByVal hdc As IntPtr, ByVal iPartId As Integer, ByVal iStateId As Integer, ByRef pRect As RECT, ByRef pClipRect As RECT) As Integer
End Function

but then I suppose IntelliSense takes away the need to read it.
# Adam Nathan said on May 20, 2004 10:15 AM:
Thanks, Mick, although I don't understand your comment about line continuation. I encourage you to use it in the signatures you contribute!

And thanks, stripe, for the feedback about proxy servers. At some point I'll release another version that addresses this (in addition to adding new features, such as search).
# Andreas Häber said on May 22, 2004 8:05 AM:
Would it be possible if the webservice also had a method to get a list of the modules currently available?
# Mike Taulty's Weblog said on May 24, 2004 2:15 PM:
# Mick Doherty said on June 1, 2004 5:23 AM:
Adam,
I submitted a signature using Line Continuation as follows:

<DllImport("UxTheme.dll", _
CallingConvention:=CallingConvention.Cdecl)> _
Function DrawThemeBackground( _
ByVal hTheme As IntPtr, _
ByVal hdc As IntPtr, _
ByVal iPartId As Integer, _
ByVal iStateId As Integer, _
ByRef pRect As RECT, _
ByRef pClipRect As RECT) As Integer
End Function

when I tried to use that all I got back was:

<DllImport("UxTheme.dll", _
CallingConvention:=CallingConvention.Cdecl)> _
Function DrawThemeBackground( _

So I had to modify the submission so that the arguments were all on one line.
# Justin Cummings said on June 3, 2004 6:20 PM:
Great work, Adam!

This tool will prove invaluable. I do have a couple of suggestions, and considerations:

1. On the pinvoke.net site, the browser navigation menu could use some massaging to work with Moz/Firebird/Gecko-based browsers -- both the javascript and the method of font-size selection are the most noticible issues.

2. As part of the snippet submission process, it would benificial to provide an [optional] author supplied annotation of the module (dll, exe, cpl, etc) version and possibly platform being used, as you know the legacy APIs for some modules varied greatly.

3. A further enhancement of the second suggestion would be [a little] more involved, and it was the approach I intended to explore until I saw your work -- wrap the native debugger and attempt to locate the suggested within a [local/remote] symbol file. If found, annotate the submission with a confirmation status (or improve it's weight/rating/relavence) and the version of the PDB used. Since the native debugger isnt really designed to work as an in-process component, perhaps make this semi-automated confirmation process a nighly/hourly batch process.

Again, kudos and much thanks to you sir.
# Deepak Shenoy said on June 14, 2004 12:33 AM:
I've written a small application using Delphi 7 (Win32) that gets header declarations from PInvoke.NET and even converts them to Delphi for .NET. You can download it at <a href="http://www.agnisoft.com/downloads/pbroker.zip">http://www.agnisoft.com/downloads/pbroker.zip</a> or visit my blog page on it at <a href="http://shenoyatwork.blogspot.com/2004/06/pinvoke-and-delphi.html">http://shenoyatwork.blogspot.com/2004/06/pinvoke-and-delphi.html</a>.

Great work, Adam, this is a really cool service!
# Deepak Shenoy said on June 14, 2004 12:35 AM:
uh oh, I messed up. The URLs are:
http://www.agnisoft.com/downloads/pbroker.zip
and
http://shenoyatwork.blogspot.com/2004/06/pinvoke-and-delphi.html

Sorry about that.
# rainer linnemann.de said on June 25, 2004 12:28 AM:
hmm ... every time I tried it the user32.dll terminated with an error . what is wrong
# andry said on July 18, 2004 4:15 PM:
-"1,700 signatures & types" it real cool :)
# Alex said on July 21, 2004 10:14 PM:
This is great Add-in.
However I noticed that it does not work with Visual Studio 2005 Express Edition :(
Thank you
# Sex Girl BBS said on July 27, 2004 11:14 AM:
Sex Girl BBS
http://www.dd20.com
http://www.waxw.com
Girl Music
http://music.waxw.com
# Sex Girl BBS said on July 27, 2004 11:17 AM:
Sex Girl BBS
http://www.dd20.com
http://www.waxw.com
Girl Music
http://music.waxw.com
# Nauman Leghari's Blog said on August 5, 2004 3:02 PM:
# Eric Nelson said on August 26, 2004 10:54 PM:
# Wah On Terra .NET: Martin Granell's Blog said on September 7, 2004 7:34 PM:
# Sam Gentile's Blog said on November 25, 2004 11:55 AM:
# Adam Nathan's Win32 to WinFX Blog said on May 9, 2005 2:23 PM:
In a recent meeting, I got the opportunity to meet Ward Cunningham, David Orenstein, and Korby Parnell.&amp;nbsp;...
# VsAddin said on November 28, 2005 3:30 AM:
Hi,

after installing it with my visual studio version 2005 (no beta) - the addin doesn't appear. What should I do? The setup finished without errors.
# If broken it is, fix it you should said on February 9, 2006 10:00 AM:

If someone asked me, what is the nastiest types of issues you get? I would say managed heap corruption,...
# Nadja said on March 8, 2006 3:16 AM:
shannon_n@merelink-mono.com
# Martin said on March 8, 2006 10:06 PM:
martin2king@homtail.com
# Antony said on March 8, 2006 10:36 PM:
antony@fillaribze.com
# Sam said on March 8, 2006 10:41 PM:
Sam@opertonickers.com
# online casino said on March 12, 2006 6:29 AM:
napsfavalleyfsoft3006@yahoo.com
# Rob said on March 16, 2006 12:48 PM:
rob@uscb.com
# Fred said on April 26, 2006 5:35 AM:
8945ht5h4h@yahoo.com
# Rhys said on April 30, 2006 4:03 PM:
rhys@tesis.com.com
# mattonsoftware.com said on May 6, 2006 4:37 AM:
The following links to .NET resources have been collated over time with the assistance of colleagues.&amp;nbsp;...
# sepid1g@gmail.com said on May 9, 2006 10:22 AM:
online directory main
# David said on May 29, 2006 10:45 PM:
shjd@bradjewelry.org
# Johny said on May 31, 2006 3:23 PM:
johny@depp.ru
# Joy said on June 2, 2006 6:09 PM:
johnson@xdsj.com
# Morris said on June 2, 2006 6:13 PM:
johnson@cn.com
# insurance auto said on June 6, 2006 10:42 AM:
Thanks!!! http://www.insurance-top.com/company/">http://www.insurance-top.com/company/ auto site insurance. [URL=http://www.insurance-top.com]home insurance[/URL]: compare car insurance, auto insurance, insurance car. Also [url=http://www.insurance-top.com]cars insurance[/url] from website .
# insurance auto said on June 6, 2006 10:42 AM:
Hi! http://www.insurance-top.com/company/ auto site insurance. compare car insurance, auto insurance, insurance car. from website .
# Sefany said on June 9, 2006 1:04 PM:
stafanymalfoy@yahoo.co.tv
# Sefany said on June 9, 2006 1:29 PM:
stafanymalfoy@yahoo.co.tv
# Micael said on June 9, 2006 1:53 PM:
stafadnymdalfoy@yahoo.co.tv
# Micael said on June 9, 2006 1:56 PM:
stafadnymdalfoy@yahoo.co.tv
# Micael said on June 9, 2006 2:02 PM:
stafadnymdalfoy@yahoo.co.tv
# Micael said on June 9, 2006 2:06 PM:
stafadnymdalfoy@yahoo.co.tv
# Micael said on June 9, 2006 2:16 PM:
stafadnymdalfoy@yahoo.co.tv
# Micael said on June 9, 2006 2:19 PM:
stafadnymdalfoy@yahoo.co.tv
# Micael said on June 9, 2006 2:22 PM:
stafadnymdalfoy@yahoo.co.tv
# Micael said on June 9, 2006 2:28 PM:
stafadnymdalfoy@yahoo.co.tv
# Micael said on June 9, 2006 2:34 PM:
stafadnymdalfoy@yahoo.co.tv
# cellulite treatment said on June 13, 2006 8:33 PM:
Hoodia gordonii diet pills.
http://beam.to/cellulitesolution/
http://beam.to/hoodiapills/
http://beam.to/hoodiagordonii/
http://beam.to/h57hoodia/
<a href=http://beam.to/hoodiapills/>hoodia diet pills</a>
<a href=http://beam.to/hoodiagordonii/>hoodia gordonii</a>
<a href=http://beam.to/h57hoodia/>h57hoodia</a>
cheap pharmacy hoodia cactus extract kill appetite pills.
# cellulite treatment said on June 15, 2006 1:48 PM:
Hoodia gordonii diet pills.
http://beam.to/cellulitesolution/
http://beam.to/hoodiapills/
http://beam.to/hoodiagordonii/
http://beam.to/h57hoodia/
<a href=http://beam.to/hoodiapills/>hoodia diet pills</a>
<a href=http://beam.to/hoodiagordonii/>hoodia gordonii</a>
<a href=http://beam.to/h57hoodia/>h57hoodia</a>
cheap pharmacy hoodia cactus extract kill appetite pills.
# teen lesbian rape said on June 20, 2006 10:22 AM:
Persone los pioneros non rabata. Great...
# lesbian rape said on June 23, 2006 10:04 PM:
Best of all people w can talk...
# cbc3fac2dc@gmail.com said on August 9, 2006 10:17 AM:
Text: cbc3fac2dc74c4adab698148eeeed9020
<a href="cbc3fac2dc74c4adab698148eeeed90200">cbc3fac2dc74c4adab698148eeeed90200</a>
[a]cbc3fac2dc74c4adab698148eeeed90201[/a]
[a href=cbc3fac2dc74c4adab698148eeeed90202]cbc3fac2dc74c4adab698148eeeed90202[/a]
[a href="cbc3fac2dc74c4adab698148eeeed90203"]cbc3fac2dc74c4adab698148eeeed90203[/a]
[link]cbc3fac2dc74c4adab698148eeeed90204[/link]
[link=cbc3fac2dc74c4adab698148eeeed90205]cbc3fac2dc74c4adab698148eeeed90205[/link]
[link="cbc3fac2dc74c4adab698148eeeed90206"]cbc3fac2dc74c4adab698148eeeed90206[/link]
[url]cbc3fac2dc74c4adab698148eeeed90207[/url]
[url=cbc3fac2dc74c4adab698148eeeed90208]cbc3fac2dc74c4adab698148eeeed90208[/url]
[url="cbc3fac2dc74c4adab698148eeeed90209"]cbc3fac2dc74c4adab698148eeeed90209[/url]
# buy text link said on August 14, 2006 8:20 AM:
buytextlink@links-universe.info
# If broken it is, fix it you should said on August 20, 2007 8:52 AM:

If someone asked me, what is the nastiest types of issues you get? I would say managed heap corruption,

# Software Information » Powertoys WebLog : Get Pinvoke.Net Native Method Signatures directly … said on January 24, 2008 9:55 AM:

PingBack from http://softwareinformation.247blogging.info/powertoys-weblog-get-pinvokenet-native-method-signatures-directly/

# Didrex online. said on July 30, 2008 8:05 PM:

No prescription didrex. Didrex. Cheap didrex without prescription.

New Comments to this post are disabled
Page view tracker