Apple manual Using Network Setup, Opening and Closing the Network Setup Database

Models: Network Setup

1 184
Download 184 pages 5.56 Kb
Page 25
Image 25
Using Network Setup

C H A P T E R 2

Figure 2-0

Listing 2-0

Table 2-0

Using Network Setup

This chapter explains how to use the Network Setup programming interface to read and write network preferences. It assumes that you are familiar with basic Network Setup concepts. If not, you should read Chapter 1, “About Network Setup,”for important background material. This chapter concentrates on practical examples of coding with Network Setup.

Opening and Closing the Network Setup Database

This section explains how your application should open the Network Setup database for reading and writing and then discusses how to close the database and, in the case where the database has been opened for writing, either committing or discarding your modifications.

Opening the Database for Reading

The MyOpenDatabaseForReading routine shown in Listing 2-1 shows how to open the default (or current) area in the Network Setup database for reading. It starts by calling OTCfgOpenDatabase, which returns a database reference (of type CfgDatabaseRef) that identifies your application’s connection to the database. It then calls OTCfgGetCurrentArea, which returns an area identifier (of type CfgAreaID) that identifies the default area. Finally, it opens the default area for reading by calling OTCfgOpenArea.

The MyOpenDatabaseForReading routine returns both the database reference

(dbRef) and the default area identifier (readArea). You must know these values in order to read preferences and eventually close the database.

Opening and Closing the Network Setup Database

25

Page 25
Image 25
Apple manual Using Network Setup, Opening and Closing the Network Setup Database, Opening the Database for Reading