(1) Write the registry, set the automatic operation of the boot
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 events and MDI device processing, timed to play 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_notify, (DWORD) (LPVOID) &mciplay);
SetTimer (1,10000,null); Delete 0515
}
Cdialog::ontimer (nidevent);