明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 758|回复: 0

P/Invoke tools

[复制链接]
发表于 2011-4-28 08:46:36 | 显示全部楼层 |阅读模式
作者:kean
原文地址:http://through-the-interface.typepad.com/through_the_interface/2011/04/pinvoke-tools.html

The topic of P/Invoke came up this morning in a discussion with Stephen Preston and Viru Aithal. Stephen mentioned a couple of interesting P/Invoke-related tools he’d stumbled upon, and Viru pointed me at an interesting technique he’d used for P/Invoking unmanaged member functions.

In this post I’ll present the tools, in a later post I’ll show Viru’s code.
The first tool is the PInvoke Visual Studio Add-in from Red Gate Software (the UK-based provider of various development tools, including Reflector Pro). It appears to be a Visual Studio Add-in for VS2003 and 2005 (I can’t see an update for VS2008 or 2010, which also means I can’t try it). The tool provides simplified access to the excellent PInvoke.net website, to which I often refer when developing .NET apps. I don’t actually use that many P/Invoke statements that I feel I need an Add-In, though – which is perhaps why the add-in doesn’t appear to have been updated for more recent Visual Studio versions – but it seemed worth mentioning.

 

The second – in my opinion more interesting – tool is the P/Invoke Interop Assistant (here’s a more in-depth article, the CodePlex hosting site and a Channel 9 interview with one of the authors). This tool generates P/Invoke signatures for use from C# and VB.NET, as well as the ability to determine the P/Invoke signatures used in compiled binaries:


  • Generating P/Invoke declarations while searching for commonly-used (presumably Win32) functions, structures, messages, etc.

    • This seems the more useful capability, in my opinion.


  • Translating C code snippets into equivalent P/Invoke declarations.

    • May be useful, but not for most “pure” .NET developers.



  • Reverse-engineers the C/C++ method declaration used within managed binaries.

    • An interesting intellectual exercise, perhaps (and potentially interesting information for some), but I can’t imagine needing to use this, myself.

The tool has been around for a while, but I hope some of you find the information in this post useful (it was certainly news to me). Does anyone else use a P/Invoke tool they’d like to share with this blog’s readership?

该贴已经同步到 mccad的微博

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
"觉得好,就打赏"
还没有人打赏,支持一下

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-12-24 20:25 , Processed in 0.171565 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表