通过使用VBNET程序调用外部.EXE子功能 [英] Call external .EXE subfunctions by using VBNET program

查看:691
本文介绍了通过使用VBNET程序调用外部.EXE子功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我正在设计用户界面,因此遇到了新问题.我需要打开特定的软件并强制其自动执行某些功能.

以下创建的代码仅创建该过程:

    Public Sub APT_upload(等待时间为整数)

       试试

           将APT_Process变暗为新的System.Diagnostics.Process
           使用APT_Process
                .EnableRaisingEvents = True
           结尾为

           将APT_ProcessInfo变暗为新的ProcessStartInfo
           使用APT_ProcessInfo
                .UseShellExecute = False
                .WindowStyle = ProcessWindowStyle.Normal
                .FileName =" C:\ xxx \ xxx.exe"  
           结尾为

            APT_Process = Process.Start(APT_ProcessInfo)

            ******在这里做些事情!

          ?????????

          ****************************************

           如果APT_Process.Id<> 0然后,过程存在"
           其他
                MsgBox(无法从以下位置打开APT:& APT_ProcessInfo.FileName)
           如果结束

            WaitDelay(WaitTime)

            Dim procesos As Process()
           过程=任务管理器中的Process.GetProcessesByName("xxx")'
           如果procesos.Length> 0然后
               对于i = procesos.Length-1至0步骤-1
                    procesos(i).Kill()
               下一个
           如果结束
            procesos =没事

           退出子

       异常捕获
            MessageBox.Show(ex.Message)
       结束尝试

   结束


但是我如何在该exe文件中自动调用子功能?我需要知道方法名称还是只使用引用的dll:s?

最好的问候.

Vesa

解决方案

目标独立应用程序必须通过COM公开其功能,以便直接从您的应用程序中调用.你知道是不是这种情况?支持此技术的应用程序示例包括Microsoft Word,Excel和其他MS Office 应用.

VB 6.0(ActiveX EXE)本身支持此技术,但.NET不支持此技术,因此如果不使用COM,就无法在.NET中为此目的真正构建独立的应用程序.

实现这种类型的机制的另一种方法是使用进程间通信,例如 匿名管道,以便按顺序向其他应用发送消息调用功能.再一次,必须开发目标应用程序以支持该技术.


Hi!

Im designing user-interface and I faced new problem. I need to open specific software and force it to make some functions automatically.

Following code I have created just creates the process:

    Public Sub APT_upload(WaitTime As Integer)

        Try

            Dim APT_Process As New System.Diagnostics.Process
            With APT_Process
                .EnableRaisingEvents = True
            End With

            Dim APT_ProcessInfo As New ProcessStartInfo
            With APT_ProcessInfo
                .UseShellExecute = False
                .WindowStyle = ProcessWindowStyle.Normal
                .FileName = "C:\xxx\xxx.exe"  
            End With

            APT_Process = Process.Start(APT_ProcessInfo)

           ******DO SOMETHING HERE!!!***********

          ????????

          ************************************

            If APT_Process.Id <> 0 Then 'process exist
            Else
                MsgBox("Cannot open APT from: " & APT_ProcessInfo.FileName)
            End If

            WaitDelay(WaitTime)

            Dim procesos As Process()
            procesos = Process.GetProcessesByName("xxx") 'from task manager
            If procesos.Length > 0 Then
                For i = procesos.Length - 1 To 0 Step -1
                    procesos(i).Kill()
                Next
            End If
            procesos = Nothing

            Exit Sub

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub


But how I can call subfunction/functionality inside that exe automatically? I Need to know method names or just using referenced dll:s?

Best Regards.

Vesa

解决方案

The target standalone application must expose its functions through COM in order to be called from your application directly. Do you know if this is the case? Examples of applications which support this technology are Microsoft Word, Excel and other MS Office apps.

This technology was natively supported in VB 6.0 (ActiveX EXE), but not in .NET so you can't really build a standalone app for this purpose in .NET without using COM.

Another way to implement this type of mechanism would be to use inter-process communication, such as anonymous pipes, to send messages to the other app in order to invoke functions. One again, the target application must be developed to support this technology.


这篇关于通过使用VBNET程序调用外部.EXE子功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆