C#调用C++的库 P/Invoke工具集

简介: p/Invoke可以使用工具辅助自动生成,以减少混淆 1、官方的支持 http://visualstudiogallery.msdn.microsoft.com/site/search?query=p%2Finvoke&f%5B0%5D.

p/Invoke可以使用工具辅助自动生成,以减少混淆

1、官方的支持

http://visualstudiogallery.msdn.microsoft.com/site/search?query=p%2Finvoke&f%5B0%5D.Value=p%2Finvoke&f%5B0%5D.Type=SearchText&ac=4

微软的官方扩展上也有很多

开源的工具

http://www.pin5i.com/showtopic-22763.html

看起来微软自己也是深受.NET蹩脚的P/Invoke支持的毒害,因此无奈之余发布P/Invoke Interop Assistant工具,你可以去下面这个链接来下载这个工具:
http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/CLRInsideOut2008_01.exe

实际上这个工具已经开源了,你可以从这里http://www.codeplex.com/clrinterop/下载到它的源代码

2、经典的讨论区 

http://stackoverflow.com/questions/2495632/easiest-way-to-generate-p-invoke-code

http://www.paulyao.com/res/pinvoke/pinvoke.aspx

3、社区评论

http://through-the-interface.typepad.com/through_the_interface/2011/04/pinvoke-tools.html

 

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.

 

PInvoke Visual Studio Add-in menu itemPInvoke Visual Studio Add-in dialog

 

The second – in my opinion more interesting – tool is the P/Invoke Interop Assistant(here’s a more in-depth articlethe 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.

 

相关文章
|
8天前
|
存储 C++ 容器
C++STL(标准模板库)处理学习应用案例
使用C++ STL,通过`std:vector`存储整数数组 `{5, 3, 1, 4, 2}`,然后利用`std::sort`进行排序,输出排序后序列:`std:vector<int> numbers; numbers = {5, 3, 1, 4, 2}; std:sort(numbers.begin(), numbers.end()); for (int number : numbers) { std::cout << number << " "; }`
15 2
|
19天前
|
存储 C++
基于C++的简易文件压缩与解压缩工具设计与实现
基于C++的简易文件压缩与解压缩工具设计与实现
12 3
|
21天前
|
算法 编译器 C语言
【C++ 异常】C++ 标准库异常类及其应用
【C++ 异常】C++ 标准库异常类及其应用
16 0
|
22天前
|
程序员 API 数据库
【Cmake工程 库相关教程 】深入理解CMake工程C/C++ 库管理技巧
【Cmake工程 库相关教程 】深入理解CMake工程C/C++ 库管理技巧
58 0
|
22天前
|
存储 JSON 安全
【C++ JSON库 json值的创建手段】深入探究C++中JSON对象定位与操作:从引用到回调函数
【C++ JSON库 json值的创建手段】深入探究C++中JSON对象定位与操作:从引用到回调函数
60 0
|
22天前
|
数据可视化 关系型数据库 编译器
【C/C++ 单线程性能分析工具 Gprof】 GNU的C/C++ 性能分析工具 Gprof 使用全面指南
【C/C++ 单线程性能分析工具 Gprof】 GNU的C/C++ 性能分析工具 Gprof 使用全面指南
98 2
|
20天前
|
IDE Linux 开发工具
一网打尽:C++远程调试工具和策略全指南
一网打尽:C++远程调试工具和策略全指南
62 2
|
21天前
|
缓存 算法 C语言
【C++ 标准查找算法 】C++标准库查找算法深入解析(In-depth Analysis of C++ Standard Library Search Algorithms)
【C++ 标准查找算法 】C++标准库查找算法深入解析(In-depth Analysis of C++ Standard Library Search Algorithms)
44 0
|
22天前
|
Linux C++ iOS开发
【C++ 17 新特性 文件管理】探索C++ Filesystem库:文件和目录操作的全面指南(二)
【C++ 17 新特性 文件管理】探索C++ Filesystem库:文件和目录操作的全面指南
235 2
|
22天前
|
Linux API C++
【C++ 17 新特性 文件管理】探索C++ Filesystem库:文件和目录操作的全面指南(一)
【C++ 17 新特性 文件管理】探索C++ Filesystem库:文件和目录操作的全面指南
288 2