請問各路大神下面這段C#代碼可以轉換成VB6的代碼嗎?
Process proc = new Process();
try
{
proc.StartInfo.FileName = Pproc_name;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.Arguments = string.Concat(new string[] { "/F=", Pfile_Path, "\\", Prpt_file, " /p /x" });
proc.Start();
while (!proc.HasExited)
{
proc.WaitForExit(1000);
}
string errormsg = proc.StandardError.ReadToEnd();
proc.StandardError.Close();
if (String.IsNullOrEmpty(errormsg))
{
Flag = true;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
proc.Close();
proc.Dispose();
}
uj5u.com熱心網友回復:
僅供參考:Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Const SYNCHRONIZE = &H100000
Dim terminateFlag As Boolean
Private Sub Form_Load()
terminateFlag = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
terminateFlag = True
End Sub
Private Sub ShellWait(cmd As String)
Dim pId As Long, pHnd As Long, r As Long
pId = Shell(cmd, vbHide)
pHnd = OpenProcess(SYNCHRONIZE, 0, pId)
If pHnd <> 0 Then
Do
r = WaitForSingleObject(pHnd, 1000) '等1秒
DoEvents
Loop While r <> 0 And terminateFlag = False
Call CloseHandle(pHnd)
End If
End Sub
Private Sub Command1_Click()
Dim f As Integer
Dim ln As String
ShellWait "cmd /c “”“+Pproc_name+“”“ /F="+ Pfile_Path+ "\"+ Prpt_file+ " /p /x"
f=FreeFile()
Open "y:\info.ini" For Input As #f
Line Input #f, ln
Debug.Print ln
Close #f
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/81886.html
標籤:VB基礎類
上一篇:關于金蝶K3的二次開發
下一篇:求大神asp問題求求求
