使用VB.net调用WinAPI方法介绍

作者:袖梨 2022-07-02
本贴精华段:
    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
    '定义一些要调用参数
    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, "调用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的所有代码。各位可根据自己的要求自行修改。

相关文章

精彩推荐