Creating an ATL Server Project


For this hour's lesson, you're going to go a little beyond the customary Hello World example. By the end of the lesson, you will have created the famous number-guessing game, where the object is to guess the magic number randomly generated by the server in the smallest amount of guesses possible.

To begin with, open the Project Wizard dialog by selecting New, Project from the File menu. Select Visual C++ Projects from the Project Types list and click the ATL Server Project template. Give your project the name NumberGuess and click OK.

The first thing you'll see is the ATL Server Project Wizard dialog, as shown in Figure 14.1.

Figure 14.1. The ATL Server Project Wizard.


Although you're going to use all the default settings for this project, it helps to know what the available options are for your ATL Server project.

Click the hyperlink titled Project Settings on the left side of the dialog. These options, shown on Figure 14.2, control what binary files are created and how they are deployed. Each ATL server needs at least two components to function correctly. The first is the Web application DLL. This DLL contains the tag-replacement logic and is the main component where you will perform most of your ATL Server actions. The second component is the ISAPI extension DLL. The ISAPI extension DLL is responsible for interacting with the IIS Web server. This DLL handles incoming client requests from IIS and delegates them to the appropriate tag handler within your Web application DLL. These two main components, however, do not need to reside in different DLLs. By checking the box labeled Generate Combined DLL, you can place both components within the same DLL. The last option available to you on this page is the Deployment Support option. This option is responsible for placing all of the necessary files for your Web application into an IIS virtual root folder on your local machine. It also registers your extension DLL so that IIS forwards client requests appropriately.

Figure 14.2. The Project Settings dialog for ATL Server.


Figure 14.3 shows the next page of options: Server Options. The first three options available under the Additional Support Options heading deal with data caching. Data caching provides enhanced performance when dealing with differing types of data. ATL Server can cache the following types of data:

  • Binary Large Objects (BLOBs), which are large areas of allocated memory used for various reasons, such as for binary data for an image file

  • Files that are temporary and will be deleted upon release of the file-caching object (IFileCache)

  • OLE DB data source connections on a per-thread basis

Figure 14.3. The server options available in ATL Server.


The remaining options on this page allow your ATL Server application to create performance counters to be viewed through the system's Performance Monitor application. With this enabled, you can view real-time statistics of client requests passing to your application from IIS. Checking the Browser Capabilities Support option will allow you to gain information about the client browser you are rendering to, provided that the user has made this information available in the security settings. This will allow you to tailor any HTML and scripting code to make sure your application renders correctly on different browser platforms.

The third page of available options, Application Options, changes behavior within your application DLL (see Figure 14.4). The first option, Validation Support, inserts a function within your application that verifies the data received as query parameters and form variables. The second option, Stencil Processing Support, is important because it provides the tag-replacement logic necessary for your ATL Server project. If you want your ATL server to be accessible as a Web Service, you can select the third check box, and the necessary code will be inserted to do this. The last two options on this page insert culture information into the server response file (SRF). The SRF will be covered later in this hour.

Figure 14.4. The application options available in ATL Server.


Finally, the last page of options for your ATL Server project aids you when creating your Web application. You can have the wizard insert comments telling you to fill in the missing pieces in the generated code. The second check box tells the wizard to generate attributed code (attributes are covered in the next hour), and the last option inserts debugging support. Figure 14.5 shows the Developer Support Options dialog.

Figure 14.5. Options for developer support within your ATL Server project.



Sams Teach Yourself Visual C++. NET in 24 Hours
Sams Teach Yourself Visual C++.NET in 24 Hours
ISBN: 0672323230
EAN: 2147483647
Year: 2002
Pages: 237

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: