Access folder contents

After a container is populated with the folders you want to find, you can read the contents of each folder in the container and the scalars within each folder.

For top-level folders in containers, your application can retrieve folders only in sequence. (Note that subfolders within folders, such as program item folders within a package folder, can be retrieved by identifier with the SmsGetFolderByID function.) After a container has been populated, the order of the folders within that particular container is fixed. Using the SmsGetNextFolder function, your application can access the folders in the container sequentially. SmsGetNextFolder returns the handle to the next folder in the list of folders within a container. To start at the beginning of the list, use the SmsRewind function.

Example:

// Get the handles to all top-level folders in the container.
DWORD numFolders;
SmsGetFolderCount( hContainer, F_ANY, &numFolders);
printf("Container has %d folders\n\n", numFolders );

// Allocate memory for the top-level folders.
HANDLE *phFolders = (HANDLE *)malloc(numFolders * sizeof(HANDLE));

HANDLE hFolder;
// Loop to get handles to all top-level folders 
// and write them to the allocated array.
  for (DWORD dwI = 0; dwI < numFolders; dwI++) {
    stat = SmsGetNextFolder( hContainer,
                             F_ANY,  // For all folder types.
                             &hFolder
                           );
      if (stat != SMS_OK) {
          printf("Error in retrieving a folder: %d\n", stat);
          break;
      }

      phFolders[dwI] = hFolder; //Assign the folder handle to 
                                //next handle in the array.
  }
 

If a folder has subfolders, your application can use these same methods to access those folders. Note that SmsEnumFolderTypes returns a list of the types of subfolders that a folder can contain. SmsGetFolderCount returns the count of the subfolders of a specified type within a folder.

After your application gets the handle to a folder, your application can retrieve the scalars for that folder. The scalars can be retrieved in sequence or by the scalar name:

Note that the SmsGetScalarCount function returns the count of scalars within a folder.

If a folder no longer needs to be accessed, use the SmsCloseFolder function to close the folder and deallocate the memory used by the folder.