Can Someone please help???

Hello I'm making a cd player for windows and I have the option to set it as the default cd player. It works ok when I Click on the CDRom Drive it opens up my cd player. I'm using vista and I want to associate my cd player with the cda extension so when I explorer my cdrom drive I want to see my icon with the cda and beable to click on the cda file and it open with my player. Can someone help me with this. here is my code I am trying to use:

BOOL CALLBACK DlgDefault::OnCommand(int NotifyCode, int ControlID, HWND hWndControl)
{
switch(ControlID) {
case RB_CHAMELEON:
EnableControl(EB_OTHER, FALSE);
break;

case RB_OTHER:
EnableControl(EB_OTHER, TRUE);
break;

case BT_SETDEFAULT:
{
int ret;
if(IsButtonChecked(RB_CHAMELEON) == 1) {
ret = MessageBox(Handle, "Set Creative CD As The Default CD Player ?",
"Set Creative CD As The Default CD Player ?",MB_YESNO | MB_ICONQUESTION);
}
else
ret = MessageBox(Handle, "Set This As The Default CD Player ?",
"Set This As The Default CD Player ?",MB_YESNO | MB_ICONQUESTION);

if(ret == IDYES ) {
//ShellExecute(Handle, NULL, "Assoc.exe", NULL, "",SW_SHOWNORMAL);
WRegKey *reg = new WRegKey(HKEY_CLASSES_ROOT, "cdafile\\shell\\play\\command");

WRegKey *reg1 = new WRegKey(HKEY_CLASSES_ROOT, ".cda");
reg1->SetStringValue("Audio CD","cdafile");
delete reg1;

// cda tipy description
WRegKey *regTrackTypeDesc = new WRegKey(HKEY_CLASSES_ROOT, "cdafile");
regTrackTypeDesc->SetStringValue(".cda","Audio CD");
delete regTrackTypeDesc;

WRegKey *reg2 = new WRegKey(HKEY_CLASSES_ROOT, "cdafile\\shell\\play\\command");


char path[MAX_PATH];
char text[MAX_PATH];
if(IsButtonChecked(RB_CHAMELEON) == 1) {
// icon
WRegKey *regIcon = new WRegKey(HKEY_CLASSES_ROOT, "cdafile\\DefaultIcon");
sprintf(path,"%s\\%s,1",myApp->FileDir, myApp->FileName);
regIcon->SetStringValue("",path);
delete regIcon;
sprintf(path,"%s\\%s /play %1",myApp->FileDir, myApp->FileName);
SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL );
}
else {
if(IsButtonChecked(RB_OTHER) == 1) {

if( GetControlText(EB_OTHER, text, MAX_PATH) && ( lstrlen(text) > 0) ) {
WRegKey *regIcon = new WRegKey(HKEY_CLASSES_ROOT, "cdafile\\DefaultIcon");
sprintf(path,"%s,1",text);
regIcon->SetStringValue("",path);
delete regIcon;
sprintf(path,"%s %1", text);

}
else {
MessageBox(Handle, "Set data for default player !","Error",MB_ICONSTOP|MB_APPLMODAL);

}

}
}


reg->SetStringValue("",path);
reg2->SetStringValue("",path);

delete reg2;
delete reg;

// set default action
reg = new WRegKey(HKEY_CLASSES_ROOT, "Audio CD\\shell");
reg->SetStringValue("Creative CD.exe","play");
delete reg;

// set default action
WRegKey *reg4 = new WRegKey(HKEY_CLASSES_ROOT, "cdafile\\shell");
reg4->SetStringValue("Creative CD.exe","play");
delete reg4;
SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL );





MessageBox(Handle, "Michael Hardy Said, It Is Now Set As Your Default CD Player","Now Set...",MB_OK | MB_ICONINFORMATION);




}

}
break;


default:
return FALSE;

}

return TRUE;


}

Thank you in advance
Hi

No idea of coding media-players :-(
Last edited on
You might have better luck on a forum dedicated to Win32 coding. We're more straight C++ here.
Topic archived. No new replies allowed.