Timed playing music program 3: playback and control of the mci Device

Source: Internet
Author: User

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

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.