1.是这样的 调用dll问题 要用到 回调函数
用delegate
这样要new 回调函数 才能引用 这样的话是否要重新分配地址 
是否在静态函数里new,把回调地址传过去
然后在button_onclick调用是否可以保证回调的地址
2.如果可以的话 那位可以给个sample

解决方案 »

  1.   

    delegate的例子在msdn中有啊:
    using System;
    public class SamplesDelegate  {   // Declares a delegate for a method that takes in an int and returns a String.
       public delegate String myMethodDelegate( int myInt );   // Defines some methods to which the delegate can point.
       public class mySampleClass  {      // Defines an instance method.
          public String myStringMethod ( int myInt )  {
             if ( myInt > 0 )
                return( "positive" );
             if ( myInt < 0 )
                return( "negative" );
             return ( "zero" );
          }      // Defines a static method.
          public static String mySignMethod ( int myInt )  {
             if ( myInt > 0 )
                return( "+" );
             if ( myInt < 0 )
                return( "-" );
             return ( "" );
          }
       }   public static void Main()  {      // Creates one delegate for each method.
          mySampleClass mySC = new mySampleClass();
          myMethodDelegate myD1 = new myMethodDelegate( mySC.myStringMethod );
          myMethodDelegate myD2 = new myMethodDelegate( mySampleClass.mySignMethod );      // Invokes the delegates.
          Console.WriteLine( "{0} is {1}; use the sign \"{2}\".", 5, myD1( 5 ), myD2( 5 ) );
          Console.WriteLine( "{0} is {1}; use the sign \"{2}\".", -3, myD1( -3 ), myD2( -3 ) );
          Console.WriteLine( "{0} is {1}; use the sign \"{2}\".", 0, myD1( 0 ), myD2( 0 ) );
       }}
      

  2.   

    to:  jiezhi(风满袖)
    有没有button_onclick
    里面使用的sample
      

  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;
        }
    }
    这个是microsoft给我们 他是在public static void Main() 调用回调
    如何可以在button_onclick里面调用
      

  4.   

    http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/csref/html/vcrefthedelegatetype.asp
      

  5.   

    buttone的Click有定义好的Event,你可以直接用啊。
    button1.Click += new EventHandle(YourOnClickHandle);
    //...
    private void YourOnClickHandle(object sender,EventArgs e)
    {
       //...
    }