1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
private void timerCheckMsgSIM_Tick(object sender, EventArgs e)
{
int hSim = 0;
try
{
log.ecriLog(this.Name.ToString() + " : Début vérif SIM ");
hSim = 0;
int SIM_SMSSTORAGE_SIM = 2;
Int64 result = SimInitialize(0, 0, 0, ref hSim);
if (result != 0) throw new Exception("Erreur Initialisation SIM");
uint smsUsed = 0; //Nombre de SMS stockés sur la SIM
uint smsTotal = 0; //Capacité SMS sur SIM
result = SimGetSmsStorageStatus(hSim, Convert.ToUInt32(SIM_SMSSTORAGE_SIM), ref smsUsed, ref smsTotal);
int index = 1; //Index sur la SIM
//Pour chaque entrée possible sur la SIM, lecture du SMS, suppresion puis traitement du message.
for (index = 1; index <= smsTotal; index++)
{
SimMessageTag sms = new SimMessageTag();
result = SimReadMessage(hSim, SIM_SMSSTORAGE_SIM, index, ref sms);
if (result == 0)
{
result = SimDeleteMessage(hSim, SIM_SMSSTORAGE_SIM, index);
if (result == 0 && !String.IsNullOrEmpty(sms.lpszMessage))
SmsTraitement(sms.lpszMessage);
}
}
}
catch (Exception ex)
{
log.ecriLog(this.Name.ToString() + " : Exception Check SIM " + ex.Message);
}
finally
{
SimDeinitialize(hSim);
}
} |
Partager