C#免注册使用大漠插件实现窗体绑定 dm.dll_v3.1233 亲测有效

  • 饿了么红包
    每天可领 全场通用
  • 本文章向大家介绍C#免注册使用大漠插件实现窗体绑定,主要包括C#免注册使用大漠插件实现窗体绑定使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

    一、引用Ddm.dll

    在VS中:项目–添加引用–COM–DM.DLL 这步很关键。

    二、注册大漠插件

    这是注册DLL到系统的一个方法,注册大漠则调用 AutoRegCom(“regsvr32 -s dm.dll”);

    三、实例化大漠对象

    Dm.dmsoft dm = new Dm.dmsoft();

    四、调用大漠的方法

    命名空间:WindowsFormsApp2

    在窗体下加一个:button1

    具体代码如下:

    namespace WindowsFormsApp2
    {
        public partial class Form1 : Form
        {
            Dm.dmsoft dm = new Dm.dmsoft();
            public Form1()
            {
                InitializeComponent();
                AutoRegCom("regsvr32 -s dm.dll");
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show(dm.Ver());
    
            }
            static string AutoRegCom(string strCmd)
            {
                string rInfo;
                try
                {
                    Process myProcess = new Process();
                    ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("cmd.exe");
                    myProcessStartInfo.UseShellExecute = false;
                    myProcessStartInfo.CreateNoWindow = true;
                    myProcessStartInfo.RedirectStandardOutput = true;
                    myProcess.StartInfo = myProcessStartInfo;
                    myProcessStartInfo.Arguments = "/c " + strCmd;
                    myProcess.Start();
                    StreamReader myStreamReader = myProcess.StandardOutput;
                    rInfo = myStreamReader.ReadToEnd();
                    myProcess.Close();
                    rInfo = strCmd + "\r\n" + rInfo;
                    return rInfo;
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
            }

    调用:

    private void button2_Click(object sender, EventArgs e)
            {
                int hwnd = dm.FindWindow("", "GaugeStudio");//获取标题为“GaugeStudio”的窗体句柄
                _ = dm.BindWindow(hwnd, "dx2", "windows3", "windows", 0);//win10下的后台绑定
                dm.MoveTo(30, 30);//鼠标移动到GaugeStudio窗体的30,30位置
                dm.LeftClick();//鼠标单击左键
            }

    常见问题:

    提示‘模块已加载,但对dllregisterserver的调用失败’的解决方案,有这种提示,多半是因为没有以管理员身份运行cmd窗口。
    提示‘模块已加载,但对dllregisterserver的调用失败’的解决方案
    解决方法也是简单的。点击桌面左下方的开始按钮,输入搜索cmd,或者在电脑C:WindowsSystem32目录下找到cmd程序。右键点击cmd程序,选择以管理员身份运行

  • 外卖/打车/电影
    各类优惠券 每天都有
  • © 版权声明
    THE END
    喜欢就支持一下吧
    点赞19 分享
    评论 抢沙发
    头像
    欢迎您留下宝贵的见解!
    提交
    头像

    昵称

    取消
    昵称表情代码图片