(1) write the registry and set Automatic startup.
Hkey sub;
Char bufname [200];
: Getmodulefilename (null, bufname, 200 );
Cstring STR;
Str. Format ("% s", bufname );
Cstring skey = "software // Microsoft // windows // CurrentVersion // run ";
: Regcreatekey (HKEY_LOCAL_MACHINE, skey, & sub );
If (m_autorun.getcheck ())
{
: Regsetvalueex (sub, "armybugle", null, REG_SZ, (const byte *) Str. getbuffer (0), str. getlength ());
}
Else
{
: Regdeletevalue (sub, "armybugle ");
}
: Regclosekey (sub );
(2) timer event and MDI device processing, regular playing of music
Ctime tt;
Tt = ctime: getcurrenttime ();
Cstring TMP = TT. Format ("% H: % m ");
If (TMP = strtime)
{
Killtimer (1 );
Mcideviceid m_ndeviceid;
Mcideviceid m_nelementid;
Mci_open_parms mciopenparms;
Mciopenparms. lpstrdevicetype = (lpstr) mci_devtype_waveform_audio;
Mcisendcommand (null, mci_open, mci_open_type | mci_open_type_id | mci_wait, (DWORD) (lpvoid) & mciopenparms );
M_ndeviceid = mciopenparms. wdeviceid;
Mci_open_parms mciopen;
Memset (& mciopen, 0, sizeof (mci_open_parms ));
Mciopen. lpstrelementname = strsound;
Mcisendcommand (m_ndeviceid, mci_open, mci_open_element, (DWORD) (lpvoid) & mciopen );
M_nelementid = mciopen. wdeviceid;
Mci_play_parms mciplay;
Mciplay. dwcallback = (DWORD) This-> getsafehwnd ();
Mcisendcommand (m_nelementid, mci_play, mci_policy, (DWORD) (lpvoid) & mciplay );
// Settimer (0515, null); // Delete
}
Cdialog: ontimer (nidevent );