zoukankan      html  css  js  c++  java
  • vb用createprocess启动其他应用程序

    Option Explicit

    Private Type PROCESS_INFORMATION

            hProcess As Long

            hThread As Long

            dwProcessId As Long

            dwThreadId As Long

    End Type

    Private Type STARTUPINFO

            cb As Long

            lpReserved As String

            lpDesktop As String

            lpTitle As String

            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 Long

            hStdInput As Long

            hStdOutput As Long

            hStdError As Long

    End Type

    Private Type SECURITY_ATTRIBUTES

            nLength As Long

            lpSecurityDescriptor As Long

            bInheritHandle As Long

    End Type

    Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" ( _

      ByVal lpApplicationName As String, _

      ByVal lpCommandLine As String, _

      lpProcessAttributes As SECURITY_ATTRIBUTES, _

      lpThreadAttributes As SECURITY_ATTRIBUTES, _

      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 WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    Private Sub Command1_Click()

      Dim sInfo As STARTUPINFO

      Dim psInfo As PROCESS_INFORMATION

      Dim pAttr As SECURITY_ATTRIBUTES

      Dim tAttr As SECURITY_ATTRIBUTES

      Dim nRet As Long

      Dim nElapse As Integer

      nRet = CreateProcess("C:Program Files (x86)360360zip360zip.exe", "", pAttr, tAttr, 0, 0, 0, "c:", sInfo, psInfo)

      If nRet = 0 Then Exit Sub

      nElapse = 0

      While 1 > 0

        nRet = WaitForSingleObject(psInfo.hProcess, 1000)

        If nRet = 0 Then

          MsgBox "Done!"

          Exit Sub

        End If

       

        Label1.Caption = CStr(nElapse)

        nElapse = nElapse + 1

        Sleep (1000)

        DoEvents

      Wend

    End Sub

    摘自 JOEL.LEE的专栏

  • 相关阅读:
    Java基础-学习笔记(十)——内部类(嵌套类)
    Java基础-学习笔记(九)——static关键字
    Java基础-学习笔记(八)——函数的参数传递
    JS获取当前时间转成时间戳,并比较两个时间戳得出相差的天数
    tp6的with关联使用(删查),insertAll批量增加
    Vue父子组件的相互调用方法与参数
    Vue父子组件之间的通信
    Vue组价的基本使用
    PHP接入图片文字识别AIP
    EC6模块化的导入和导出
  • 原文地址:https://www.cnblogs.com/wgscd/p/9557846.html
Copyright © 2011-2022 走看看