打印本文 打印本文 关闭窗口 关闭窗口
如何把用VB进行控制台命令的输入和输出.
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3161  更新时间:2009/4/23 15:42:23  文章录入:mintao  责任编辑:mintao
p;    =   105
      Width           =   1800
   End
   Begin VB.TextBox TxtOutput
      BackColor       =   &H00404040&
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   ''''False
         Italic          =   0   ''''False
         Strikethrough   =   0   ''''False
      EndProperty
      ForeColor       =   &H80000005&
      Height          =   3615
      Left            =   0
      Locked          =   -1  ''''True
      MultiLine       =   -1  ''''True
      ScrollBars      =   2  ''''Vertical
      TabIndex        =   2
      Top             =   540
      Width           =   8775
   End
   Begin VB.TextBox TxtExecute
      BackColor       =   &H00404040&
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   ''''False
         Italic          =   0   ''''False
         Strikethrough   =   0   ''''False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   375
      Left            =   1320
      TabIndex        =   0
      Top             =   120
      Width           =   5295
   End
   Begin VB.Label Label1
      Caption         =   "命令输入:"
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   ''''False
         Italic          =   0   ''''False
         Strikethrough   =   0   ''''False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   855
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Private Sub Cmdexe_Click()
 Dim Ret As Long, StrExe As String
 
 StrExe = TxtExecute.Text
 If Len(StrExe) = 0 Then
  MsgBox "命令怎么为空呢?", vbInformation, "奇怪?"
  Exit Sub
 End If
 
 Ret = DosInput(StrExe)
 
 If Ret <> 0 Then
  
   ''''MsgBox "在写入控制台管道的时候出现错误", vbInformation, "错误"
   Exit Sub
 End If
 sw False
End Sub

Private Sub Cmdget_Click()
  Dim strR As String
 Ret = DosOutput(strR)
 If Ret = 0 Then
  TxtOutput.Text = strR
 Else
  MsgBox "读取控制台输出错误", vbInformation, "错误"
 End If
 sw True
End Sub

Private Sub Form_Load()
 Dim Ret As Long
 Ret = InitDosIO()
 If Ret <> 0 Then
   MsgBox "控制台输入输出管道重定向初始化失败"
   End
 End If
 sw True
End Sub

Private Sub Form_Unload(Cancel As Integer)
 EndDosIo
End Sub
Private Sub sw(ByVal s As Boolean)
  cmdExe.Enabled = s
  cmdget.Enabled = Not s
End Sub
运行平台:2000/XP/稍微修改可用于98

上一页  [1] [2] [3] 

打印本文 打印本文 关闭窗口 关闭窗口