网站首页 > 网络编程教程 > ASP.NET教程 > P/Invoke能够在asp.net中使用

P/Invoke能够在asp.net中使用

  • 作者:互联网
  • 时间:2009-06-30 16:57:01

     P/Invoke能够在asp.net 中使用哦,是的,今天have some try le.  1
 2
 3using System;
 4using Sy***m.Collections;
 5using Sy***m.ComponentModel;
 6using Sy***m.Data;
 7using Sy***m.Drawing;
 8using Sy***m.Web;
 9using Sy***m.Web.SessionState;
10using Sy***m.Web.UI;
11using Sy***m.Web.UI.WebControls;
12using Sy***m.Web.UI.HtmlControls;
13
14using Sy***m.Runtime.InteropServices;
15using Sy***m.Windows.Forms;
16
17namespace Test_MyService
18{
19    /**////


20    /// WebForm1 的摘要说明。
21    ///

22    public class WebForm1 : Sy***m.Web.UI.Page
23    {
24        protected Sy***m.Web.UI.WebControls.TextBox TextBox1;
25        protected Sy***m.Web.UI.WebControls.Label Label1;
26        protected Sy***m.Web.UI.WebControls.Button Button1;
27        protected Sy***m.Web.UI.WebControls.TextBox TextBox2;
28        protected Sy***m.Web.UI.WebControls.TextBox txtQ;
29        protected Sy***m.Web.UI.WebControls.TextBox txtD;
30
31        lo***host.ServiceTest myservice = new Test_MyService.lo***host.ServiceTest();
32   
33        private void Page_Load(object sender, Sy***m.EventArgs e)
34        {
35            // 在此处放置用户代码以初始化页面
36
37        }
38
39        [DllImport("us***2.dll", Ch***et=CharSet.Ansi)]
40        public static extern int MessageBox(int h, string m,
41            string c, int type);
42
43        [DllImport("us***2.dll", Ch***et=CharSet.Ansi)]
44        public static extern Boolean MessageBeep(UInt32 beepType);
45
46        [DllImport("Ke***l32.dll", SetLastError=true)]
47        static extern Boolean Beep(UInt32 frequency, UInt32 duration);
48
49
50        Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
51        override protected void OnInit(EventArgs e)
52        {
53            //
54            // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
55            //
56            InitializeComponent();
57            ba***OnInit(e);
58        }
59       
60        /**////
61        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
62        /// 此方法的内容。
63        ///

64        private void InitializeComponent()
65        {   
66            th***Button1.Click += new Sy***m.EventHandler(th***Button1_Click);
67            th***Load += new Sy***m.EventHandler(th***Page_Load);
68
69        }
70        #endregion
71
72        private void Button1_Click(object sender, Sy***m.EventArgs e)
73        {
74            th***TextBox2.Text = my***vice.Who(th***TextBox1.Text);
75
76//            string pText = "Hello World!";
77//            string pCaption = "PInvoke Test";
78//            MessageBox(0, pText, pCaption, 0);
79
80            //MessageBeep(0x00000010);
81            Beep(Co***rt.ToUInt32(tx***Text),Co***rt.ToUInt32(tx***Text));
82
83        }
84    }
85}
86   其中Me***geBox.Show(...)执行时就不动了,内部机理也不名所以,若是能够SHOW的话,那岂不是不用ACTIVEX了吗,一己之见而已了。根据理论是不行的,在。NET3.0(WinFX)可以将Win&Web集成到一起,那时将不分什么了,太恐怖了。