Getting Started with DTO
This section describes how to set up DTO for use in Visual Basic, Active Server Pages (ASP), and Delphi.
Visual Basic
Since DTO is a library of dual interface COM objects, there are two ways of working with these objects in Visual Basic. If you are using Active Server Pages, you must use the second method. The first and preferred method is to add the type library to the project. This method allows VB to do type checking and provides the developer with useful drop down options for object creation and function parameters (Intellisense).
The other method is to use the CreateObject function. This creates objects at run time and therefore lacks type checking and the Intellisense feature.
Adding a Reference to DTO to a Project
To add the Distributed Tuning Library to a Visual Basic project:
1
Select References from the Project menu.
2
Scroll through the available entries and select the Pervasive Distributed Tuning Library 1.0 or Pervasive Distributed Tuning Library 2.0 check boxes. For more information on the difference, see DTO2.
3
VB is now aware of all the objects included in DTO. All the objects are now browsable. To view the available objects:
1
Select Object Browser from the View menu. Alternatively, you can press F2.
2
Select DTOLib or DTOLib2 from the list of available libraries depending if you want DTO Version 1 or 2, respectively. For more information on the difference, see DTO2.
Using the CreateObject Function
You need to use this method when instantiating an object with ASP. The CreateObject syntax looks like this:
Dim my_session as Object
‘ For DTO Version 2
Set my_session = CreateObject("DTO.DtoSession.2")
‘ or use DTO Version 1 for compatibility with
‘ previous DTO applications
Set my_session = CreateObject(“DTO.DtoSession.1”)
Most of the DTO objects can later be obtained from the session object.
Active Server Pages
There is no special initialization required to use DTO with ASP. However, note the following:
ASP by default does not save state information between calls. You will need to use the Microsoft IIS built-in Session object to preserve object references and variable state.
For example, to initialize a DtoSession object with DTO Version 2:
Set Session("my_session") = Server.CreateObject("DTO.DtoSession.2")
Delphi
There are two ways to utilize COM objects in Delphi. As with Visual Basic, the first and preferred set-up method is to import the type library into the Delphi project.
The other method allows COM interfaces to be called directly by using CreateOleObject function. This function will instantiate a single instance of an Automation object.
Importing the DTO Type Library into a Delphi project
In order to import the type library and generate the necessary Pascal declarations:
1
Select Project | Import Type Library.
2
The Import Type Library dialog box displays the type libraries registered on the system. Choose Pervasive Distributed Tuning Library 1.0 or Pervasive Distributed Tuning Library 2.0
3
Enter a location of pascal unit in Unit directory name and press Create Unit. The file DTOLib_TLB.pas or DTOLib2_TLB.pasfile will be created and included in the project, depending on whether you use DTO version 1 or 2.
4
uses DTOLib2_TLB; // Dto Version 2
uses DTOLib_TLB;  // Dto Version 1
Example of Using Pascal Declarations
var
Result:DTOResult;
Session:DTOSession;
MySettings:DTOSettings;
MyCategories:DTOCategories;
MyCategory:DTOCategory;
i:integer;
begin
Session:=CoDTOSession.Create;
Result:=Session.Connect
('ServerName','UserName','Password');
MyCategories:=Session.Categories;
for i:=1 to MyCategories.Count do
MyCategory:=MyCategories.Item[i];
end;
Example of Using Direct COM Calls
Example:
var
Session, Categories, Category: Variant;
I: Integer;
begin
Session := CreateOleObject('DTO.DtoSession');
Session.Connect('ServerName','UserName','Password');
Categories := Session.Categories;
for I := 1 to Categories.Count do
Category := Categories.Item[I];
end;