有个叫大漠插件的DLL文件,我想调用它怎没弄?求大虾帮帮忙 3QDllImport("MY.LLL"] 这个方法貌似没用
据DLL作者说 DLL使用VC6写的

解决方案 »

  1.   

    项目上右击,选择“添加引用”,然后切换到“浏览”选项卡,选择你要引用的DLL即可
      

  2.   

    用VS打开工程,会有一个References的文件夹,点击右键 选择 Add References 即可。
      

  3.   

    额 我引用了 也using dm了 写了句代码:
     Dm.Idmsoft.BindWindow(0, "dx", "dx", "dx", 0); //对象浏览器里面复制来的
    调用dm.dll里面的函数 说:
    D:\My Documents\Visual Studio 2008\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs(23,13): 错误 CS0120: 非静态的字段、方法或属性“Dm.Idmsoft.BindWindow(int, string, string, string, int)”要求对象引用怎么办?
      

  4.   

    说明这个Dm.Idmsoft成员是非静态的,你要构造:Dm.Idmsoft soft =new Dm.Idmsoft();//可能还有参数
    soft.BindWindow(0, "dx", "dx", "dx", 0);
      

  5.   

    Dm.Idmsoft soft =new Dm.Idmsoft();//可能还有参数
    soft.BindWindow(0, "dx", "dx", "dx", 0);额 这个报错:D:\My Documents\Visual Studio 2008\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs(23,31): 错误 CS0144: 无法创建抽象类或接口“Dm.Idmsoft”的实例在VB中 新建一个对象类型的变量dm 用shell函数把COM接口的DLL注册到系统后
    然后一句:Set dm = CreateObject("dm.dmsoft") 创建对象就OK了
      

  6.   

    虽然7楼的那位大虾还是没对 但是这个也让我想到了方法
    代码:
     long hwnd;      
      string jub;        
     Dm.dmsoft soft = new Dm.dmsoft();//          
      hwnd = soft.FindWindow("wndclass_desked_gsk", null);
      
      

  7.   

    虽然7楼的那位大虾还是没对 但是这个也让我想到了方法
    代码:
     long hwnd;      
      string jub;        
     Dm.dmsoft soft = new Dm.dmsoft();//          
      hwnd = soft.FindWindow("wndclass_desked_gsk", null);
      
      

  8.   

    顺便问下 创建实例soft在button1的单击事件中 怎么弄成全局的?
    也就是在程序的任何地方 都能使用soft这个对象来调用dm.dll内的函数库
      

  9.   

    dll可以用很多编程语言写的,也可以在其他语言调用它,楼上有很多兄弟都给你说对了,很实用,也很常用。
      

  10.   

    在你的Form1类,添加成员变量:  private Dm.dmsoft soft=null;
      

  11.   

    声明DLL及参数
    调用DLL
    引用参数
    返回
      

  12.   

    先在解决方案资源管理器中添加引用,
    例子如下
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Dm;//定义大漠空间namespace Plug
    {
        public partial class Form1 : Form
        {
            dmsoft dm = new dmsoft();//实例化大漠对象
            public Form1()
            {
                InitializeComponent();
            }
            //Form[设计]中双击添加Load事件
            private void Form1_Load(object sender, EventArgs e)
            {
                MessageBox.Show(dm.Ver());//弹出版本号
            }
            //Form[设计]中右键》属性》事件列表中添加FormClosing事件
            private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (MessageBox.Show("确定要关闭程序吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    dm.UnBindWindow();//释放大漠对象
                    e.Cancel = true;
                }
            }
        }
    }