- 导入命名空间
using System.Runtime.InteropServices;
- 把
非托管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 会在以下目录中寻找依赖:
- exe根目录
- system32目录
- 环境变量目录