用C#创建一个类库,将这些函数都封装成一个类的方法或属性。
动态的或者静态的都可以。静态的不必实例化,动态的则必须
比如:
类库名字:'Attend3X.dll',
其中有一个Attend3X类,
她又一个方法:public static void InitMachine(byte Port,Address)//静态方法
在你写的程序中用;using Attend3X,就是把这个类库引用过来
然后这样调用
......
Attend3X.InitMachine(port,address)//port,address为byte型参数
......

解决方案 »

  1.   


    主要问题是对外部函数的调用。声名函数
    [DllImport("User32.dll")]
    private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);调用函数
    ShowWindowAsync (instance.MainWindowHandle , WS_SHOWNORMAL);或者添加一个外部函数的引用,这样.net会自动生成Interop对应的文件,
    在.net里调用也会很方便。
      

  2.   

    function SetCallBack(func:CallBack_DealCardNo):integer;stdcall;external 'Attend3X.dll';
    就这个,请大家以此举个调用例子,稍微详细一点,其他的例子就免了
      

  3.   

    using System;
    using System.Runtime.InteropServices;public delegate bool CallBack(int hwnd, int lParam);public class EnumReportApp {    [DllImport("user32")]
        public static extern int EnumWindows(CallBack x, int y);     public static void Main() 
        {
            CallBack myCallBack = new CallBack(EnumReportApp.Report);
            EnumWindows(myCallBack, 0);
        }   public static bool Report(int hwnd, int lParam) { 
            Console.Write("Window handle is ");
            Console.WriteLine(hwnd);
            return true;
        }
    }