ReactOS 0.4.15-dev-7953-g1f49173
cmicpl.cpp
Go to the documentation of this file.
1/*
2Copyright (c) 2006-2008 dogbert <dogber1@gmail.com>
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions
7are met:
81. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
102. Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
133. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#define WIN32_LEAN_AND_MEAN
29#include <windows.h>
30#include <shellapi.h>
31#include <tchar.h>
32#include <cpl.h>
33#include "resource.h"
34
36{
37 return TRUE;
38}
39
41{
42 TCHAR szSysDir[1024];
43 if (!GetSystemDirectory(szSysDir, sizeof(szSysDir) / sizeof(TCHAR))) {
44 return FALSE;
45 }
46 _tcscat(szSysDir, _T("\\cmicontrol.exe")); //unsafe
47 ShellExecute(NULL, _T("open"), szSysDir, NULL, NULL, SW_SHOWNORMAL);
48 return TRUE;
49}
50
51LONG APIENTRY CPlApplet (HWND hWnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
52{
53 switch (uMsg)
54 {
55 case CPL_INIT:
56 return TRUE;
57
58 case CPL_GETCOUNT:
59 return 1;
60
61 case CPL_INQUIRE:
62 {
63 LPCPLINFO pCplInfo = (LPCPLINFO)lParam2;
64
65 if (!pCplInfo) {
66 return TRUE;
67 }
68
69 if ((UINT)lParam1 == 0) {
70 pCplInfo->idIcon = IDI_CPLICON;
71 pCplInfo->idName = IDS_CPLNAME;
72 pCplInfo->idInfo = IDS_CPLINFO;
73 }
74 break;
75 }
76
77 case CPL_NEWINQUIRE:
78 break;
79
80 case CPL_DBLCLK:
81 case CPL_STARTWPARMS:
82 if ((UINT)lParam1 == 0) {
83 if (!execControlPanel()) {
84 return TRUE;
85 }
86 }
87 break;
88 case CPL_EXIT:
89 break;
90
91 default:
92 break;
93 }
94
95 return 0;
96}
97
HWND hWnd
Definition: settings.c:17
BOOL APIENTRY DllMain(HANDLE hModule, ULONG gna, LPVOID lpReserved)
Definition: cmicpl.cpp:35
BOOL execControlPanel()
Definition: cmicpl.cpp:40
#define CPL_INQUIRE
Definition: cpl.h:14
#define CPL_DBLCLK
Definition: cpl.h:16
#define CPL_STARTWPARMS
Definition: cpl.h:54
#define CPL_INIT
Definition: cpl.h:12
#define CPL_EXIT
Definition: cpl.h:18
#define CPL_GETCOUNT
Definition: cpl.h:13
struct tagCPLINFO * LPCPLINFO
#define CPL_NEWINQUIRE
Definition: cpl.h:19
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDS_CPLNAME
Definition: resource.h:8
#define IDI_CPLICON
Definition: resource.h:4
#define APIENTRY
Definition: api.h:79
HMODULE hModule
Definition: animate.c:44
#define IDS_CPLINFO
Definition: resource.h:30
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _tcscat
Definition: tchar.h:622
unsigned int UINT
Definition: ndis.h:50
long LONG
Definition: pedump.c:60
#define ShellExecute
Definition: shellapi.h:693
Definition: cpl.h:24
int idName
Definition: cpl.h:26
int idInfo
Definition: cpl.h:27
int idIcon
Definition: cpl.h:25
uint32_t ULONG
Definition: typedefs.h:59
#define _T(x)
Definition: vfdio.h:22
#define GetSystemDirectory
Definition: winbase.h:3842
LONG_PTR LPARAM
Definition: windef.h:208
#define SW_SHOWNORMAL
Definition: winuser.h:770
char TCHAR
Definition: xmlstorage.h:189