Hi, you might also find this sample useful: https://github.com/Azure/azure-iot-sdk-c/tree/main/provisioning_service_client/samples/prov_sc_query_sample.
As it stands the sample just prints the registration IDs, but you could modify it to use individualEnrollment_getDeviceRegistrationState
to get the registration state.