www.pudn.com > CS_CALLAPI_20111018A.rar > Form1.cs, change:2011-10-18,size:1257b


using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
using CS_CALLAPI; 
 
namespace CS_CALLAPI 
{ 
    public partial class Form1 : Form 
    { 
        public delegate int TestAddDelegate(int a,int b); 
        public delegate int TestMinusDelegate(int a, int b); 
        public Form1() 
        { 
            InitializeComponent(); 
        } 
 
        private void buttoncallapi_Click(object sender, EventArgs e) 
        { 
            CALLAPI TEST1API = new CALLAPI(); 
            TEST1API.LoadDll("USERAPIDLL.dll"); 
            TestAddDelegate testadd = (TestAddDelegate)TEST1API.Invoke("testadd", typeof(TestAddDelegate)); 
            int testvar1 = testadd(1, 2); 
            TEST1API.FreeDll(); 
            CALLAPI TEST2API = new CALLAPI(); 
            TEST2API.LoadDll("USERAPIDLL.dll"); 
            TestMinusDelegate testminus = (TestMinusDelegate)TEST2API.Invoke("testminus", typeof(TestMinusDelegate)); 
            int testvar2 = testminus(1, 2); 
            TEST2API.FreeDll(); 
            // գ 
            TEST1API = null; 
            TEST2API = null; 
            GC.Collect(); 
        } 
    } 
}