There is no built in way to get these numbers/handles, though it should be fairly straightforward to do this yourself. The following code aliases the create/discard functions to wrapper functions that increment and decrement global count variables. You would just have to add the .c file to your project and include the header in any .c file that creates/discards thread pools or TSQs. Then you could just monitor the global variables to see how many queues/pools are alive. I realize you also wanted a list of the handles, but that's not much harder. You would have to keep lists instead of just ints, and you'd have to put locking (see the Cmt Thread Lock functions) around the list accesses for thread safety.
I have not tried or even compiled this code, but I believe it should work.
Also note that the default thread pool is not included in the thread pool count.
// begin new header, MTResourceCounting.h
#ifndef MT_RESOURCE_COUNTING_H
#define MT_RESOURCE_COUNTING_H
#include <utility.h>
#define CmtNewThreadPool CmtNewThreadPoolWrapper
#define CmtDiscardThreadPool CmtDiscardThreadPoolWrapper
#define CmtNewTSQ CmtNewTSQWrapper
#define CmtDiscardTSQ CmtDiscardTSQWrapper
extern volatile int gThreadPoolCount;
extern volatile int gTSQCount;
int CVIFUNC CmtNewThreadPoolWrapper(int maxNumThreads, int *poolHandle);
int CVIFUNC CmtDiscardThreadPoolWrapper(int poolHandle);
int CVIFUNC CmtNewTSQWrapper(int numItems, int itemSize, unsigned int options, int *queueHandle);
int CVIFUNC CmtDiscardTSQWrapper(int queueHandle);
#endif
// end MTResourceCounting.h
// begin new source file, MTResourceCounting.c
#include <utility.h>
volatile int gThreadPoolCount = 0;
volatile int gTSQCount = 0;
int CVIFUNC CmtNewThreadPoolWrapper(int maxNumThreads, int *poolHandle)
{
int err = CmtNewThreadPool(maxNumThreads, poolHandle);
if (err >= 0)
++gThreadPoolCount;
return err;
}
int CVIFUNC CmtDiscardThreadPoolWrapper(int poolHandle)
{
int err = CmtDiscardThreadPool(poolHandle);
if (err >= 0)
--gThreadPoolCount;
return err;
}
int CVIFUNC CmtNewTSQWrapper(int numItems, int itemSize, unsigned int options, int *queueHandle)
{
int err = CmtNewTSQ(itemSize, options, queueHandle);
if (err >= 0)
++gTSQCount ;
return err;
}
int CVIFUNC CmtDiscardTSQWrapper(int queueHandle)
{
int err = CmtDiscardTSQ(queueHandle);
if (err >= 0)
--gTSQCount ;
return err;
}
// end MTResourceCounting.c