shellwaitapi.bas

来自「主要是对文件的一些操作:加密、解密文件」· BAS 代码 · 共 44 行

BAS
44
字号
Attribute VB_Name = "ShellWaitApi"
Option Explicit

Private Declare Function ShellExecuteEx Lib "shell32.dll" (SEI As SHELLEXECUTEINFO) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Type SHELLEXECUTEINFO
    cbSize As Long
    fMask As Long
    hWnd As Long
    lpVerb As String
    lpFile As String
    lpParameters As String
    lpDirectory As String
    nShow As Long
    hInstApp As Long
    '  Optional fields
    lpIDList As Long
    lpClass As String
    hkeyClass As Long
    dwHotKey As Long
    hIcon As Long
    hProcess As Long
End Type

Public Sub ShellWait(FileName As String, WorkDir As String, strParameters As String)

  Dim ShExecInfo As SHELLEXECUTEINFO

    ShExecInfo.cbSize = Len(ShExecInfo)
    ShExecInfo.fMask = &H40
    ShExecInfo.hWnd = frmMain.hWnd
    ShExecInfo.lpVerb = "open"
    ShExecInfo.lpFile = FileName
    ShExecInfo.lpParameters = strParameters
    ShExecInfo.lpDirectory = WorkDir
    ShExecInfo.nShow = 1
    ShExecInfo.hInstApp = vbNull
    Call ShellExecuteEx(ShExecInfo)
    Call WaitForSingleObject(ShExecInfo.hProcess, &HFFFF)

End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?