TESTALL.EXE

Overview

This program illustrates the use of the SMS functions to examine a site hierarchy, package container, or job container. For each type of container, the user is prompted for which of the standard sets of filters to apply. The container is then populated, and enumerated to the console.

Running the Program

TESTALL.EXE runs as a console application. The program prompts you to enter the information needed to connect to SQL Server, then prompts you to specify Sites, Jobs, or Packages.

When viewing a Site hierarchy, the program will display the site/domain/machine/machine group tree for the associated datasource according to the filter conditions that you specify during program execution.

When viewing a job container, the user can select a Run Command On Workstation job (w), Share Package On Server job (s), Remove Package From Server job (r), or System job (y). Make one selection per line, and type x to specify no more job types. Selections are connected by the OR operator, so it is possible to select multiple job types. It is also possible to select no filters (x), in which case the system displays all job types.

When viewing a package container, the user can select a workstation package (w), a server package (s), or an inventory package (i). Make one selection per line, and type x to specify no more package types. Selections are connected by the OR operator, so it is possible to select multiple package types. It is also possible to select no filters (x), in which case the system displays all package types.

For both jobs and packages, the program will enumerate all folders and subfolders in the specified container. For each folder it will then display all scalars. After displaying the appropriate data, the program will allow you to restart (examine a new container) or quit.

Functions

SmsAPIVer
SmsDataSourceConnect
SmsDataSourceDisconnect
SmsOpenContainer
SmsCloseContainer
SmsPopulate
SmsGetFolderCount
SmsGetNextFolder
SmsGetFolderID
SmsGetFolderType
SmsGetScalarCount
SmsGetNextScalar
SmsCreateFilter
SmsSetFilter
SmsCloseFilter
SmsAddToken
SmsGetToken
SmsGetTokenCount

Program Flow

This program illustrates the use of the SMS functions to examine a site hierarchy, package container, or job container. The only difference in code between them is the setting of filters.

The code connects to the datasource and prompts the user to select the type of container to view. The user then is asked to select and apply valid filters for the container. All folders in the container are then retrieved, and the folder handles are stored in an array. The container is closed after the folder handles have been stored. The folders are then displayed recursively.

Note that the container is closed before the folders are displayed. This allows the memory used by the folders themselves to be recovered as soon as the folders are closed. Folders all have reference counts and will only be released when this count falls to zero. This technique is also used inside the DisplayFolder function in the sample.