# C# 如何调用动态连接库?

  1. 导入命名空间 using System.Runtime.InteropServices;
  2. 非托管DLL放入执行程序同级目录,比如 Debug 、Release 。
[DllImport("XQOCR.dll", EntryPoint = "XQOCR_IsSupport", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
public static extern int XQOCR_IsSupport();

[DllImport("XQOCR.dll", EntryPoint = "XQOCR_OPenByDefault", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
public static extern int XQOCR_OPenByDefault(string docPath);

DllImport 引用路径

DllImport 会在以下目录中寻找依赖:

  1. exe根目录
  2. system32目录
  3. 环境变量目录
posted @ 2017-12-21 18:39  學海無涯  阅读(741)  评论(0编辑  收藏  举报