How to create contol panel application?
I created a dll and exported "CPlApplet" function. Then I renamed the dll as .cpl, copyed it into \\winnt\\system32.
But when I opened control panel,it crashed. Does anything else need to do?
The following is the code:
LONG CALLBACK CPlApplet(HWND hwndCPL, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
int i;
LPCPLINFO lpCPlInfo;
i = (int) lParam1;
switch (uMsg) {
case CPL_INIT: // first message, sent once
// hinst = GetModuleHandle("ecp.cpl");
return TRUE;
case CPL_GETCOUNT: // second message, sent once
return 1;
break;
case CPL_INQUIRE: // third message, sent once per application
/* lpCPlInfo = (LPCPLINFO) lParam2;
lpCPlInfo->lData = 0;
lpCPlInfo->idIcon = StereoApplets[i].icon;
lpCPlInfo->idName = StereoApplets[i].namestring;
lpCPlInfo->idInfo = StereoApplets[i].descstring;*/
break;
case CPL_DBLCLK: // application icon double-clicked
{
CDlg dlg;
dlg.DoModal();
}
// DialogBox(hinst,
// MAKEINTRESOURCE(StereoApplets[i].dlgtemplate),
// hwndCPL, StereoApplets[i].dlgfn);
break;
case CPL_STOP: // sent once per application before CPL_EXIT
break;
case CPL_EXIT: // sent once before FreeLibrary is called
break;
default:
break;
}
return 0;
}