May 24th, 2002, 10:37 AM
Launch default player for audio CD
I am trying figure out how I can get my app to launch the default audio CD player, with a CD Extra (i.e., audio + data) in the CD drive. Oh, and I'm trying to avoid playing with the registry!!
I know (thanks to a post by Ondrak in Nov 2000) that I could do it by parsing the HKEY_CLASSES_ROOT/AudioCD/shell/play/command registry entry to get the default AudioCD program, substituting parameters, and calling ShellExecute ... but that's way too ugly for my liking.
I feel like I SHOULD be able to do it with a more simple ShellExecute call, but I can't for the life of me figure out how. If I try to "open" the drive, it simply brings up Explorer. If I try to "open" the first track (i.e. <drive>:\\Track01.cda), nothing happens (and I can't see the tracks in explorer anyway). "play" isn't a valid verb.
May 24th, 2002, 04:55 PM
Not sure if this will work, but have you tried:
ShellExecute(NULL, "open", "<drive>:\\Track01.cda", NULL, NULL, SW_SHOWNORMAL);
May 24th, 2002, 06:45 PM
Calling ShellExecute on Track01.cda works for a normal CD, but not for a "CD Extra" format CD (audio + data). It seems that Windows can detect it as an audio CD (because Media Player can play it), but in Explorer only the "data" part of the CD is visible. The audio tracks don't appear. Presumably this means ShellExecute also can't "see" the audio tracks.
That means what I'm after is a neat way to invoke the "play" command for the "AudioCD" entry in the "File Types" tab of the explorer options. (AudioCD is one of the entries which doesn't actually have a file extension associated with it).
September 25th, 2003, 02:03 AM
At long last I've come back to my own problem, and found the neat solution that I always thought must be there: Call ShellExecuteEx with at least the following fields of the SHELLEXECUTEINFO structure specified:
fMask = SEE_MASK_CLASSNAME
lpClass = _T("AudioCD")
lpVerb = _T("play")
Leave the lpFile NULL.
This simply launches the "play" command for the default audio CD player, as registered under the pre-XP Autoplay mechanism (i.e., Autoplay V1 rather than V2). If the registered player's command line string has a "%1" parameter, the shell will substitute the current directory (or info.lpDirectory, if it's non-NULL).
This is the only solution I have found that works for CD Extra format CDs.
Incidentally: Why did I want to do that in the first place? Because I wrote an autorun app for a Data + Music CD-Extra CD, and wanted to include a "Play CD" button on it, which simply launches the default audio CD player.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!