是否有办法从使用CDP编写的应用程序中检测是否使用RDP作为远程应用程序启动?
答案 0 :(得分:1)
获取应用程序进程的父进程,并检查它是否由rdpinit.exe引发。如果是这样,那就是RemoteApp。
获取parent-process-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
现在您可以轻松获得父进程。
此致 扬