資源簡介
【實例簡介】C#調用大漠實例
首先添加 CDmSoft.cs 到工程 兩個DLL放到EXE目錄
public static CShapDM.CDmSoft dm = new CShapDM.CDmSoft("dm.dll");
申請個全局變量
然后就可以使用了
例如:
dm.Ver();
【核心代碼】
class CDmSoft : IDisposable
{#region import DLL 函數
[DllImport("dmc.dll",CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr CreateDM(string dmpath);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FreeDM();
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string Ver(IntPtr dm);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int SetPath(IntPtr dm,string path);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern string Ocr(IntPtr dm,int x1,int y1,int x2,int y2,string color,double sim);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int FindStr(IntPtr dm,int x1,int y1,int x2,int y2,string str,string color,double sim,out object x,out object y);
[DllImport("dmc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int GetResultCount(IntPtr dm,string str);
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.Runtime.InteropServices;
namespace?CShapDM
{
????///?
????///?大漠插件C#免注冊調用類
????///?作者:清風撫斷云
????///?QQ:274838061
????///?本模塊必須包含dmc.dll?實現不用注冊dm.dll?到系統可以動態調用
????///?
????class?CDmSoft?:?IDisposable
????{
????????
????????#region?import?DLL?函數
????????[DllImport(“dmc.dll“CharSet?=?CharSet.Unicode?CallingConvention?=?CallingConvention.StdCall)]
????????public?static?extern?IntPtr?CreateDM(string?dmpath);
????????[DllImport(“dmc.dll“?CharSet?=?CharSet.Unicode?CallingConvention?=?CallingConvention.StdCall)]
????????public?static?extern?int?FreeDM();
????????[DllImport(“dmc.dll“?CharSet?=?CharSet.Unicode?CallingConvention?=?CallingConvention.StdCall)]
????????pub
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????9728??2013-10-11?21:40??C#免注冊大漠.doc
?????文件?????109288??2013-10-11?20:57??CDmSoft.cs
?????文件?????823296??2012-08-10?15:58??dm.dll
?????文件?????390656??2012-12-20?18:37??dmc.dll
-----------?---------??----------?-----??----
??????????????1332968????????????????????4
- 上一篇:分享,C#實現OutLook郵箱郵件檢索
- 下一篇:c#生成二維碼條形碼 打印
評論
共有 條評論