Jump to content

SetAlarm - my first WM5 program


Guest rogueqd

Recommended Posts

Guest othoca

You have done a good job!!! In which language have u developed it? using the cf 2.0? is it possible to have the source code too? Thanks in advance

Edited by othoca
Link to comment
Share on other sites

  • 2 weeks later...
Guest rogueqd

I used CF2.0 with the OpenNetCF 1.4 registry code.

I'm making a much improved version so I don't have the original source for this one anymore, but the interesting parts are:

using OpenNETCF.Win32;

private RegistryKey registryKey;

private string soundKeyName = "ControlPanel\\Sounds\\Clock";

private string timeKeyName = "Software\\Microsoft\\Clock\\0";

private void ReadRegistry()

{

byte[] rBuff;

registryKey = Registry.CurrentUser.CreateSubKey(soundKeyName);

soundFile = (string)registryKey.GetValue("Sound");

if (registryKey.ValueCount == 3)

{

alarmScript = (string)registryKey.GetValue("Script");

}

else

{

alarmScript = "ap";

}

registryKey.Close();

registryKey = Registry.LocalMachine.CreateSubKey(timeKeyName);

alarmState = (byte[])registryKey.GetValue("AlarmFlags");

if (alarmState == null)

{

alarmState = new Byte[1];

}

rBuff = (byte[])registryKey.GetValue("AlarmTime");

if (rBuff != null)

{

alarmTime = Convert.ToInt32(rBuff[0]) + (256 * Convert.ToInt32(rBuff[1]));

}

registryKey.Close();

}

private void WriteRegistry()

{

Byte[] rBuff = {0,0};

if (cboAlarmState.SelectedItem == "On")

{

alarmState[0] = 1;

}

else

{

alarmState[0] = 0;

};

alarmTime = 0;

alarmTime = alarmTime + dateTimePicker1.Value.Minute;

alarmTime = alarmTime + (dateTimePicker1.Value.Hour * 60);

while (alarmTime > 255)

{

rBuff[1]++;

alarmTime = alarmTime - 256;

}

rBuff[0] = Convert.ToByte(alarmTime);

alarmScript = "ap";

if (chkRepeat.Checked == true)

{

if (chkInterval.Checked == true)

{

alarmScript = alarmScript + "w3";

}

alarmScript = alarmScript + "r";

}

registryKey = Registry.CurrentUser.CreateSubKey(soundKeyName);

registryKey.SetValue("Sound", soundFile);

registryKey.SetValue("Script", alarmScript);

registryKey.Close();

registryKey = Registry.LocalMachine.CreateSubKey(timeKeyName);

registryKey.SetValue("AlarmFlags", alarmState);

registryKey.SetValue("AlarmTime", rBuff);

registryKey.Close();

}

Hope that's not too messy for anyone. ;)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.