How to compile dynamic virtual channel c++ example from MSDN - c++

On MSDN there is an example in C++ on how to create Dynamic virtual channel plugin.
My problem is that I don't know how to compile it.
Do I need to create an ATL project and in main.cpp copy-and-paste the code found on msdn? What do I call the project? If I create ATL project with name DVCPlugin, than Visual studio 2008 automatically creates DVCPlugin_i.h file, otherwise I don't have that file.
tsvirtualchannels.h is part of Windows 7 SDK so at least with that include I don't have a problem.
One of the errors I am getting is this:
&CLSID_DVCSamplePlugin not recognized identifier
I tried to create ATL project with the name DVCSamplePlugin but I received the same message as above.
Any suggestions I need to do to be able to compile that source code?

It took me a couple of hours, but I got the source for the client plugin to build using VS 2012. Here were my steps.
Start a new ATL Project named DVCPlugin. Select the option for a DLL.
Choose support for COM+ and check the box for the Object Registrar.
Add a file named GUID.cpp to the DVCPlugin project. include stdafx.h in this file.
ATL gave me a class named CompReg, which had its own IDL entries and GUID. I needed to associate that GUID with the CDVCSamplePlugin class.
In DVCPlugin.cpp, add the include for <tsvirtualchannels.h> to the top.
Paste the rest of the sample code after the definition of DllInstall().
Change the line DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN) to DECLARE_REGISTRY_RESOURCEID(IDR_DVCPLUGIN).
It looks like building the solution silently runs the registry script in the DVCPlugin.rgs file. I had to change the threading model to Free, though.
If mstsc.exe is 64-bit, you need a 64-bit plugin dll for the dynamic discovery to work.

This is just some code for testing Remote desktop connection -
There is an "echo" listener that is implemented by the Remote Desktop Connection (RDC) client, which is always present and listening for incoming connections. When you are writing the server side of a dynamic virtual channel (DVC) module, as a quick test you can open an endpoint named "ECHO". Any write to a channel that is instantiated from this endpoint will result in the receipt of the same data.
From MSDN.
Such projects are usually included in some SDK. And this one seems to be part of Windows 8 SDK
Update: After a critique from Tim (see below), i've decided to add these links with MSDN information -
Remote Desktop Services. TS-Teleport: Sample Instructions and
Remote Desktop Services Blog. Dynamic Virtual Channels

Related

Register ActiveX Control without an ocx file

I am adding functionality to an open source project which uses an external activex control known as DMGraph (http://www.codeproject.com/Articles/310494/D-Graph-ActiveX-Control-in-Cplusplus-with-ATL-No-M?msg=4567275#xx4567275xx) but I get an error that the control needs to be registered when I try opening the resource file that uses this control. As stated on the project page that I linked, there is no ocx file, but I don't understand how I'm supposed to register this control without said file. If its any help to finding the issue, I have simply downloaded the source code to this open source project that i'm trying to get this work in. It has already implemented the DMGraph functionality and works in their builds so the issue must be with trying to build it on a different machine. Any ideas?

Sitecore 7.2 Command Configuration

I'm trying to get a command working in a new instance of Sitecore 7.2. The command that I've added lives in a different assembly than the main project for this web application. I've added the full path to the file for the command, along with the name of the compiled assembly in the App_Config/Commands.config file.
In Sitecore, I've added the command template under the branches/user defined folder and entered the command name from Commands.config, in the Command field. I've then added the command as an insert option on the appropriate item in Sitecore.
When I log on as an admin and click the command link under the Home tab in the top menu, nothing happens. No error is generated and the pop-up window does not appear - just nothing.
Having configured commands many times before in earlier versions of Sitecore, I can't think of what I'm missing... The only difference this time is that the file for the command is located in a different assembly. Am I missing a step somewhere that is needed, in order for this to work? Did something change in Sitecore 7.2?
It looks like there was an error in the reference to the namespace. Once I updated that, the code ran. The frustrating thing was that Sitecore wasn't generating an error. It just wasn't responding, at all.
I had a similar situation the other day. I had a Visual Studio solution with just one Class Library project and one C# class in the project. I wrote some code in that class, built the solution and moved the DLL into my Sitecore website's bin folder. I tried running the feature in Sitecore and nothing happened. I confirmed I was referencing the DLL appropriately. I then used the debugger in my Visual Studio to attach to my process and sure enough, the method parameters that Sitecore was supposed to set in my method signature were not getting set.
After trying a lot of different things, I decided to add a Web Application to my solution. I then moved the code from the Class Library to the Web Application and updated Sitecore to reference the Web Application DLL instead of the Class Library DLL. All of the sudden, my method parameters were set and the rest of my code worked as expected!
So my suggestion is: if you have the code the in a Class Library right now, move it to a Web Application project and see if that helps.

How to create an extension for Internet Explorer as Exe Com server?

I need to create an extension for Internet Explorer and I need it to be EXE Com server.
First, I created a simple COM DLL project using ATL wizard as described here and it worked very well, IE loaded my extension and it showed my message boxes. Next, I repeated all these steps but created COM EXE project. I registered it the same way and Internet Explorer can see the extension but it does not work. My functions IObjectWithSite::SetSite and IObjectWithSite::GetSite aren't called. Could you please advice me how to resolve this problem?
You can not register Out-of-Process COM server as a BHO, but you can call COM server from your BHO. E.g. you can use late binding:
CComDispatchDriver pServer;
if (SUCCEEDED(pServer.CoCreateInstance(CLSID_YourComServer)) {
pServer.Invoke0(L"ServerMethodName");
}
Make sure you have build and register proxy-stub dll for your project (auto generated project with YourServerPS.dll name).

Compiling native COM client stub in client, using VS2010

I'm new to COM programming, and creating a basic native COM server / client pair from Visual Studio 2010. Both the client and the server projects live in the same solution. I'd like to know what the most appropriate way is to include the generated client stub and header file in the client project. I've created the MIDL in my server project, and when I compile the project the _h.h, _i.c, and _p.c files are generated in my project source directory.
Do I need to compile both of the .c files in my client project?
Is the best way to compile these in the client project by adding them as linked files in the client project from the source directory of the server project?
Is there a way for Visual Studio to know that the _h.h, _i.c, and _p.c files are out of date when I modify the MIDL, or do I need to remember to recompile the server project any time I touch the MIDL?
Where's the best place for the .h file to go - can it go in the stdafx.h file in the server project? If so, is it proper to add the source directory of the server project to the header include directories of the client project?
Should the client project have a "Reference" (in the Visual Studio Reference sense) to the server project?
Additionally - I'd like to make this registration free. Is there anything extra I need to do in this case, besides having manifests for my client and server?
..
edit
Looking at the MSDN article here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366830(v=vs.85).aspx, it appears that of the files generated, if I only want to support in-proc reg-free activation, I only need to compile the _i.c and include the _h.h files in my client program.
dlldata.c, and _p.c appear to be used to create a proxy DLL, which supports registration on a remote computer (for activation by a remote computer? or also local computer, out of proc? If it's required for local computer, out of proc, why is it needed given that the COM server's dll is registered? The COM server DLL is different from the proxy DLL, yes?)
Thanks very much,
--Matt
The generated _p.c and dlldata.c must be compiled into a separate project to build the proxy/stub DLL. You don't always need one, only when you marshal calls across apartments or processes.
The generated _i.c file provides the GUID values. Compile it into the server and the proxy/stub. Compiling it into the client is okay but using the __uuidof keyword is easiest.
The generated _i.h file contains the interface and coclass declarations. You'll need to #include it in the server and the client.
Midl.exe should automatically regenerate these files when you change the .idl. Which in turn ensures that client, server and proxy/stub get rebuilt.
stdafx.h is fine, yes on the include directory.
No on the "reference", the client and server have no link dependency.
You'll have to write the manifest for reg-free com and embed it in the client.

How To Prepare An ActiveX Control For Delivery Over The Web

So i have the misfortune of embedding this proprietary ActiveX control we created into a web page so that it downloads the code from our server and installs as necessary.
Our ActiveX requires a host of other files which need to be installed along with the activex control itself. It should also be noted that the activex and all its dependencies are c++-based COM objects (many use MFC).
So I read this article about it:
http://msdn.microsoft.com/en-us/library/aa751974(VS.85).aspx
But it leaves a lot of things unanswered. For one thing, my ActiveX is actually embedded in a DLL file that contains other COM interfaces. Also, is it possible to have the mentioned cab file include the ActiveX/SDK installer and run that if the GUID isn't present? For example:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
Setup.exe=Setup.exe
[Setup.exe]
file-win32-x86=thiscab
run=%EXTRACT_DIR%\Setup.exe
Security is not an issue here as this is an intranet-based solution (not available publically).
Also, the article mentioned here seems really old. Is there more up to date info available?
You can create a dependency between the installer and a dll that is on the system like this:
[Add.Code]
Your-dll-name
[Your-dll-name]
Version=Your dll version
hook=setup.exe
[Setup.exe]
file-win32-x86=thiscab
run=%EXTRACT_DIR%\Setup.exe
If the system cannot find your dll or the version is lower, then it will run the setup.exe that suppose to install and register the dll.