读书人

如何用vb.net调java.exe 啊.高人.一点

发布时间: 2011-12-18 22:54:38 作者: rapoo

怎么用vb.net调java.exe 啊.高人..急!!!!!!!一点思路没有.
怎么用vb.net调java.exe 啊.高人..急!!!!!!!一点思路没有.

[解决办法]
'引用命名空间
Imports   System.Diagnostics  
'代码
FileName = "D:\Java.exe"  
Process.Start(FileName)  
exe文件这么调用是没什么问题的。楼主试试。
[解决办法]
Private Function ExcuteShellCommand(ByVal ExcuteFileName As String, ByVal ExcuteArguments As String) As String
Dim sReturn As String
Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process
Dim bOk As Boolean
myProcess.StartInfo.FileName = ExcuteFileName
myProcess.StartInfo.Arguments = ExcuteArguments
myProcess.StartInfo.UseShellExecute = False
'myProcess.StartInfo.RedirectStandardInput = True
'myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.RedirectStandardError = True
'myProcess.StartInfo.CreateNoWindow = True

bOk = myProcess.Start()
sReturn = ""
If bOk Then
sReturn = myProcess.StandardError.ReadToEnd()
sReturn = ""
Else
sReturn = "执行【 " & ExcuteFileName & ExcuteArguments & "】失败"
End If
myProcess.Dispose()
Return sReturn
End Function
[解决办法]

VB.NET code
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim procID As Integer        Dim newProc As Diagnostics.Process        newProc = Diagnostics.Process.Start("C:\WINDOWS\NOTEPAD.EXE", "g:\a.xml")        procID = newProc.Id        newProc.WaitForExit()        Dim procEC As Integer = -1        If newProc.HasExited Then            procEC = newProc.ExitCode        End If        MsgBox("Process with ID " & CStr(procID) & _            " terminated with exit code " & CStr(procEC))    End Sub 

读书人网 >VB Dotnet

热点推荐