你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:技术专栏 / Linux开发
如何编写控制面板程序(2)
 

//控制面板接口函数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)

  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089