当前位置:编程学习 > C#/ASP.NET >>

用vb.net开发api viewer(1)

答案:下面我们要做的是利用vb.net开发类似于vb6.0中的api viewer tools的工具,它可以向我们展示利用vb.net和C#如何调用win32 的api函数
利用vb.net或c#调用api不是一件容易的事,因为语法等已经发生了很大的变化,愿这篇文章给大家带来帮助
确信你的机器文件包含安装vs6.0所安装的 Microsoft Visual Studio\Common\Tools\Winapi目录下的win32api.txt等文件
我们要查看的就是这个文件,如同使用api viewer tools一样软件的界面如下

下面我将给出代码
新建vb.net应用程序命名为api.net
添加引用
system
system.data
system.drawing
system.windows.forms
system.xml
添加窗体(Viewer.vb)
代码如下
Public Class frmViewer
    Inherits System.Windows.Forms.Form
#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
    Friend WithEvents cmbOption As System.Windows.Forms.ComboBox
    Friend WithEvents lstItem As System.Windows.Forms.ListBox
    Friend WithEvents txtSearch As System.Windows.Forms.TextBox
    Friend WithEvents txtOutPut As System.Windows.Forms.RichTextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents txtAdd As System.Windows.Forms.RichTextBox
    Friend WithEvents btAdd As System.Windows.Forms.Button
    Friend WithEvents btCopy As System.Windows.Forms.Button
    Friend WithEvents btClear As System.Windows.Forms.Button
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents optPublic As System.Windows.Forms.RadioButton
    Friend WithEvents optPrivate As System.Windows.Forms.RadioButton
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents optCSharp As System.Windows.Forms.RadioButton
    Friend WithEvents optVB As System.Windows.Forms.RadioButton
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container
    '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.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.txtAdd = New System.Windows.Forms.RichTextBox()
        Me.optVB = New System.Windows.Forms.RadioButton()
        Me.btClear = New System.Windows.Forms.Button()
        Me.cmbOption = New System.Windows.Forms.ComboBox()
        Me.btCopy = New System.Windows.Forms.Button()
        Me.lstItem = New System.Windows.Forms.ListBox()
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.txtOutPut = New System.Windows.Forms.RichTextBox()
        Me.btAdd = New System.Windows.Forms.Button()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.MenuItem5 = New System.Windows.Forms.MenuItem()
        Me.MenuItem6 = New System.Windows.Forms.MenuItem()
        Me.optCSharp = New System.Windows.Forms.RadioButton()
        Me.MenuItem3 = New System.Windows.Forms.MenuItem()
        Me.MainMenu1 = New System.Windows.Forms.MainMenu()
        Me.MenuItem1 = New System.Windows.Forms.MenuItem()
        Me.MenuItem2 = New System.Windows.Forms.MenuItem()
        Me.MenuItem4 = New System.Windows.Forms.MenuItem()
        Me.optPrivate = New System.Windows.Forms.RadioButton()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.optPublic = New System.Windows.Forms.RadioButton()
        Me.GroupBox2 = New System.Windows.Forms.GroupBox()
        Me.txtSearch = New System.Windows.Forms.TextBox()
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.SuspendLayout()
        '
        'txtAdd
        '
        Me.txtAdd.Location = New System.Drawing.Point(9, 280)
        Me.txtAdd.Name = "txtAdd"
    &nb

上一个:Windows消息类,续一
下一个:用vb.net开发api viewer(2)

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,