当前位置:编程学习 > VB >>

VB获取CMD执行结果

VB获取CMD执行结果 text1中输入了一大堆CMD代码,

要求在后台用CMD执行这些代码,

并把所有结果显示在text2里

 

答案:你要的代码。。

调用方法 

ReDos text1.text,Temp

text2.text=Temp

 

'***************读取DOS文本*****************
'*         ReDos "Net Share",TempTxt       *
'*        TempTxt 为返回的文本             *
'*     作者:Christly    QQ:105120185      *
'*******************************************

Option Explicit
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, _
                                                                             ByVal lpCommandLine As String, _
                                                                             lpProcessAttributes As Any, _
                                                                             lpThreadAttributes As Any, _
                                                                             ByVal bInheritHandles As Long, _
                                                                             ByVal dwCreationFlags As Long, _
                                                                             lpEnvironment As Any, _
                                                                             ByVal lpCurrentDriectory As String, _
                                                                             lpStartupInfo As STARTUPINFO, _
                                                                             lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long

Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, _
                                                     phWritePipe As Long, _
                                                     lpPipeAttributes As SECURITY_ATTRIBUTES, _
                                                     ByVal nSize As Long) As Long
Private Type STARTUPINFO
    cb   As Long
    lpReserved   As Long
    lpDesktop   As Long
    lpTitle   As Long
    dwX   As Long
    dwY   As Long
    dwXSize   As Long
    dwYSize   As Long
    dwXCountChars   As Long
    dwYCountChars   As Long
    dwFillAttribute   As Long
    dwFlags   As Long
    wShowWindow   As Integer
    cbReserved2   As Integer
    lpReserved2   As Byte
    hStdInput   As Long
    hStdOutput   As Long
    hStdError   As Long
End Type
Private Type PROCESS_INFORMATION
    hProcess   As Long
    hThread   As Long
    dwProcessId   As Long
    dwThreadId   As Long
End Type
Private Type SECURITY_ATTRIBUTES
    nLength   As Long
&nbs

上一个:VB文本格式转换问题
下一个:vb制作邮件发送软件

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,