public static string[] GetReaderList(IntPtr hContext, string Groups) { int i, j = 0; string s = ""; uint rc; uint readers_size = 0; int readers_count = 0; rc = SCARD.ListReaders(hContext, Groups, null, ref readers_size); if (rc != SCARD.S_SUCCESS) { return(null); } string readers_str = new string(' ', (int)readers_size); rc = SCARD.ListReaders(hContext, Groups, readers_str, ref readers_size); if (rc != SCARD.S_SUCCESS) { return(null); } for (i = 0; i < readers_size; i++) { if (readers_str[i] == '\0') { if (i > 0) { readers_count++; } if (readers_str[i + 1] == '\0') { break; } } } string[] readers = new string[readers_count]; if (readers_count > 0) { for (i = 0; i < readers_size; i++) { if (readers_str[i] == '\0') { readers[j++] = s; if (readers_str[i + 1] == '\0') { break; } s = ""; } else { s = s + readers_str[i]; } } } return(readers); }