After a filter container is opened, it is populated with persistent filters. You can read the contents of each filter in the filter container and the tokens within each filter.
There are two methods for retrieving persistent filters from a filter container:
Example:
// Get the handles to first 30 filters in the filter container
// and put them into an array of handles.
HANDLE hFilter;
DWORD numFilters = 30;
DWORD dwI = 0;
// Allocate memory for the filter handles.
HANDLE *phFilters = (HANDLE *)malloc(numFilters * sizeof(HANDLE));
// Loop to get handles to all filters
// and write them to the allocated array.
// Initial value for loop.
stat = SMS_OK;
while(stat = SMS_OK)
{
// Get the next filter in the filter container.
stat = SmsGetNextFilter( hFContainer, // Handle to filter
F_MACHINE, // For machine filters.
&hFilter // Assign handle to
// filter to hFilter.
);
// Check if this is the last filter in the filter container.
// If last, break.
if (stat == SMS_NO_MORE_DATA) {
//last filter
break;
}
// Check if there is an error retrieving the filter.
if (stat != SMS_OK) {
printf("Error in retrieving a filter: %d\n", stat);
break;
}
// Assign the filter handle to the next handle in the array.
phFilters[dwI] = hFilter;
dwi++;
}
Example:
// Get the "TIM00001" filter for
// the filter container with handle hFContainer.
char *pszID = "TIM00001";
HANDLE hMyFilter;
stat = SmsGetFilterByID(hFContainer, // Handle to filter
// container.
F_MACHNE, // Type is machine.
pszID, // ID to retrieve.
&hMyFilter // Assign handle to
// hMyFilter.
);