Tag: process

如何在c#中停止ffmpegvideo录制?

我在应用程序中使用FFmpeg并且它完美地启动和录制video但是当我想要停止它请求按“q”时,我收到了System.EntryPointNotFoundException错误消息。 如何从应用程序向处于运行状态的进程发送消息“q” int key_q = 81; [DllImport(“user32.dll”, EntryPoint = “postmessage”)] private static extern bool postmessage(IntPtr hwnd, uint msg, int wparam, int lparam); private void button_stop_Click(object sender, EventArgs e) { string process = “ffmpeg”; Process[] pro = Process.GetProcessesByName(“ffmpeg”); pro[0].Refresh(); IntPtr h = pro[0].MainWindowHandle; postmessage(h, 0x100, key_q, 0); }

如何在进程操作期间逐行捕获进程STDOUT和STDERR。 (C#)

我将执行一个进程(lame.exe)将WAV文件编码为MP3。 我想处理进程的STDOUT和STDERR以显示进度信息。 我需要使用线程吗? 我无法理解它。 一些简单的示例代码将不胜感激。 谢谢

重定向进程输出C#

我想将Process的标准输出重定向到一个字符串,以便以后解析。 我还希望在进程运行时看到屏幕上的输出,而不仅仅是当它完成运行时。 这有可能吗?

C#Process.MainWindowHandle总是返回IntPtr Zero

这是我的代码: using (Process game = Process.Start(new ProcessStartInfo() { FileName=”DatabaseCheck.exe”, RedirectStandardOutput = true, CreateNoWindow = true, UseShellExecute = false })) { lblLoad.Text = “Loading”; int Switch = 0; while (game.MainWindowHandle == IntPtr.Zero) { Switch++; if (Switch % 1000 == 0) { lblLoad.Text += “.”; if (lblLoad.Text.Contains(“….”)) lblLoad.Text = “Loading.”; lblLoad.Update(); game.Refresh(); } } 问题是,那个游戏.MainWindowHandle总是IntPtr.Zero。 我需要找到运行过程的IntPtr以确认游戏是由启动器启动的,所以我让游戏发送它的IntPtr并让发射器响应它是否正常。 但为此,我必须具体了解运行过程的IntPtr。 […]

C#运行时获取进程输出

无论如何,重定向生成的进程的标准输出并将其捕获为它的发生。 我看到的所有内容在完成后都会执行ReadToEnd。 我希望能够在打印时获得输出。 编辑: private void ConvertToMPEG() { // Start the child process. Process p = new Process(); // Redirect the output stream of the child process. p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; //Setup filename and arguments p.StartInfo.Arguments = String.Format(“-y -i \”{0}\” -target ntsc-dvd -sameq -s 720×480 \”{1}\””, tempDir + “out.avi”, tempDir + “out.mpg”); p.StartInfo.FileName […]

如何在C#中使用?

我发现了很多关于它的问题,但没有人解释我如何使用它。 我有这个: using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Windows.Forms; using Microsoft.FSharp.Linq.RuntimeHelpers; using System.Diagnostics; using System.Runtime.InteropServices; using System.IO; public class WindowHandling { public void ActivateTargetApplication(string processName, List barcodesList) { [DllImport(“User32.dll”)] public static extern int SetForegroundWindow(IntPtr point); Process p = Process.Start(“notepad++.exe”); p.WaitForInputIdle(); IntPtr h = p.MainWindowHandle; SetForegroundWindow(h); SendKeys.SendWait(“k”); IntPtr processFoundWindow = p.MainWindowHandle; } } […]

为什么这个过程一启动就会崩溃?

我们有一个IIS WCF服务,它以另一个用户的身份启动另一个进程(app.exe)。 我完全控制了两个应用程序(现在这是一个开发环境)。 IIS应用程序池以我的身份运行,域用户(DOMAIN \ nirvin),也是该框的本地管理员。 第二个进程应该作为本地用户运行(svc-low)。 我正在使用System.Diagnostics.Process.Start(ProcessStartInfo)来启动该进程。 该过程成功启动 – 我知道因为没有抛出exception,我得到了一个进程ID。 但是进程立即死亡,我在事件日志中看到如下错误: 错误应用程序名称:app.exe,版本:1.0.3.0,时间戳:0x514cd763 错误模块名称:KERNELBASE.dll,版本:6.2.9200.16451,时间戳:0x50988aa6 exception代码:0xc06d007e 故障偏移:0x000000000003811c 错误进程id:0x10a4 错误应用程序启动时间:0x01ce274b3c83d62d 错误的应用程序路径:C:\ Program Files \ company \ app \ app.exe 错误模块路径:C:\ Windows \ system32 \ KERNELBASE.dll 报告ID:7a45cd1c-933e-11e2-93f8-005056b316dd 错误包全名: 错误包相关的应用程序ID: 我已经在app.exe(现在)中进行了非常彻底的日志记录,因此我认为它不会在.NET代码中引发错误(不再)。 这是真正令人讨厌的部分:我认为我只是启动了错误的进程,所以我在一个愚蠢的WinForms应用程序中复制了我的Process.Start()调用并在机器上像我一样运行它,希望能够修改,直到我得到正确的参数。 因此,当然这是第一次和每次都有效:我能够始终如一地启动第二个流程并使其按预期运行。 它只能从IIS启动,不起作用。 我试过给svc-low权限“以批处理作业登录”,并且我已尝试授予自己“替换进程级别令牌”(在本地安全策略中)的权限,但似乎都没有任何区别。 救命! 环境细节 Windows Server 2012 .NET 4.5(提到的所有应用程序) 额外细节 起初app.exe是一个控制台应用程序。 尝试启动是让conhost.exe在事件日志中生成错误,因此我将app.exe切换为Windows应用程序。 这让conhost脱离了这个等式,但让我了解了这里描述的情况。 (通过这个问题引导了这条道路。) 我使用的ProcessStartInfo对象如下所示: new […]