新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
VB.NET調(diào)用WinAPI實例探討
VB.NET作為一款功能強大的面向?qū)ο笳Z言,為我們帶來了很多不一樣的體驗。我們今天可以通過對VB.NET調(diào)用WinAPI的操作技巧的掌握,來體驗一下這款語言給我們帶來的不同之處,從而初步掌握它的應用技巧。

創(chuàng)新互聯(lián)建站憑借專業(yè)的設(shè)計團隊扎實的技術(shù)支持、優(yōu)質(zhì)高效的服務意識和豐厚的資源優(yōu)勢,提供專業(yè)的網(wǎng)站策劃、成都網(wǎng)站設(shè)計、做網(wǎng)站、成都外貿(mào)網(wǎng)站建設(shè)公司、網(wǎng)站優(yōu)化、軟件開發(fā)、網(wǎng)站改版等服務,在成都10年的網(wǎng)站建設(shè)設(shè)計經(jīng)驗,為成都成百上千家中小型企業(yè)策劃設(shè)計了網(wǎng)站。
以下為VB.NET調(diào)用WinAPI的演示實例:
- Declare Auto Function MBox Lib
"user32.dll" _- Alias "MessageBox" (ByVal hWnd
As Integer, _- ByVal txt As String, ByVal
caption As String, _- ByVal Typ As Integer) As Integer
- '定義一些要調(diào)用參數(shù)
- Const MB_ICONQUESTION = &H20L
- Const MB_YESNO = &H4
- Const IDYES = 6
- Const IDNO = 7
- Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e
As System.EventArgs) Handles
Button1.Click- Dim RetVal As Integer ' 存儲返回的值.
- RetVal = MBox(0, "調(diào)用WinApi成功否?",
"Windows API 信息框", _- MB_ICONQUESTION Or MB_YESNO)
- ' Check the return value.
- If RetVal = IDYES Then
- MsgBox("您選擇了是")
- Else
- MsgBox("您選擇了不是")
- End If
- End Sub
以下附上本CALLAPI.vb的所有代碼。各位可根據(jù)自己的要求對這段VB.NET調(diào)用WinAPI代碼自行修改。
- Public Class CallApi
- Inherits System.Windows.Forms.Form
- Declare Auto Function MBox Lib
"user32.dll" _- Alias "MessageBox" (ByVal hWnd
As Integer, _- ByVal txt As String, ByVal
caption As String, _- ByVal Typ As Integer) As Integer
- '定義一些要調(diào)用參數(shù)
- Const MB_ICONQUESTION = &H20L
- Const MB_YESNO = &H4
- Const IDYES = 6
- Const IDNO = 7
- #Region " Windows Form Designer
generated code "- Public Sub New()
- MyBase.New()
- 'This call is required by the
Windows Form Designer.- InitializeComponent()
- 'Add any initialization after the
InitializeComponent() call- End Sub
- 'Form overrides dispose to clean
up the component list.- Protected Overloads Overrides Sub
Dispose(ByVal disposing As Boolean)- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
- 'Required by the Windows
Form Designer- Private components As System.
ComponentModel.IContainer- 'NOTE: The following procedure is
required by the Windows Form Designer- 'It can be modified using the
Windows Form Designer.- 'Do not modify it using the code editor.
- Friend WithEvents Button1 As System.
Windows.Forms.Button
Private Sub InitializeComponent()- Me.Button1 = New System.Windows.Forms.Button()
- Me.SuspendLayout()
- '
- 'Button1
- '
- Me.Button1.Location = New System.
Drawing.Point(88, 56)- Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(168, 48)
- Me.Button1.TabIndex = 0
- Me.Button1.Text = "調(diào)用API的信息框"
- '
- 'CallApi
- '
- Me.AutoScaleBaseSize = New System.
Drawing.Size(5, 13)- Me.ClientSize = New System.Drawing.Size(384, 205)
- Me.Controls.AddRange(New System.Windows.
Forms.Control() {Me.Button1})- Me.Name = "CallApi"
- Me.Text = "CallApi"
- Me.ResumeLayout(False)
- End Sub
- #End Region
- Private Sub Button1_Click(ByVal sender
As System.Object, ByVal e As System.
EventArgs) Handles Button1.Click- Dim RetVal As Integer ' 存儲返回的值.
- RetVal = MBox(0, "調(diào)用WinApi成功否?",
"Windows API 信息框", _- MB_ICONQUESTION Or MB_YESNO)
- ' Check the return value.
- If RetVal = IDYES Then
- MsgBox("您選擇了是")
- Else
- MsgBox("您選擇了不是")
- End If
- End Sub
- End Class
VB.NET調(diào)用WinAPI代碼示例就為大家介紹到這里。
文章題目:VB.NET調(diào)用WinAPI實例探討
當前網(wǎng)址:http://fisionsoft.com.cn/article/dhcocij.html


咨詢
建站咨詢
