Use Text Input Source Services if you're on 10.5 or higher. It's based on CoreFoundation, so don't worry it's inside Carbon framework. If you need to support 10.4 or older, you need to use Keyboard Layout Services. I only know the former, so let me explain just that.
You use
CFArrayRef sourceList= TISCreateInputSourceList (NULL,false);
to get the array of TISInputSourceRef
corresponding to all the enabled keyboard types. Then you can use other functions to examine them. To select/deselect one, you can use TISSelectInputSource
and TISDeselectInputSource
, etc.
Don't forget to CFRelease
the array you got, though, even in the garbage collected environment, because the garbage-collection of CF objects are not automatic!