Public 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
    lpIDList As Long
    lpClass As String
   
hkeyClass As Long
    dwHotKey As Long
    hIcon As Long
    hProcess
As Long
End Type

Public Const SEE_MASK_NOCLOSEPROCESS = &H40
Public Const SW_SHOWNORMAL
= 1

Public Declare Function ShellExecuteEx Lib "shell32.dll" Alias
"ShellExecuteExA" _
(lpExecInfo As SHELLEXECUTEINFO) As Long
   

Public Const SE_ERR_FNF = 2
Public Const SE_ERR_NOASSOC = 31

Public Declare Function WaitForSingleObject Lib "kernel32.dll" _
(ByVal
hHandle As Long, ByVal dwMilliseconds As Long) As Long
   
Public Const
INFINITE = &HFFFF
Public Const WAIT_TIMEOUT = &H102

Sub Upload1()
    Dim sei As SHELLEXECUTEINFO  ' structure used by the
function
    Dim retval As Long  ' return value
   
    ' Load the
information needed to open C:\Bootlog.txt into the structure.
    With
sei
        ' Size of the structure
        .cbSize = Len(sei)
       
' Use the optional hProcess element of the structure.
        .fMask =
SEE_MASK_NOCLOSEPROCESS
        ' Handle to the window calling this
function.
'        .hwnd = Me.hwnd
        ' The action to perform: open
the file.
        .lpVerb = "open"
        ' The file to open.
       
.lpFile = strPath + "IT3CW32.EXE"
        ' No additional parameters are
needed here.
        .lpParameters = strPath + "CARTONS.DAT +R +E
+V"
        ' The default directory -- not really necessary in this
case.
        .lpDirectory = ""
        ' Simply display the
window.
        .nShow = SW_SHOWNORMAL
        ' The other elements of the
structure are either not used
        ' or will be set when the function
returns.
    End With
   
    ' Open the file using its associated
program.
    retval = ShellExecuteEx(sei)
    If retval = 0
Then
        ' The function failed, so report the error. 
Err.LastDllError
        ' could also be used instead, if you
wish.
        Select Case sei.hInstApp
        Case
SE_ERR_FNF
            MsgBox "Program not found."
        Case
SE_NOASSOC
            MsgBox "No associate"
        Case
Else
            MsgBox "Unexpected Error"
        End Select
   
Else
        ' Wait for the opened process to close before continuing.
Instead of waiting once
        ' for a time of INFINITE, this example
repeatedly checks to see if the process
        ' is still open.  This allows
the DoEvents VB function to be called, preventing
        ' our program from
appearing to lock up while it waits.
        Do
           
DoEvents
            retval = WaitForSingleObject(sei.hProcess, 0)
       
Loop While retval = WAIT_TIMEOUT
        ' MsgBox "Operation
Completed"
        bUpload = True
    End If
End Sub

使用API调用外部程序并监控程序状态的更多相关文章

  1. Windows API调用外部程序

    要在应用程序中启动其他的应用程序,有3个函数可以使用,下面我一一说说他们(我以打开D:\Program Files\zeecalls\目录下的zeecalls.exe应用程序为例): 1.Winexe ...

  2. k8s监控api调用

    k8s监控api调用 curl -s --cacert /etc/kubernetes/ssl/ca.pem -basic -u fengjian:fengjian --insecure -X GET ...

  3. C#调用API向外部程序发送数据

    C#调用API向外部程序发送数据 最近有可能要做一个项目.在项目中有这么一个功能,在A程序中调用B程序,同时在A程序中进行登陆后,要将A程序的登录名和密码自动填充到B程序的登陆对话框中,这样B程序就不 ...

  4. 【阿里云API】 阿里云API调用的若干说明

    阿里云API 为了监控我们使用的一些阿里云产品,需要些一些脚本,定时调用这些脚本来获得相关阿里云产品的信息. ■ 概述 调用阿里云API大约分成两类方法,一个是直接从HTTP协议开始,自己根据阿里云的 ...

  5. Java魔法堂:调用外部程序

    前言 Java虽然五脏俱全但总有软肋,譬如获取CPU等硬件信息,当然我们可以通过JNI调用C/C++来获取,但对于对C/C++和Windows API不熟的码农是一系列复杂的学习和踩坑过程.那能不能通 ...

  6. Vue.js——使用$.ajax和vue-resource实现OAuth的注册、登录、注销和API调用

    概述 上一篇我们介绍了如何使用vue resource处理HTTP请求,结合服务端的REST API,就能够很容易地构建一个增删查改应用.这个应用始终遗留了一个问题,Web App在访问REST AP ...

  7. 信鸽推送 .NET (C#) 服务端 SDK rest api 调用库(v1.2)

    信鸽推送 .NET  服务端 SDK rest api 调用库-介绍 该版本是基于信鸽推送v2版本的时候封装的,先拿出来与大家分享,封装还还凑合,不依赖其他http调用件,唯一依赖json序列化dll ...

  8. MySql UDF 调用外部程序和系统命令

    1.mysql利用mysqludf的一个mysql插件可以实现调用外部程序和系统命令 下载lib_mysqludf_sys程序:https://github.com/mysqludf/lib_mysq ...

  9. xmlrpc实现bugzilla api调用(无会话保持功能,单一接口请求)

    xmlrpc实现bugzilla4   xmlrpc api调用(无会话保持功能,单一接口请求),如需会话保持,请参考我的另外一篇随笔(bugzilla4的xmlrpc接口api调用实现分享: xml ...

随机推荐

  1. a标记无效问题

    当在<a href=''></a>这个标记中嵌入<td></td>  就会导致部分浏览器无法单击,所以在开发HTML页面的时候,一定不要在 a标记中嵌入 ...

  2. STM32知识点纪要

    1.GPIO BSRR(端口位设置寄存器)是赋1相应IO拉高,赋0无影响 BRR(端口位清除寄存器)是是赋1相应IO拉低,赋0无影响 2.UART 连线TX—TX,RX—RX 3.JTAG和SWD接口 ...

  3. halcon之屌炸天的自标定(1)

      本次先对halcon的自标定做个整体介绍,了解屌炸天的自标定在实际应用中的应用与实现方法,具体的编程细节将在后续的文章中介绍. halcon提供了一种自标定的算子,它可以在不用标定板的情况下,标定 ...

  4. 让IE兼容console——“由于出现错误80020101而导致此项操作无法完成”的解决方案

    问题描述 经测试发现问题只出现在: 1.原生IE8(其他版本IE模拟出的IE8无此问题) 2.从打开IE8没有开启过F12(曾经开启过又关闭的无此问题) IE8报错“由于出现错误80020101而导致 ...

  5. 怎样使用visio画数据库模型图

    怎样使用visio画数据库模型图     计算机专业的学生在做程序的需求分析文档或者毕业设计的时候,针对自己开发的系统,肯定少不了要画数据库的模型图.许多同学喜欢用word实现,当然,word可以满足 ...

  6. ES6中箭头函数的作用

    我们知道在ES6中,引入了箭头函数,其本质就是等同有ES5中的函数.类似于下面的写法: let test1=() => “abc”; let test2=() => { return “a ...

  7. iOS-----MFMessageCompose 和 MFMailComposeViewController的使用方法

    MFMessageCompose 和 MFMailComposeViewController的使用方法 使用MFMessageComposeViewCOntroller发短信 应用想自己提供界面让用户 ...

  8. 20155315 2016-2017-2 《Java程序设计》第八周学习总结

    教材学习内容总结 第14章 NIO与NIO2 1.认识NIO NIO使用频道(Channel)来衔接数据节点,在处理数据时,NIO可以让你设定缓冲区(Buffer)容量,在缓冲区中对感兴趣的数据区块进 ...

  9. hadoop之 安全模式及SafeModeException

    问题: hadoop启动的时候报错 HTTP ERROR 500 Problem accessing /nn_browsedfscontent.jsp. Reason: Cannot issue de ...

  10. windows 如何查看端口占用进程ID 进程名称 强制结束进程

    1.查看指定端口的占用情况C:\>netstat -aon|findstr "9050" 协议    本地地址                     外部地址        ...