0

私のプロジェクトの 1 つに役立つコードを見つけました。ただし、64 ビット MS Access では使用できません。

これは元の投稿でしたプロセス名からアプリケーション名を取得する方法?

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
    ApplicationName = .MainModule.FileVersionInfo.FileDescription
    ProcessName = .ProcessName
    WindowTitle = .MainWindowTitle
End With
End Sub
4

0 に答える 0