gpt4 book ai didi

.net - 如何从进程名称中获取应用程序名称?

转载 作者:行者123 更新时间:2023-12-01 15:02:54 32 4
gpt4 key购买 nike

当我有进程名称时,我需要知道如何获取这样的应用程序名称:

enter image description here

我到目前为止的进展:

Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As Int32, ByRef lpdwProcessId As Int32) As Int32
Private Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As IntPtr
'Private Declare Auto Function GetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpString As System.Text.StringBuilder, ByVal cch As Integer) As Integer
Private makel As String
Private Function GetActiveAppProcess() As Process
Dim activeProcessID As IntPtr
GetWindowThreadProcessId(GetForegroundWindow(), activeProcessID)
Return Process.GetProcessById(activeProcessID)
End Function
Sub GetProcInfo()
Dim activeProcess As Process = GetActiveAppProcess()
With activeProcess
ProcessName = .ProcessName
Windowtitle = .MainWindowTitle
'Application name = ?
End With
End Sub

除了 Process.ProcessName 返回“资源管理器”之外,我几乎就在那里。如何获得“Windows 资源管理器”的值?
任何帮助表示赞赏。

最佳答案

由于汉斯尚未发布答案,以下是他在该问题的评论中建议的答案。我希望大家不要介意我冒昧地继续写一个答案。

Sub GetProcInfo()
Dim activeProcess As Process = GetActiveAppProcess()
With activeProcess
ApplicationName = .MainModule.FileVersionInfo.FileDescription
ProcessName = .ProcessName
WindowTitle = .MainWindowTitle
End With
End Sub

关于.net - 如何从进程名称中获取应用程序名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33564688/

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