P/Invoke能够在asp.net 中使用哦
生活随笔
收集整理的這篇文章主要介紹了
P/Invoke能够在asp.net 中使用哦
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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:?該調(diào)用是?ASP.NET?Web?窗體設計器所必需的。
55????????????//
56????????????InitializeComponent();
57????????????base.OnInit(e);
58????????}
59????????
60????????/**////?<summary>
61????????///?設計器支持所需的方法?-?不要使用代碼編輯器修改
62????????///?此方法的內(nèi)容。
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(...)執(zhí)行時就不動了,內(nèi)部機理也不名所以,若是能夠SHOW的話,那豈不是不用ACTIVEX了嗎,一己之見而已了。根據(jù)理論是不行的,在。NET3.0(WinFX)可以將Win&Web集成到一起,那時將不分什么了,太恐怖了。。。。。
?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:?該調(diào)用是?ASP.NET?Web?窗體設計器所必需的。
55????????????//
56????????????InitializeComponent();
57????????????base.OnInit(e);
58????????}
59????????
60????????/**////?<summary>
61????????///?設計器支持所需的方法?-?不要使用代碼編輯器修改
62????????///?此方法的內(nèi)容。
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(...)執(zhí)行時就不動了,內(nèi)部機理也不名所以,若是能夠SHOW的話,那豈不是不用ACTIVEX了嗎,一己之見而已了。根據(jù)理論是不行的,在。NET3.0(WinFX)可以將Win&Web集成到一起,那時將不分什么了,太恐怖了。。。。。
轉(zhuǎn)載于:https://www.cnblogs.com/pccai/archive/2006/08/01/464935.html
總結
以上是生活随笔為你收集整理的P/Invoke能够在asp.net 中使用哦的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网络渗透测试实验二 网络嗅探与身份认证
- 下一篇: Worok:专门针对亚洲实体的网络间谍组