ReactOS  0.4.15-dev-499-g1f31905
cmicpl.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2006-2008 dogbert <dogber1@gmail.com>
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8 1. Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10 2. 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.
13 3. 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 
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS 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 
51 LONG 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 
#define TRUE
Definition: types.h:120
Definition: cpl.h:24
struct tagCPLINFO * LPCPLINFO
HWND hWnd
Definition: settings.c:17
int idInfo
Definition: cpl.h:27
BOOL execControlPanel()
Definition: cmicpl.cpp:40
int idIcon
Definition: cpl.h:25
#define CPL_DBLCLK
Definition: cpl.h:16
#define IDS_CPLINFO
Definition: resource.h:30
#define IDS_CPLNAME
Definition: resource.h:8
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define ShellExecute
Definition: shellapi.h:689
#define CPL_NEWINQUIRE
Definition: cpl.h:19
#define CPL_STARTWPARMS
Definition: cpl.h:54
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define CPL_EXIT
Definition: cpl.h:18
#define IDI_CPLICON
Definition: resource.h:4
#define CPL_INIT
Definition: cpl.h:12
BOOL APIENTRY DllMain(HANDLE hModule, ULONG gna, LPVOID lpReserved)
Definition: cmicpl.cpp:35
#define CPL_INQUIRE
Definition: cpl.h:14
int idName
Definition: cpl.h:26
#define GetSystemDirectory
Definition: winbase.h:3682
#define SW_SHOWNORMAL
Definition: winuser.h:764
unsigned int UINT
Definition: ndis.h:50
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
unsigned int ULONG
Definition: retypes.h:1
LONG APIENTRY CPlApplet(HWND hWnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: cmicpl.cpp:51
#define CPL_GETCOUNT
Definition: cpl.h:13
#define APIENTRY
Definition: api.h:79
HMODULE hModule
Definition: animate.c:44