Horloge système et alerte sonore!

cs_othland Messages postés 298 Date d'inscription jeudi 18 décembre 2003 Statut Membre Dernière intervention 9 février 2010 - 6 avril 2006 à 11:11
sphaxslayer Messages postés 216 Date d'inscription mardi 5 avril 2005 Statut Membre Dernière intervention 17 septembre 2008 - 6 avril 2006 à 12:45
slt tlm,
je veux ajouter une portion de code qui surveille l'horloge système et qui déclanche une alrte sonore à une heure bien précise!
quelqu'un sait comment le faire???

1 réponse

sphaxslayer Messages postés 216 Date d'inscription mardi 5 avril 2005 Statut Membre Dernière intervention 17 septembre 2008
6 avril 2006 à 12:45
Salut,
ce code surveille le temps du systeme. Vois si tu peux pas t'en servir pour ta surveillance. En revanche, pour l'alerte sonore je ne sais pas du tout !
=======================================================
[DllImport("coredll.dll")]
private extern static void GetSystemTime(ref SYSTEMTIME lpSystemTime);

[DllImport("coredll.dll")]
private extern static uint SetSystemTime(ref SYSTEMTIME lpSystemTime);

using System.
using System.Runtime.InteropServices;
using System.Windows.Forms

private struct SYSTEMTIME
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
}

private void GetTime()
{
// Call the native GetSystemTime method
// with the defined structure.
SYSTEMTIME stime = new SYSTEMTIME();
GetSystemTime(ref stime);

// Show the current time.
MessageBox.Show("Current Time: " +
stime.wHour.ToString() + ":"
+ stime.wMinute.ToString());
}
private void SetTime()
{
// Call the native GetSystemTime method
// with the defined structure.
SYSTEMTIME systime = new SYSTEMTIME();
GetSystemTime(ref systime);

// Set the system clock ahead one hour.
systime.wHour = (ushort)(systime.wHour + 1 % 24);
SetSystemTime(ref systime);
MessageBox.Show("New time: " + systime.wHour.ToString() + ":"
+ systime.wMinute.ToString());
}
=======================================================

"Un seul Être vous manque, et tout est dépeuplé..."
0
Rejoignez-nous