Welcome to MSDN Blogs Sign in | Join | Help

TS-Teleport: Sample Instructions

Installation

To install the sample the user needs to register both client plug-in and shell extension on the TS client and server machines respectively.

NOTE: The VS support DLLs need to be copied to the same path as the sample DLLs.  Please choose the right VS support DLLS for the architecture (x86/x64) and binary type (debug/release); e.g.:

"%programfiles(x86)%\Microsoft Visual Studio 9.0\vc\redist\Debug_NonRedist\x86\Microsoft.VC90.DebugCRT\*"

Client Installation (on the TS client machine)

1.       Copy the right VS support DLL files to the same directory as TsTelePlgn.dll

2.       Register the Plug-in COM object: “RegSvr32 TsTelePlgn.dll”, this will:

a.       Register the COM object

b.      Add the following TS specific key/value to load the plug-in

HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default\AddIns\TsTelePlgn

Name    REG_SZ    {0350DF61-30CF-451B-B292-3CE3A330F958}

Server Installation (on the TS server machine)

3.       Copy the right VS support DLL files to the same directory as TsTeleport.dll

4.       Register the shell extension COM object: “RegSvr32 TsTeleport.dll”, this will

a.       Register the COM object

b.      Add the shell extension keys/values

5.       Manually create the following empty file to trigger loading the COM object by Shell

a.       Locate the SendTo folder (for the current user or all users); e.g.:

C:\Users\<User>\AppData\Roaming\Microsoft\Windows\SendTo

b.      Create an empty file with the following name: “RDP Client Desktop.tsteleport

Usage

1.       Use the machine with the client plug-in to establish a TS connection

2.       TS to the server with the shell extension

3.       Highlight a group of files and/or directories and right-click

4.       Select the send-to menu and then “RDP Client Desktop”

Debugging and Troubleshooting

Attach a debugger to the running instance of mstsc.exe hosting the client side plug-in, or explorer.exe hosting the shell extension and watch messages in the debugger output area in case of errors.

Sample Assumptions

This section outlines assumptions made to simplify the sample and focus on demonstrating the DVC API usage.  The reader is advised to go through it if basing an application on the provided sample.  If the intent is just familiarity with DVCs, this section can be skipped.

Protecting State and State Sensitive Protocol

The TS client serializes calls to the plug-in so we don’t use a lock to protect state changes.  Moreover, we are guaranteed to have only a single DVC connection from our server which allows for a state-ful protocol.  On the server side explorer calls our methods synchronously and doesn’t allow a new “Send to RDP Client Desktop” invocation while one is in progress.  The whole scheme does not require the use of any locks on the client or the server.  In real-life applications most of these assumptions are invalidated, which requires caution when using this code as core for other implementations.

One COM Object

Another simplification is the use of the same COM object as the client plug-in, listener and channel callbacks.  This might or might not be the case in more complex protocols depending on the problem addressed and the assumptions.

Error Reporting and Verbosity

Again TS-Teleport is far from an application with a fully furnished UI.  The UI consists of a single dialog box that echoes the success or failure of transporting the requested set of files.  More verbose output for debugging and understanding is provided through the debugger spew.

Shell Blocking

Again this is another limitation since we do all the teleportation on a synchronous shell call, certain shell features are blocked during the whole operation which can take a significant time depending on the cumulative size of the transported files.

Sample Code

The sample code is attached to this article.  Windows Server 2008 SDK is needed to get the DVC definitions.  Also attached is the VS2008 Beta-2 solution file for the sample (Visual Studio 2008 Beta2 is needed from the microsoft.com website to compile the sample).

Build FAQ:

Why can’t I open the .sln or .vcproj files with Visual Studio 2005?

Because you need Visual Studio 2008 (or VS 2008 Beta 2) as previously stated (link below).

Why am I getting one or more of the following erros?

fatal error C1083: Cannot open include file: 'TsVirtualChannels.h': No such file or directory

error C2065: 'WTS_CHANNEL_OPTION_DYNAMIC' : undeclared identifier

error C3861: 'WTSVirtualChannelOpenEx': identifier not found

 

Since Windows Server 2008 SDK in the link below needs to be installed and configured with Visual Studio (i.e. add the new SDK include and lib directories to VS – Tools->Options->Projects and Solutions->VC++ directories).

Links:

Windows Server 2008 SDK:

http://www.microsoft.com/downloads/details.aspx?FamilyId=58726ACA-8D84-4683-8959-BE0038DA7084&displaylang=en

VS2008 Beta2:

http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx

TS-Teleport sample:

TS Dynamic Virtual Channel Sample

Published Wednesday, September 19, 2007 10:35 PM by termserv

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Dynamic Virtual Channels

An important goal of the Terminal Services (TS) team is to provide a product that can easily be extended

Thursday, September 20, 2007 1:02 PM by Terminal Services Team Blog

# re: TS-Teleport: Sample Instructions

thanks for this excellent article.

Monday, September 24, 2007 5:19 AM by anita

# re: TS-Teleport: Sample Instructions

can u give some explanation on TS DVC example.

Tuesday, September 25, 2007 5:47 AM by amit

# re: TS-Teleport: Sample Instructions

how do we add shellextn key values. We are getting WTSVirtualChannelOpenex() failed  error NO. 80070002. Are there any security settings to be done. Please reply ASAP.

Thanks

Ravi

Tuesday, September 25, 2007 6:08 AM by Ravi

# re: TS-Teleport: Sample Instructions

Ravi,

Please follow the instructions in the main post to register the DVC plugin with the client.  0x80070002 is 'file not found' so I'm pretty sure the DVC client plugin is not loaded properly or doesn't create the right listener.

Tuesday, September 25, 2007 3:53 PM by Ahmed

# re: TS-Teleport: Sample Instructions

TsTelePlugin.dll is correctly registered on the client

Below are the trace staments in the debugger

[hr=0x80070057]WTSVirtualChannelOpenEx failed

[hr=0x80070057]GetVirtualChannelHandle failed

[hr=0x80070057]TeleportFiles failed

CallStack which is failing

02b8eeb0 759a38dc 00000008 759a394c 02b8f040 WINSTA+0x1556

02b8eed0 74d63b94 00000000 ffffffff 6e61ede8 WINSTA!WinStationVirtualOpenEx+0x1b

02b8eef4 74d63f67 00000000 ffffffff 6e61ede8 WTSAPI32!WTSEnumerateProcessesA+0x1ec

02b8ef0c 6e602dc6 ffffffff 6e61ede8 00000000 WTSAPI32!WTSVirtualChannelOpenEx+0x15

02b8f040 6e601d14 02c83328 8cefc753 02b8f2b0 TsTeleport!DllGetClassObject+0xec28

02b8f19c 6e601584 02b8f28c 02b8f2b4 02b8f4e4 TsTeleport!DllGetClassObject+0xdb76

02b8f2b0 75b65bbf 02c83320 0294bbdc 00000009 TsTeleport!DllGetClassObject+0xd3e6

Above mentioned is the stack trace. Any clue are we missing any security settings on server side.

File version of wtsapi32.dll is

6.0.6001.16526. I suppose this is the correct RDP we are using

Wednesday, September 26, 2007 6:18 AM by Ravi

# re: TS-Teleport: Sample Instructions

For Ts-teleport to work fine, do we need to have Remote Desktop Connection 6.1 or using Remote Desktop Connection 6.0 will be sufficient? Please reply.

I am unable to find Remote Desktop Connection 6.1 download site,please help me in this regard also.

Thanks,

Sabry

Wednesday, September 26, 2007 8:19 AM by Sabry

# re: TS-Teleport: Sample Instructions

The error 0x80070057 indicates an incorrect parameter.  Most probably you are not running this on Vista SP1 or a Windows Server 2008.  If you are then maybe not on a recent enough build although I doubt it.

- Ahmed [MS]

Wednesday, September 26, 2007 2:47 PM by ahmedt

# re: TS-Teleport: Sample Instructions

It appears that my post from the morning didn't go through; so sorry Sabry.

YES, you need the 6.1 client, which I believe isn't available as a stand-alone from MS.  It's the client that ships with Vista SP1 and Windows Server 2008.  You can download pre-release versions of those OS'es from the MS website.

- Ahmed [MS]

Wednesday, September 26, 2007 9:56 PM by ahmedt

# re: TS-Teleport: Sample Instructions

The application is working fine on using Remote Desktop Connection 6.1,thanks for the guidance.

Regards,

Sabry

Friday, September 28, 2007 8:00 AM by Sabry

# re: TS-Teleport: Sample Instructions

I'm really interested in this mechanism and I've tried to compile it up.

I am using Visual Studio 2008 on top of Vista and I get the errors below. I've added in the 2008 SDK (on top of VS2008) and added in the paths as detailed above, but still no differrence.

tsclientplgn.h(127) : error C2065: 'IWTSListener' : undeclared identifier

tsclientplgn.h(27) : error C2512: 'ATL::CComPtr' : no appropriate default constructor available

tsclientplgn.cpp(50) : error C2664: 'IWTSVirtualChannelManager::CreateListener' : cannot convert parameter 4 from 'T **' to 'IUnknown **'

Any pointers would be welcome.

Friday, December 14, 2007 11:40 AM by Tim

# re: TS-Teleport: Sample Instructions

Can this be done with VS2005 between Windows XP Client and Windows Server 2003 Terminal Server?

Friday, December 14, 2007 5:25 PM by Ryan Hilliker

# re: TS-Teleport: Sample Instructions

As described in the requirements above the client has to be 6.1 which *can run* on XP but the server has to be WS08.

- Ahmed.

Tuesday, January 08, 2008 8:39 PM by ahmedt

# re: TS-Teleport: Sample Instructions

The link of the Sample code is not working, Can any body reactivate it, or send it on

mohd1024@yahoo.com

I need it badly and would be very gratefull

Monday, February 25, 2008 7:59 AM by Mohammed

# Unable to register the COM object

When I tried to register the COM Object, I get the following error :

//////////////////////////////////////////

Debug Error!

Program: c:\WINDEOS\system32\regsvr32.exe

R6034

An application has made an attempt to load the C runtime library without using a manifest.

This is an unsupported way to load Visual C++ DLLs. You need to modify your application to build with a manifest.

For more information, see the "Visual C++ Libraries as Shared Side-by-Side Assemblies" topic in the product decumentation.

//////////////////////////////////////////

Wednesday, May 14, 2008 8:06 AM by Mohammed

# Unable to register the COM object

When I tried to register the COM Object, I get the following error :

//////////////////////////////////////////

Debug Error!

Program: c:\WINDEOS\system32\regsvr32.exe

R6034

An application has made an attempt to load the C runtime library without using a manifest.

This is an unsupported way to load Visual C++ DLLs. You need to modify your application to build with a manifest.

For more information, see the "Visual C++ Libraries as Shared Side-by-Side Assemblies" topic in the product decumentation.

//////////////////////////////////////////

Given that I put the following files with the output dll file :

Microsoft.VC90.DebugCRT.manifest

msvcm90d.dll

msvcp90d.dll

msvcr90d.dll

Wednesday, May 14, 2008 8:07 AM by Mohammed

# Static Virtual Channel on RDP 6.1

Is there a way to load the Static Virtual Channels by RDP 6.1 I mean on windows Vista or Server 2008.

Since the "WTSVirtualChannelOpenEx" can be used only on Windows 2008 then we have to develop two versions of the server side, one for Win 2008 that accepts both the dynamic and static channels and the other version for windows 2003 that accepts only the static channels.

I'd like to find a way to develop a server application that can work on both 2008 and 2003 and accept sessions from any windows version (vista, XP, ...).

Regards

Wednesday, July 09, 2008 6:25 AM by Mohammed N.

# re: TS-Teleport: Sample Instructions

Mohammed N,

Assuming you are only using static channels, WTSVirtualChannelOpen still works on Windows Server 2008 the same as it did in previous versions. You don't have to use WTSVirtualChannelOpenEx unless you need dynamic channels.

If you want to you WTSVirtualChannelOpenEx, you can use GetProcAddress to see if the function exists. If it does, you can use it, otherwise you can fall back on WTSVirtualChannelOpen. This will let you keep one version of your server code, which uses the newer APIs if they are present.

-Eric

Wednesday, July 09, 2008 1:37 PM by Eric Holk [MSFT]

# re: TS-Teleport: Sample Instructions

Thanks Eric for replying.

In fact I'd like to continue using only static channels, but the problem I faced that Static Virtual Channels can't be integrated with RDP 6.1 running on Windows Vista or 2008. Am I right?

As you may know, the Static Virtual Channels were registered to the RDC by adding a registry key in

HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default\AddIns

This is working fine on Windows XP, 2003. But when I try to do this for Windows Vista or 2008 to load the same SVC, the RDC will not connect to the server! is there another way to register the SVC?

If I find a way to do that I will continue to use the same SVC and "WTSVirtualChannelOpen", which is better for me.

Please, I am waiting your reply

Thursday, July 10, 2008 3:41 AM by mohd1024

# re: TS-Teleport: Sample Instructions

Hi again, Mohammed. We have not changed the way static virtual channel plugins are registered in Windows Vista or Windows Server 2008. The way you are describing should work. Is it possible that your plugin is returning some error that it doesn't return on earlier versions of Windows?

I'd suggest trying to run RDC under a debugger, and see if you can find anything interesting in your code that way.

-Eric

Thursday, July 10, 2008 4:46 PM by Eric Holk [MSFT]

# re: TS-Teleport: Sample Instructions

Hi again, Mohammed. We have not changed the way static virtual channel plugins are registered in Windows Vista or Windows Server 2008. The way you are describing should work. Is it possible that your plugin is returning some error that it doesn't return on earlier versions of Windows?

I'd suggest trying to run RDC under a debugger, and see if you can find anything interesting in your code that way.

-Eric

Thursday, July 10, 2008 4:46 PM by Eric Holk [MSFT]

# re: TS-Teleport: Sample Instructions

Thanks agian Eric for replying and for this information.

I added a key into the key "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default\AddIns" for my virtual channel and added the value:

Name REG_SZ [Virtual Channel DLL path]

in you sample code, you are registering the COM object first by regsvr32 and then adding the class ID in the "Name" value, while I am adding the dll file path directly, Is that make any difference?

I tried to debug the RDC, and yes it entered the dll entry point which is:

extern _declspec(dllexport) BOOL _cdecl VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)

and it executes all this function correctly, the API "VirtualChannelInit" was also executed successfully and returned "CHANNEL_RC_OK", and the entry point returned TRUE as expected, now it should go to the "VirtualChannelInitEventProc" callback function to handl the Initialization Event, but instead it breaks giving me the following error:

"Unhandled exception at 0x6c51584d in mstsc.exe: 0xC0000005: Access violation writing location 0x5ed88c89"

Iam trying to get extra info about this error cause.

Can you redirect me to a code that is definitly working on Win Server 2008 to compare with? or can I send you my code?

Thank you very much

Sunday, July 13, 2008 7:47 AM by Mohammed N.

# re: TS-Teleport: Sample Instructions

Thanks Eric Very Much, The Problem has been Solved. I really appreciate your help. It is now working on Win Vista and 2008.

As you may have figured out from my previous post, the problem was in the Virtual Channel Entry Point definition:

extern _declspec(dllexport) BOOL _cdecl VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)

I was using _cdecl where it should be _stdcall I am now using:

BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)

Which is working fine, it was working on Win2003 and XP even that it is _cdecl, but in 2008 and Vista it should be _stdcall

Thank you Eric again

Sunday, July 13, 2008 10:14 AM by mohd1024

# re: TS-Teleport: Sample Instructions

Mohammed, I'm glad to hear everything is working well for you now.

Good luck,

-Eric

Monday, July 14, 2008 4:48 PM by Eric Holk [MSFT]

# re: TS-Teleport: Sample Instructions

Hi Eric,

 I met a problem when I run it, WTSVirtualChannelOpenex() failed, I think I have the same problem with Ravi, can you tell me how to operate it correctly? how to establish TS connection in client side?

Monday, July 28, 2008 10:54 PM by Edward

# re: TS-Teleport: Sample Instructions

I can register the 32-bit client and server dlls (on both XP SP3 and 2008 x64) successfully, however the TS 'ignores' the presence of the .tsteleport file in the user's SendTo directory, only presenting all other items in the directory through the context menu.

The TS is Windows 2008 x64, will registering the 32-bit dll be a problem here or can it run successfully under WoW?

Tuesday, August 19, 2008 9:41 AM by bjtm

# static virtual channel & RDP 6.1 client

We have a problem using RDP 6.1 Client with  static virtual channels.

I our case everthing is working fine with the RDP 5.X client, but with RDP 6.1 (shipped with XP SP3) client, the static virtual channel doesn't work anymore.

As you saíd before, the RDP 6.1 Client should still support static virtual channels. Are there any known problems?

Tuesday, October 14, 2008 1:33 PM by Kalle

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker