gpt4 book ai didi

vb.net - 如何在 vb.net 中获取 ffmpeg 进程的参数?

转载 作者:行者123 更新时间:2023-12-04 23:03:49 25 4
gpt4 key购买 nike

我正在编写一个简单的程序来获取像 ffmpeg 这样的进程的所有属性。我得到了预定义函数的大部分属性,但我想知道我在 vb.net 中给 ffmpeg 的参数?

  For Each prog As Process In Process.GetProcesses
If prog.ProcessName = "ffmpeg" Then
al.Add(prog.Id)
End If
Next

For Each id In al
Dim p As Process = Process.GetProcessById(id)
listBox3.Items.Add(Process.GetProcessById(id).ProcessName)
ListBox3.Items.Add(p.BasePriority)
ListBox3.Items.Add(p.HandleCount)
ListBox3.Items.Add(p.Id)
ListBox3.Items.Add(p.MainWindowTitle)
ListBox3.Items.Add(p.MaxWorkingSet)
ListBox3.Items.Add(p.MinWorkingSet)
ListBox3.Items.Add(p.PriorityBoostEnabled)
ListBox3.Items.Add(p.PriorityClass)
ListBox3.Items.Add(p.PrivilegedProcessorTime)
ListBox3.Items.Add(p.ProcessName)
ListBox3.Items.Add(p.ProcessorAffinity)
ListBox3.Items.Add(p.StartTime)
ListBox3.Items.Add(p.TotalProcessorTime)
ListBox3.Items.Add(p.UserProcessorTime)
lastBox3.Items.Add(p.WaitForInputIdle)
ListBox3.Items.Add("========================")
Next id

最佳答案

使用 Jesse Slicer 的代码作为 here 的基础:

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For Each proc As Process In Process.GetProcessesByName("ffmpeg")
Debug.Print("ID: " & proc.Id)
Debug.Print("Arguments: " & proc.GetCommandLine)
Debug.Print("------------------------------")
Next
End Sub

End Class

Public Module Extensions

<Runtime.CompilerServices.Extension()>
Public Function GetCommandLine(ByVal proc As Process) As String
' Project --> Add Reference --> System.Management
Dim arguments As New System.Text.StringBuilder
Using searcher As New Management.ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " & proc.Id)
For Each arg In searcher.Get
arguments.Append(arg("CommandLine") & " ")
Next
End Using
Return arguments.ToString.Trim
End Function

End Module

请注意,您需要添加 System.Management 引用,并且我将该函数作为 Process 类的扩展方法。

关于vb.net - 如何在 vb.net 中获取 ffmpeg 进程的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32972131/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com