【问题标题】:How can I discover the methods available to me in an unmanaged DLL如何在非托管 DLL 中发现可供我使用的方法
【发布时间】:2011-08-25 00:08:34
【问题描述】:

当像这样进行 dll 导入时:

[DllImport("user32.dll")]
    static extern bool SwapMouseButton(bool fSwap);

    private void button1_Click(object sender, EventArgs e)
    {
        SwapMouseButton(false);
    }

如何知道user32.dll 中有一个名为 SwapMouseButton 的方法,它接受一个 bool 参数并返回一个 bool 值?

显然没有智能感知可以挽救局面。那么有没有一个网站可以列出这一切,或者我可以输入 user32.dll 的程序来为我发现它?

【问题讨论】:

  • 您不搜索 DLL。您在 MSDN 中搜索您需要的功能,然后链接到相应的 .h .lib 和 .dll
  • @David,看起来 MSDN 现在有一个很酷的快速参考页面。 msdn.microsoft.com/en-us/library/ms123401.aspx
  • @Nick:感谢您的链接。我没看过那个页面;这是一个方便的参考。

标签: windows dllimport


【解决方案1】:

`User32.dll' 是 Windows API 本身的一部分,该 API 记录在 MSDN。在那里查找内容的典型方法是确定您要尝试做什么,然后搜索该主题。

无法找到非托管 DLL 函数的参数。您可以(通常)使用depends.exe(VS 的一部分)或DependencyWalker 找到函数的名称。但是,这不会为您提供参数;这些必须从库的文档中获得。

【讨论】:

    【解决方案2】:

    您可以使用 Visual Studio 附带的depends.exe。您可以加载一个 dll,它会显示里面的所有函数以及依赖项。

    你也可以试试 Dumpbin:http://msdn.microsoft.com/en-us/library/c1h23y6c

    【讨论】:

      猜你喜欢
      • 2013-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-04
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多