本文介绍了如何启动进程然后再将其停止。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以告诉我这次尝试有什么问题吗?
进口系统
进口System.Diagnostics
进口System.ComponentModel
模块modProcess
类PolProcess
公共共享子StartProcess()
Dim PolProcess As New Process()
试试
PolProcess.StartInfo.UseShellExecute = False
'你可以启动任何进程,HelloWorld是一个无用的例子。
PolProcess.StartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)& " \BriefCase\Pol\Pol.exe"
PolProcess.Start()
'此代码假定您启动的进程将自行终止。
'或者您可以使用Kill方法从此应用程序以编程方式执行此操作。
Catch e As Exception
MsgBoxer(e.Message,MsgBoxStyle.OkOnly," Pol","Critical")
结束尝试
结束子'主
Public Shared Sub StopProcess()
Dim PolProcess As Process
Try
PolProcess.Kill()
Catch ex As Exception
MsgBoxer(ex.Message, MsgBoxStyle.OkOnly,"Pol","Critical")
结束尝试
结束子
结束类
结束模块
Robert Homes
解决方案
Can someone tell me what's wrong with this attempt?
Imports System Imports System.Diagnostics Imports System.ComponentModel Module modProcess Class PolProcess Public Shared Sub StartProcess() Dim PolProcess As New Process() Try PolProcess.StartInfo.UseShellExecute = False ' You can start any process, HelloWorld is a do-nothing example. PolProcess.StartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) & "\BriefCase\Pol\Pol.exe" PolProcess.Start() ' This code assumes the process you are starting will terminate itself. ' or you can do it programmatically from this application using the Kill method. Catch e As Exception MsgBoxer(e.Message, MsgBoxStyle.OkOnly, "Pol", "Critical") End Try End Sub 'Main Public Shared Sub StopProcess() Dim PolProcess As Process Try PolProcess.Kill() Catch ex As Exception MsgBoxer(ex.Message, MsgBoxStyle.OkOnly, "Pol", "Critical") End Try End Sub End Class End Module
Robert Homes
解决方案
这篇关于如何启动进程然后再将其停止。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!