Windows Desktop Sharing API

Windows Desktop Sharing API

  • Comments 37

Windows Desktop Sharing API Basics

Microsoft Terminal Services provides a public "Windows Desktop Sharing API" based on RDP to enable customers to write custom collaboration solutions in Windows Vista. These API's are available on all the SKU's starting with Windows Vista Home Basics. You can write a customized collaboration application that can do either or all kinds of sharing including desktop, application and region.  Useful MSDN documentation of these API's is available at:

http://msdn2.microsoft.com/en-us/library/aa373852.aspx

Highlights:

Windows desktop sharing is a multi-party screen sharing technology in Windows Vista, wherein a local desktop can be transmitted over an RDP connection without creating an additional session.

  • a) Connectivity: Windows Desktop Sharing does support connectivity to intelligent appliances, wireless devices and PC's in uPnP framework and also teredo tunneling to provide connectivity to IPV6 machines behind IPV4 NAT's.
  • b) Reverse Connect: It is an interesting feature, where sharer can connect to the viewer if viewer cannot reach the sharer via direct connect. For example, the viewer may not be able to connect to the sharer because of network address translation (NAT).
  • c) Authentication: API supports creating tickets/ invitations on the sharer side that can be routed by the API consumer application or IM's to the viewers.
  • d) Sharing Modes: API supports sharing desktop, application or a region.
  • e) Control Modes: Sharer always has full control of his desktop/ application/region. Each viewer can be tuned to no-view/view or interactive control. Sharer controls the control level for each viewer and viewers can request promotion in control level to sharer.
  • f) Smart sizing: Smart sizing is well-supported and is a client/ viewer option that can be turned on and off.
  • g) Virtual channels: Virtual channels can be used to exchange other data like documents, application data, chat messages etc.

Microsoft Collaboration Solutions:

"Windows Meeting Space" and "Remote Assistance" in Windows Vista are based on these public API's -

  • a) Remote Assistance: Remote assistance is 1:1 sharing mechanism wherein the helper (expert) can get to see and control novice's desktop. Application and region sharing is not exposed via RA in Windows Vista.
  • b) Windows Meeting Space: Windows Meeting Space is a peer-to-peer application that enables multiple users to conduct virtual meeting. Participants can share their desktop, documents and applications, exchange notes, give presentations by connecting to a network projector. Network projector in this scenario is a intelligent device in uPnP framework that plays a role of viewer.

API support versus perceived limitations in Windows Meeting Space:

  • a) Multi-monitor remoting - In Windows Meeting Space the sharer does not allow sharing of both or the secondary monitor in multi-monitor arrangement. However, the API allows you to attach the appropriate region of the composite monitor and hence it can be flexible enough to share any particular monitor, if needed. It could get very interesting with more than 2 monitors.
  • b) Easy Switching among desktop/ application sharing - "Windows Meeting Space" doesn't allow flexible switching between desktop and application sharing. You need to select either one of them. To switch you need to restart the session (Meeting Space session). The API allows you to switch between various sharing methods without closing the session.
  • c) Application Sharing (minimize->on-screen) - In "Windows Meeting Space" when the viewer has the control of the sharer's application and viewer minimizes the application then he/she doesn't have a way to work on that application further (until sharer clicks on the taskbar on the minimized application). The API does provide a way for the viewer to bring back the minimized application on desktop. Hence a better user experience can be provided on the viewer side.

Frequently Asked Questions:

  1. What is the behavior with DWM?
    Windows desktop sharing API turns off "Desktop Windows Manager/ DWM" on the sharer's machine when the desktop/ application sharing is active.  
  2. What is the behavior when "Secure Desktop" pops up while sharing?
    "Pause screen- Black screen with two bars(indicating pause) at lower right" is remoted when secure desktop (UAC prompts) is up on sharer's machine, when sharing process is run as a non-system process. Also, the pause screen is shown if sharer opts to suspend graphics encoding for some reason via IRDPSRAPISharingSession::Pause.
  3. Why does the remoted screen refresh for all connected clients whenever a new viewer joins the session?
    The protocol tries to make sure that the graphics updates sent to all the connected viewers are synchronized. To do so, it needs to refresh the graphics stream for each previously connected client.
  4. Why does sharer's monitor flash while sharing? Is there anything that I can do to avoid multiple set of DWM on/off flashes, typically in 1:M scenarios?
    Currently, the protocol does not support remoting glass so it turns DWM off while sharing. Turning DWM off/ on causes a flash on the sharer's monitor [only in case if DWM was on]. You cannot entirely avoid on/off flash but you can avoid multiple on/off flashes.  Depending on your preference you can select dynamic/ static loading of mirror driver. In static mode, sharer will load mirror driver [& turn DWM off if it is on] only once when it puts a session in active state and unload mirror driver [& turns DWM on if it was on earlier] only once when it puts session in inactive state. So, in static mirror driver load mode you won't see multiple set of DWM on/off flashes. However, note that in static mirror driver load DWM/ glass will be turned off even if there are no clients connected. In dynamic mirror driver load mode DWM/ glass is turned off only when there is at least one connected client and is turned on whenever there are no connected clients. There is a property DrvConAttach that you can set via IRDPSRAPISessionProperties to control this behavior.
  5. Can multiple viewers have simultaneous control of sharer's desktop/ application?
    Yes. Sharer can permit each viewer a none, view only OR interactive control. Of course, viewers input (mouse movements/ keyboard input) will only be directed to sharer's machine when viewer has interactive control and the active X control has focus.
  6. Can you force sharer or viewer[in reverse connect scenario] to use particular port/ protocol for listening for connection and communication?
    Yes. You can use IRDPSRAPISessionProperties property - PortId and PortProtocol to use specific port and protocol.
  7. Why does requesting color depth change from the viewer via IRDPSRAPIViewer::RequestColorDepthChange fail?
    Currently, protocol does not allow viewer to request/ control the color depth change. Only the sharer can control the color depth via put property IRDPSRAPISharingSession::put_ColorDepth. IRDPSRAPIViewer::RequestColorDepthChange returns E_NOTIMPL in the current release.
  8. Does the API support clipboard?
    No. Windows Desktop Sharing API doesn't provide automatic text/ file clipboard solution yet. This might be a good proposal for new feature in future versions.
  9. Does the API support Audio/ Multi-media?
    No audio can be redirected to and fro from viewers/ sharer via "Windows Desktop Sharing API". This might be a good proposal for new feature in future versions.
Leave a Comment
  • Please add 5 and 1 and type the answer here:
  • Post
  • Have you look at the SmartSizing API. Link to the API - http://msdn.microsoft.com/en-us/library/aa373358(VS.85).aspx. It is part of IRDPSRAPIViewer interface,

  • I'm working on a custom remote access application for Windows XP Embedded. Any plans to support Windows Desktop Sharing API on XPe? If not, can you recommend another solution?

  • Same question here: I need to support anything from Windows XP SP2 and up. If RTC is gimped on Vista, and the Vista APIs are not available on XP SP2, then how can I cross-communicate?

    I could use RealVNC, or Citrix, or something like that, but it seems Microsoft has enough technologies floating around that this ought to be possible without resorting to that...

  • Are Desktop Sharing working on Windows 7?

  • Many people have asked: Yes, remote desktop sharing works on Win7. I have a 64-bit desktop and a 32-bit netbook, both running 7, and using the ActiveX controls for hosting and viewing.

    However, when I click the "control desktop" button in the sample application, and then click in the viewing control, it just beeps at me; it doesn't actually let me share control. The hosting application does receive the request, and does assign "Control" level access in the event handler.

    Why does this not work as advertised?

    Also, why can't I get access to the RDP stream at a lower level? I'd really like to be able to get the bitmap data directly (because I'm rendering to something that's not the screen), and I'd really like to be able to inject mouse and keyboard events directly (because I'm using input devices that are not the physical devices).

    As it is, I'm trying to host the ActiveX control and use IViewObject to Draw() into an offscreen bitmap, and it's not working out very well so far...

  • I have the same problem as Jon has:

    I'm unable to draw the contents of the RDP ActiveX control using IViewObject.

    Is it possible at all to somehow render the contents of the RDP session managed by RDP ActiveX into the virtual device context (straight into memory)?

    If it is not, it there any workarounds?

  • I believe Microsoft has not implemented IViewObject for RDP Active X because they did not want people to write RDP plugins for FireFox. God damn Microsoft!

  • I am trying to use this API in an MDI application.  Whenever I create the child form I get a "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." error.  

    Does anyone know why?

  • Are there any samples available for creating a screen sharing application using this API?

  • How can i access

    IRDPSRAPITcpConnectionInfo::LocalPort

    Property for RDPViewer object?

    Can we set the 'local' port to use for RDPViewer?

  • While the desktop sharing session is running, if the local user locks the screen, the remote user unable to unlock it. Is it a limitation of this control?

    more ever, If there is no user logged in, and desktop sharing server is running as a service, then will it be possible for remote user to unlock the desktop and log in?

    I mean, can this control also be used for un-attendant remote desktop control, just like Windows remote desktop?

    Secondly, I am not able to send Alt+Ctrl+Del (or Alt+Ctrl+END) keys from remote session. I want to see CPU usage etc, while sharing the remote desktop.

    Can anyone please guide me to find out how to achive this?

    Thanks in advance.

  • I am trying to enhance this Desktop Sharing application available at the link below, and facing a problem:

    blogs.msdn.com/.../...top-sharing-application.aspx

    (I think) The Limitation of this control is:

    Consider two types of users: Physical user who actually sits in front of the machine and uses its actual keyboard, mouse and monitor. And Remote User: Who remotely shares the desktop.

    Limitation:

    While the desktop is being shared, if physical user press Ctrl+Alt+Del to open the Windows Security Dialog, then the sharer stop sharing the desktop until the user is back to normal screen by choosing any of the option like task manager, or by pressing 'Esc key'.

    This is because the sharer is running in user context.

    But when I tried to run the sharer application as a system process or as a service, then the sharer does not share the session (session-0) at all.

    My Aim: You probably have guessed it by now…

    Yes. I want the sharer to share the desktop, no matter whether the use has locked the desktop, or even if there is no user logged in.

    NOTE: To make it simple, I am trying this only on client OS - Windows 7. So no question of multiple sessions as in Windows 2008. in that case, I would like to share Session 0 always.

    I tried to look more into it, but couldn't find anything other than working of Terminal Services on Server OS:

    technet.microsoft.com/en-us/library/cc755399(WS.10).aspx

    Can you please guide me on how and where to start with, or where I can find more details about working of rdpencom.dll?

  • I am trying to enhance this Desktop Sharing application available at the link below, and facing a problem:

    blogs.msdn.com/.../...top-sharing-application.aspx

    (I think) The Limitation of this control is:

    Consider two types of users: Physical user who actually sits in front of the machine and uses its actual keyboard, mouse and monitor. And Remote User: Who remotely shares the desktop.

    Limitation:

    While the desktop is being shared, if physical user press Ctrl+Alt+Del to open the Windows Security Dialog, then the sharer stop sharing the desktop until the user is back to normal screen by choosing any of the option like task manager, or by pressing 'Esc key'.

    This is because the sharer is running in user context.

    But when I tried to run the sharer application as a system process or as a service, then the sharer does not share the session (session-0) at all.

    My Aim: You probably have guessed it by now…

    Yes. I want the sharer to share the desktop, no matter whether the use has locked the desktop, or even if there is no user logged in.

    Any kind of help, suggestions are really apreaciated.

    Thanks in advance.

  • How many viewers can simultaneously connect to a sharer?

    In my test, I can only have 3 viewer to connect to a sharer simultaneously.

    Is this correct? or

    Is there any way to allow more viewers?

    Thanks in advance.

  • Hi, is there any way to connect pc/machine remotly using above API with Static IP Address via internet?

    Please let me know if you have any solutions.

    Thank you!

    Rasik Godhani

Page 2 of 3 (37 items) 123