Timing Music Program III: The Playback and control of MCI devices

Source: Internet
Author: User

(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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.