Nino.Mobile

Nino Benvenuti's Blog

P/Invoke Wizard (I was curious..)

Doing a bit of P/Invoke lately (for COM Interop on NETCF), I became curious (and my fingers tired), so I purchased the P/Invoke Wizard ..... that was yesterday. I just got the e-mail back from them today (with the attached .zip file)...so now I'll play with it a bit..and give some feedback to everyone -Nino
[Listening to: The Sky Is a Landfill - Jeff Buckley - Sketches (For My Sweetheart the Drunk) Disc 1 (05:09)]

Comments

.S.Rod. said:

I am interested to know whether the conversion product does anything useful, actually. Here are questionable thoughts over this product :
- the only example provided in his web site is straight forward. Man, you don't need to pay software to translate LONG to Int32, and LPWSTR to String. I hope I am biased and the software does much much more, especially complex types.
- what the tool does not say, and that's according to me why there is no trial version, is that the true issue with P/Invoke is the fact that the WIN32 API only provides a piece of the knowledge when it comes to marshaling types. And I am afraid this tool is of no help about it. Here is an example : assume we have a function with LPSTR as a parameter. How can an automated tool figure out whether the string is an input string or an output string. How does he know whether we must allocate a memory block before we pass the pointer, or we simply don't have to.
Just send an e-mail to him and ask how he handles this. I guess he doesn't at all.
# May 2, 2003 4:58 AM

Nino said:

I know that I don't need pay software to translate LONG to Int32, etc, but as I said.. I was curious.. I am in the process of finding out the limits of this tool (and hey, since they were late getting processing my order they took off $20 .. so less out of pocket for me) =)

-Nino
# May 3, 2003 9:52 AM

Paul Yao said:

I'm the creator of the P/Invoke Wizard, noticed your comments, and wanted to add some more info.

The first thing is that there is a new version available (version 1.2) which also includes a trial version. So anyone that wants to can answer the question about "does this do anything useful" by running your own tests. (Available from http://www.paulyao.com/pinvoke">http://www.paulyao.com/pinvoke)

The key reason I wrote this tool was to save time. Rather than spend 2-3 minutes writing a bunch of declarations for a function I want to use, I wanted to be able to click a mouse and do the conversions automatically. After all, time is the one thing you don't get more of. If I can do a conversion in 10 seconds that used to take several minutes, I am ahead of the game.

I wrote the tool while I was working on a book about the .NET Compact Framework. At the time, it seemed to me that mobile device programmers needed to do P/Invoke more than desktop .NET Framework programmers. In fact, though, there is probably an equal need for this type of tool for both desktop and device programming. (The book is due out at the end of May, by the way, and the full text of the book is available on my web site - and the code is coming soon).

The tool supports both desktop and device programming. It supports the MarshalAs attribute for embedded arrays inside structures, and generally does a good job at guessing what needs to be passed to a called function based on the parameter type information.

So -- Nino, you were curious to see if this tool would help you. Please let us know what you think, and how well it has worked for you.

My Best,
Paul Yao
President
The Paul Yao Company
http://www.paulyao.com
# March 6, 2004 10:05 PM

Albert Anderthal said:

I tried that tool before I found your post here.

I was creating a search engine optimization tool. If you look at the Internet Explorer interfaces, you will see that there are some interface definitions that are a bit squirrly. SOme hand-tuning was required, but otherwise I had no problem.

Anyway, the PInvoke declarations can be a real bear sometimes. Someone told me that managed C++ does not require any PInvoke declarations. Any truth to that?

# October 28, 2009 11:19 AM

Bavol said:

Hi. Nothing is as simple as we hope it will be. Help me! Need information about: Cosmetic dentistry alamo. I found only this - <a href="www.supplychainbyagrostar.fr/.../cosmetic-dentistry-del-mar">cosmetic dentistry del mar</a>. Cosmetic dentistry, forget out about scientific wetlands and worms which live your parts, and which shore may be found for you. From 1903, harmful empress teeth were covered for treatment across the atlantic, cosmetic dentistry. Waiting for a reply :mad:, Bavol from France.

# March 24, 2010 1:00 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)