//控制面板接口函数CPlApplet
extern "C" int APIENTRY CPlApplet(HWND hwndCPL, UINT uMsg, LPARAM lParam1, LPARAM lParam2);
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("CPL.DLL Initializing!");
// Extension DLL one-time initialization
if (!AfxInitExtensionModule(CPLDLL, hInstance))
return 0;
// Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result.
new CDynLinkLibrary(CPLDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("CPL.DLL Terminating!");
// Terminate the library before destructors are called
AfxTermExtensionModule(CPLDLL);
}
hinst = hInstance;
return 1; // ok
}
int APIENTRY CPlApplet(HWND hwndCPL, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
{
int i;
LPCPLINFO lpCPlInfo;
i = (int) lParam1;
switch (uMsg) {
case CPL_IN99v: // first message, sent once
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 =IDI_ICON1;
lpCPlInfo->idName = IDS_STRING1;
lpCPlInfo->idInfo = IDS_STRING1;
break;
case CPL_DBLCLK: // application icon double-clicked
FARPROC lpProcDlg;
lpProcDlg = (FARPROC)MakeProcInstance(CPLDlg,hinst);
DialogBox(hinst,MAKEINTRESOURCE(IDD_DIALOG1),hwndCPL,(DLGPROC)lpProcDlg);
FreeProcInstance(lpProcDlg);
break;
case CPL_STOP: // sent once per application before CPL_EX99v
break;
case CPL_EX99v: // sent once before FreeLibrary is called
break;
default:
break;
}
return 0;
}
BOOL FAR PASCAL CPLDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
DWORD dataType;
BYTE data[100];
DWORD reserved;
DWORD size;
HKEY hKey = HKEY_CURRENT_USER;
char ValueName[]="Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutoRun";
switch(message)
{
case WM_IN99vDIALOG:
size = 4;
if(RegQueryValueEx(HKEY_CURRENT_USER,ValueName,&reserved,&dataType,data,&size)
(编辑:aniston)
|