欢迎光临
我们一直在努力

P/Invoke能够在asp.net中使用-.NET教程,Asp.Net开发

建站超值云服务器,限时71元/月

   p/invoke能够在asp.net 中使用哦,是的,今天have some try le.  1
 2
 3using system;
 4using system.collections;
 5using system.componentmodel;
 6using system.data;
 7using system.drawing;
 8using system.web;
 9using system.web.sessionstate;
10using system.web.ui;
11using system.web.ui.webcontrols;
12using system.web.ui.htmlcontrols;
13
14using system.runtime.interopservices;
15using system.windows.forms;
16
17namespace test_myservice
18{
19    /**//// <summary>
20    /// webform1 的摘要说明。
21    /// </summary>
22    public class webform1 : system.web.ui.page
23    {
24        protected system.web.ui.webcontrols.textbox textbox1;
25        protected system.web.ui.webcontrols.label label1;
26        protected system.web.ui.webcontrols.button button1;
27        protected system.web.ui.webcontrols.textbox textbox2;
28        protected system.web.ui.webcontrols.textbox txtq;
29        protected system.web.ui.webcontrols.textbox txtd;
30
31        localhost.servicetest myservice = new test_myservice.localhost.servicetest();
32   
33        private void page_load(object sender, system.eventargs e)
34        {
35            // 在此处放置用户代码以初始化页面
36
37        }
38
39        [dllimport(“user32.dll”, charset=charset.ansi)]
40        public static extern int messagebox(int h, string m,
41            string c, int type);
42
43        [dllimport(“user32.dll”, charset=charset.ansi)]
44        public static extern boolean messagebeep(uint32 beeptype);
45
46        [dllimport(“kernel32.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            base.oninit(e);
58        }
59       
60        /**//// <summary>
61        /// 设计器支持所需的方法 – 不要使用代码编辑器修改
62        /// 此方法的内容。
63        /// </summary>
64        private void initializecomponent()
65        {   
66            this.button1.click += new system.eventhandler(this.button1_click);
67            this.load += new system.eventhandler(this.page_load);
68
69        }
70        #endregion
71
72        private void button1_click(object sender, system.eventargs e)
73        {
74            this.textbox2.text = myservice.who(this.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(convert.touint32(txtq.text),convert.touint32(txtd.text));
82
83        }
84    }
85}
86   其中messagebox.show(…)执行时就不动了,内部机理也不名所以,若是能够show的话,那岂不是不用activex了吗,一己之见而已了。根据理论是不行的,在。net3.0(winfx)可以将win&web集成到一起,那时将不分什么了,太恐怖了。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » P/Invoke能够在asp.net中使用-.NET教程,Asp.Net开发
分享到: 更多 (0)