I am using AxMSTSCLib to develop a Windows application for establishing RDP connections. But I don't know how to redirect a physical camera from client to remote RDP session.
I tried to add camerastoredirect:s:* and devicestoredirect:s:* in .rdp file to redirect camera, it worked, I can use the camera in remote desktop via RDP.
But I can't find the correct property in AxMSTSCLib library to enable this feature.
I've tried to redirect all possible/dynamic devices, but it didn't work at all. Here is the code:
public AxMSTSCLib.AxMsRdpClient7NotSafeForScripting oRemote;
oRemote = new AxMSTSCLib.AxMsRdpClient7NotSafeForScripting();
oRemote.AdvancedSettings7.RedirectDevices = true;
oRemote.AdvancedSettings7.RedirectPorts = true;
oRemote.AdvancedSettings7.RedirectPOSDevices = true;
MSTSCLib.IMsRdpClientNonScriptable5 ocx = (MSTSCLib.IMsRdpClientNonScriptable5)oRemote.GetOcx();
ocx.RedirectDynamicDevices = true;
for (int i = 0; i < ocx.DeviceCollection.DeviceCount; i++)
{
MSTSCLib.IMsRdpDevice device = ocx.DeviceCollection.get_DeviceByIndex((uint)i);
device.RedirectionState = true;
}
I found IMsRdpCameraRedirConfigCollection in newer API documents, need to upgrade IMsRdpClientNonScriptable from 5 to 7.
I tried to print its count before setting Redirected as true, like this:
MSTSCLib.IMsRdpClientNonScriptable7 ocx = (MSTSCLib.IMsRdpClientNonScriptable7)oRemote.GetOcx();
Logger.Log("[ocx.CameraRedirConfigCollection.Count]:" + (ocx.CameraRedirConfigCollection.Count).ToString());
for (int i = 0; i < ocx.CameraRedirConfigCollection.Count; i++)
{
MSTSCLib.IMsRdpCameraRedirConfig camera = ocx.CameraRedirConfigCollection.get_ByIndex((uint)i);
Logger.Log("[camera.FriendlyName]:" + camera.FriendlyName);
camera.Redirected = true;
}
Unfortunately, I got zero.
According to the Docs, it looks like I have to add the camera symbolic link to the collection using AddConfig method. I stuck at this point, how do I add a camera symbolic link to the IMsRdpCameraRedirConfigCollection? How to get camera symbolic link?
Why
IMsRdpCameraRedirConfigCollectionis empty in the beginning? Since you didn't Rescan connected camera devices.That's it, all connected camera devices will be redirected to the remote desktop.