首页 > 技术文章 > dll托管于非托管

xiaowie 2018-04-09 13:48 原文

托管的DLL组件可以在VS 直接添加引用,在使用using dll的文件命名空间就可以使用

非托管的DLL组件,只能通过using system.Runtime.InteropServices;引入 函数写在类的里面方法的外面如:

pubulic Class Myclass

{

  [DllImport("winmm.dll" , EntryPoint="mciSendString", CharSet=CharSet.Auto)] //调用winmm.dll非托管组件
  public static extern int mciSendString(string lpstrCommand, string lpstrReturnstring, int uReturnLength, int hwndCallback);

}

 

非托管的Dll怎么查看里面的方法和字段呢  使用vs自带的dumpbin.exe  path(D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64)

如果你下载了一个非托管的Dll文件放在D的新建文件夹下面:

  首先进入cmd 进入D:\新建文件夹  运行dumpbin -exports AltTab.dll 。

推荐阅读