vb6.0的各种SHELL,CMD内部命令、外部命令、SHELL任意文件

 1 Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 2 '能打开任意文件的shell
 3 Public Function ShellAll(nHwnd As Long, ByVal strFilePath As String, Optional ByVal strCanShu As String = "") As Boolean
 4     On Error GoTo ShellAllErr
 5     ShellAll = True
 6     strFilePath = Trim(strFilePath)
 7     Dim nLs As Long
 8     nLs = ShellExecute(nHwnd, "open", strFilePath, vbNullString, strCanShu, vbNormalFocus)
 9     If nLs <= 32 Then
10         ShellAll = False
11     End If
12     Exit Function
13 ShellAllErr:
14     Err.Clear
15     ShellAll = False
16 End Function
17 '不提示错误的shell,可SHELL外部DOs命令
18 Public Function myShell(strFile As String) As Boolean
19     On Error GoTo shellError
20     myShell = True
21     Dim k As Long
22     k = Shell(strFile, vbNormalFocus)
23     If k = 0 Then myShell = False
24     Exit Function
25 shellError:
26     myShell = False
27 End Function
28 'SHELL DOS的内部命令
29 Public Sub ShellDocIn(ByVal strCmd As String)
30     On Error Resume Next '此过程不保证一定执行成功
31     strCmd = Trim(strCmd)
32     Shell "Cmd.exe /k " & strCmd, vbHide
33 End Sub

 

转载于:https://www.cnblogs.com/lhghroom/p/7663476.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值