using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("omjk.dll", EntryPoint = "SetDllPathA")] //必需的代码
public static extern int SetDllPathA(string path, int mode); //必需的代码
public static dmsoft dm_dm;
private void Form1_Load(object sender, EventArgs e)
{
//我是把dm.dll改名为omcj.dll(插件文件) RegDll.dll改名为omjk.dll(免注册接口文件) (改名的目的是防检测) //并放到了资源文件
/* 重点:大漠压缩包内的那个24K的RegDll.dll是不能免注册调用的
* 要免注册调用需要下载52K的那个,官方下载去吧 。
* 别处下载的鬼知道里面会不会缺斤少两的。我就是在这儿吃亏的 。
* 浪费了好多时间 还一直发生各种错误和异常!!!!
*/
//下面是判断运行目录下是否有这两个文件,如果没有则写出文件到运行目录下
if (!File.Exists("omcj.dll"))
{
//写出插件文件
using (FileStream x = new FileStream("omcj.dll", FileMode.OpenOrCreate, FileAccess.Write))
{
byte[] s = j;
x.Write(s, 0, s.Length);
}
}
if (!File.Exists("omjk.dll"))
{
//写出插件接口文件
using (FileStream x = new FileStream("omjk.dll", FileMode.OpenOrCreate, FileAccess.Write))
{
byte[] s = jk;
x.Write(s, 0, s.Length);
}
}
/
/调用接口文件注册插件
int res = SetDllPathA("omcj.dll", 0); //必需的代码
//创建对象
dm_dm = new dmsoft();//主线程对象创建一次就可以了 ,不然再次创建的就是子线程对象了
//判断版本 这儿是为了防止目录下被防止其他版本造成后续的异常错误
if (dm_dm.Ver() != "7.1904")
{
//如果版本不一致,提示用户手动删除文件
MessageBox.Show("请先关闭程序,手动删除omcj和omjk文件。路径是:\r\n" + Application.StartupPath, "版本错误");
Application.Exit();
}
}
}
}