1
如果使用RDP将应用程序作为远程应用程序启动,是否可以使用c#编写的应用程序进行检测?检测应用程序是否在远程应用程序中运行
如果使用RDP将应用程序作为远程应用程序启动,是否可以使用c#编写的应用程序进行检测?检测应用程序是否在远程应用程序中运行
获取应用程序进程的父级并检查它是否由rdpinit.exe引发。如果是这样,那是一个RemoteApp。用于获取父进程ID(抱歉,vb.net)
简单的例子:
<Extension()>
Public Function GetParentProcessId(process As Process) As Integer
If process Is Nothing Then Throw New NullReferenceException()
Dim parentProcessId As Integer
Dim snapShot As IntPtr = IntPtr.Zero
Try
snapShot = CreateToolhelp32Snapshot(SnapshotFlags.Process, 0)
If snapShot <> IntPtr.Zero Then
Dim procEntry As New PROCESSENTRY32
procEntry.dwSize = CUInt(Marshal.SizeOf(GetType(PROCESSENTRY32)))
If Process32First(snapShot, procEntry) Then
Do
If process.Id = procEntry.th32ProcessID Then
parentProcessId = CInt(procEntry.th32ParentProcessID)
Exit Do
End If
Loop While Process32Next(snapShot, procEntry)
End If
End If
Catch ex As Exception
Throw
Finally
If snapShot <> IntPtr.Zero Then
CloseHandle(snapShot)
End If
End Try
Return parentProcessId
End Function
现在你可以很容易地得到父进程。
Regards, Jan