<!-- Download Links -->
Most of the developers that work with graphic applications or work with applications that
have full-screen window some times need to know exactly what is going on behind the
function or any other screen-drawing function. The problem is that when you set up a break point in the
the focus of the window goes to the VC++ environment. When this happens, your on paint event
is lost and you can't even see what's happening during the painting process. This situation
is very common in directX programming too, where the program need to use fullscreen mode
and doesn't allow you to switch to VC++.
MS VC++ has a workaround to this problem called remote debugger. The remote debugger enables you
to execute your app in one machine while you step into the code in another machine.
To explain how this VC++ feature works, we are going to use the
sample project provided with this article.
Setting up the environment
The first thing you need to do is install the remote debugger in the remote machine.
If you don't have VC++ installed in the remote machine (it's not required
:) ), you need
to copy the following files to the system directory of the remote computer:
After copying this files you need to establish a connection between the remote computer
and the "host" computer (we'll call that computer that hosts VC++ "host" for now on). To
do this, create a folder in the remote computer and share it so that the host computer can see it.
You must do the same thing in the host computer. Create a folder called "Test" and share it
so that the remote computer can access it.
The next step is to copy the remote debugger files to the remote machine. To do this,
in the host computer, map the drive that you shared early in the remote computer. After
mapping the drive, copy the remote debugger files. This files can be found in the
Visual Studio Folder at the subfolder Common\MsDev98\Bin. This files are:
When the files are copied, in the remote computer, go to the folder where the files
were copied. Find the MSVCMON.EXE file and start it. When you start it, you'll see
the following screen.
When you see this screen, hit the Connect button, so that your machine starts to listen
for any connection to the remote debugger. The following screen will be showed.
Setting up the VC++ project
We have the remote computer up and running. Now we are going to use the sample project
to test the remote debugger. First copy the sample project files to the shared "Test" folder
in the host computer. Open the sample project and locate the OnPaint message handler
function. The function must contain this code:
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
dc.TextOut(200,i, "THIS IS DRAWED STEP BY STEP!");
Set a break point at the line contain the "for" statement, so that we can step into
the code while the window is being drawn.
The next step is to set the project to run using the remote debugger. Go to the
Project Menu and select the Settings menu item. The project settings window should
Select the Debug Tab. In this window we will see 4 text boxes. In the first check box, you need
to type the complete path of the application executable file as the host computer see it.
(Ex.: My project is running under C:\Test in the host computer, so you need to type
The second and third text box can be just blank. In the forth text box you need to
type the path of the application as the remote computer see it. If you have copied
sample project to the "Test" folder, you need to inform the path of the mapped drive
in the remote computer (Ex.: Let's say that you have mapped out "Test" folder of the
host computer in the F: drive letter of the remote computer. In this case you need to
inform F:\TestRemoteDebug.exe in the text box). After this step you can close the project
We are almost ready! Now you need to inform to the project which computer will be the
remote debugger. To do this, go to the Build Menu and select the "Debugger Remote Connection..."
option. Within this window, select the TCP/IP protocol and click on settings. In the settings
window inform the name or IP address of the remote computer. After that you can close this
window hitting the ok button.
Ok! We are ready! Start your project by hitting the F5 key (or Run menu item). The
first time you execute you'll probably see a screen like this:
This happens because VC++ needs to find a local reference of each DLL that the project
uses in the local machine. The first time this message boxes appear, just inform the correct
path of the local DLLs.
Now just step into the code in the host computer and see what happens in the remote
machine! Have fun!