请问各路大神下面这段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();
            }

解决方案 »

  1.   

    仅供参考: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