ReactOS  0.4.15-dev-4574-g434cf85
cpanel.h File Reference
#include <cpl.h>
Include dependency graph for cpanel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  applet_info
 
struct  CPlApplet
 
struct  CPanel
 
struct  CPlItem
 

Typedefs

typedef struct CPlApplet CPlApplet
 
typedef struct CPanel CPanel
 
typedef struct CPlItem CPlItem
 

Functions

CPlAppletControl_LoadApplet (HWND hWnd, LPCWSTR cmd, CPanel *panel) DECLSPEC_HIDDEN
 
void Control_UnloadApplet (CPlApplet *applet) DECLSPEC_HIDDEN
 

Typedef Documentation

◆ CPanel

typedef struct CPanel CPanel

◆ CPlApplet

◆ CPlItem

Function Documentation

◆ Control_LoadApplet()

CPlApplet* Control_LoadApplet ( HWND  hWnd,
LPCWSTR  cmd,
CPanel panel 
)

Definition at line 59 of file control.c.

60 {
61 #ifdef __REACTOS__
62  ACTCTXW ActCtx = {sizeof(ACTCTX), ACTCTX_FLAG_RESOURCE_NAME_VALID};
64  BOOL bActivated;
65  WCHAR fileBuffer[MAX_PATH];
66 #endif
67  CPlApplet* applet;
68  DWORD len;
69  unsigned i;
70  CPLINFO info;
71  NEWCPLINFOW newinfo;
72 
73  if (!(applet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet))))
74  return applet;
75 
77  if (len > 0)
78  {
79  if (!(applet->cmd = HeapAlloc(GetProcessHeap(), 0, (len+1) * sizeof(WCHAR))))
80  {
81  WARN("Cannot allocate memory for applet path\n");
82  goto theError;
83  }
84  ExpandEnvironmentStringsW(cmd, applet->cmd, len+1);
85  }
86  else
87  {
88  WARN("Cannot expand applet path\n");
89  goto theError;
90  }
91 
92  applet->hWnd = hWnd;
93 
94 #ifdef __REACTOS__
95  StringCchCopy(fileBuffer, MAX_PATH, applet->cmd);
96  if (PathIsFileSpecW(fileBuffer))
97  SearchPath(NULL, fileBuffer, NULL, MAX_PATH, fileBuffer, NULL);
98  ActCtx.lpSource = fileBuffer;
99  ActCtx.lpResourceName = (LPCWSTR)123;
100  applet->hActCtx = CreateActCtx(&ActCtx);
101  bActivated = (applet->hActCtx != INVALID_HANDLE_VALUE ? ActivateActCtx(applet->hActCtx, &cookie) : FALSE);
102 #endif
103 
104  if (!(applet->hModule = LoadLibraryW(applet->cmd))) {
105  WARN("Cannot load control panel applet %s\n", debugstr_w(applet->cmd));
106  goto theError;
107  }
108  if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet"))) {
109  WARN("Not a valid control panel applet %s\n", debugstr_w(applet->cmd));
110  goto theError;
111  }
112  if (!applet->proc(hWnd, CPL_INIT, 0L, 0L)) {
113  WARN("Init of applet has failed\n");
114  goto theError;
115  }
116  if ((applet->count = applet->proc(hWnd, CPL_GETCOUNT, 0L, 0L)) == 0) {
117  WARN("No subprogram in applet\n");
118  applet->proc(applet->hWnd, CPL_EXIT, 0, 0);
119  goto theError;
120  }
121 
122  applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet,
123  FIELD_OFFSET( CPlApplet, info[applet->count] ));
124 
125  for (i = 0; i < applet->count; i++) {
126  ZeroMemory(&newinfo, sizeof(newinfo));
127  newinfo.dwSize = sizeof(NEWCPLINFOA);
128  applet->info[i].helpfile[0] = 0;
129  /* proc is supposed to return a null value upon success for
130  * CPL_INQUIRE and CPL_NEWINQUIRE
131  * However, real drivers don't seem to behave like this
132  * So, use introspection rather than return value
133  */
134  applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info);
135  applet->info[i].data = info.lData;
136 #ifdef __REACTOS__
137  applet->info[i].idIcon = info.idIcon;
138 #endif
139 
140  if (info.idIcon != CPL_DYNAMIC_RES)
141  applet->info[i].icon = LoadIconW(applet->hModule, MAKEINTRESOURCEW(info.idIcon));
142  if (info.idName != CPL_DYNAMIC_RES)
143  LoadStringW(applet->hModule, info.idName,
144  applet->info[i].name, sizeof(applet->info[i].name) / sizeof(WCHAR));
145  if (info.idInfo != CPL_DYNAMIC_RES)
146  LoadStringW(applet->hModule, info.idInfo,
147  applet->info[i].info, sizeof(applet->info[i].info) / sizeof(WCHAR));
148 
149  /* some broken control panels seem to return incorrect values in CPL_INQUIRE,
150  but proper data in CPL_NEWINQUIRE. if we get an empty string or a null
151  icon, see what we can get from CPL_NEWINQUIRE */
152 
153  if (!applet->info[i].name[0]) info.idName = CPL_DYNAMIC_RES;
154 
155  /* zero-length szInfo may not be a buggy applet, but it doesn't hurt for us
156  to check anyway */
157 
158  if (!applet->info[i].info[0]) info.idInfo = CPL_DYNAMIC_RES;
159 
160  if (applet->info[i].icon == NULL)
161  info.idIcon = CPL_DYNAMIC_RES;
162 
163  if ((info.idIcon == CPL_DYNAMIC_RES) || (info.idName == CPL_DYNAMIC_RES) ||
164  (info.idInfo == CPL_DYNAMIC_RES)) {
165  applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo);
166 
167  applet->info[i].data = newinfo.lData;
168  if (info.idIcon == CPL_DYNAMIC_RES) {
169  if (!newinfo.hIcon) WARN("couldn't get icon for applet %u\n", i);
170  applet->info[i].icon = newinfo.hIcon;
171  }
172  if (newinfo.dwSize == sizeof(NEWCPLINFOW)) {
173  if (info.idName == CPL_DYNAMIC_RES)
174  memcpy(applet->info[i].name, newinfo.szName, sizeof(newinfo.szName));
175  if (info.idInfo == CPL_DYNAMIC_RES)
176  memcpy(applet->info[i].info, newinfo.szInfo, sizeof(newinfo.szInfo));
177  memcpy(applet->info[i].helpfile, newinfo.szHelpFile, sizeof(newinfo.szHelpFile));
178  } else {
179  if (info.idName == CPL_DYNAMIC_RES)
181  sizeof(((LPNEWCPLINFOA)&newinfo)->szName) / sizeof(CHAR),
182  applet->info[i].name, sizeof(applet->info[i].name) / sizeof(WCHAR));
183  if (info.idInfo == CPL_DYNAMIC_RES)
184  MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szInfo,
185  sizeof(((LPNEWCPLINFOA)&newinfo)->szInfo) / sizeof(CHAR),
186  applet->info[i].info, sizeof(applet->info[i].info) / sizeof(WCHAR));
188  sizeof(((LPNEWCPLINFOA)&newinfo)->szHelpFile) / sizeof(CHAR),
189  applet->info[i].helpfile,
190  sizeof(applet->info[i].helpfile) / sizeof(WCHAR));
191  }
192  }
193  }
194 
195 #ifdef __REACTOS__
196  if (bActivated)
198 #endif
199 
200 #ifndef __REACTOS__
201  list_add_head( &panel->applets, &applet->entry );
202 #endif
203 
204  return applet;
205 
206  theError:
207  FreeLibrary(applet->hModule);
208  HeapFree(GetProcessHeap(), 0, applet->cmd);
209  HeapFree(GetProcessHeap(), 0, applet);
210  return NULL;
211 }
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
static const WCHAR szName[]
Definition: powrprof.c:45
struct applet_info info[1]
Definition: cpanel.h:52
Definition: cpl.h:24
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
Definition: ftp_var.h:139
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
LONG(APIENTRY * APPLET_PROC)(HWND, UINT, LPARAM, LPARAM)
Definition: cpl.h:23
#define WARN(fmt,...)
Definition: debug.h:112
struct list entry
Definition: cpanel.h:43
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
HWND hWnd
Definition: settings.c:17
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define ZeroMemory
Definition: winbase.h:1667
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define SearchPath
Definition: winbase.h:3761
uint32_t ULONG_PTR
Definition: typedefs.h:65
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
APPLET_PROC proc
Definition: cpanel.h:51
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CPL_DYNAMIC_RES
Definition: cpl.h:11
static struct _test_info info[]
Definition: SetCursorPos.c:19
#define debugstr_w
Definition: kernel32.h:32
#define CPL_NEWINQUIRE
Definition: cpl.h:19
BOOL WINAPI PathIsFileSpecW(LPCWSTR lpszPath)
Definition: path.c:2132
#define LoadLibraryW(x)
Definition: compat.h:606
LONG_PTR LPARAM
Definition: windef.h:208
#define FreeLibrary(x)
Definition: compat.h:607
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CPL_EXIT
Definition: cpl.h:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR cmd
Definition: cpanel.h:48
#define MAX_PATH
Definition: compat.h:34
unsigned count
Definition: cpanel.h:49
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwSize
Definition: cpl.h:41
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:247
#define CPL_INIT
Definition: cpl.h:12
TCHAR szHelpFile[]
Definition: scrnsave.c:30
#define CPL_INQUIRE
Definition: cpl.h:14
#define StringCchCopy
Definition: strsafe.h:139
struct tagNEWCPLINFOA NEWCPLINFOA
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
struct list applets
Definition: cpanel.h:57
HWND hWnd
Definition: cpanel.h:47
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define HeapReAlloc
Definition: compat.h:593
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
Definition: cookie.c:33
#define NULL
Definition: types.h:112
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define MultiByteToWideChar
Definition: compat.h:110
HMODULE hModule
Definition: cpanel.h:50
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define GetProcAddress(x, y)
Definition: compat.h:612
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define HeapFree(x, y, z)
Definition: compat.h:594
#define CPL_GETCOUNT
Definition: cpl.h:13

Referenced by Control_DoLaunch(), Control_DoWindow(), Control_RegisterRegistryApplets(), and CControlPanelEnum::RegisterCPanelApp().

◆ Control_UnloadApplet()

void Control_UnloadApplet ( CPlApplet applet)

Definition at line 43 of file control.c.

44 {
45  unsigned i;
46 
47  for (i = 0; i < applet->count; i++)
48  applet->proc(applet->hWnd, CPL_STOP, i, applet->info[i].data);
49 
50  if (applet->proc) applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L);
51  FreeLibrary(applet->hModule);
52 #ifndef __REACTOS__
53  list_remove( &applet->entry );
54 #endif
55  HeapFree(GetProcessHeap(), 0, applet->cmd);
56  HeapFree(GetProcessHeap(), 0, applet);
57 }
struct applet_info info[1]
Definition: cpanel.h:52
#define CPL_STOP
Definition: cpl.h:17
struct list entry
Definition: cpanel.h:43
APPLET_PROC proc
Definition: cpanel.h:51
#define L(x)
Definition: ntvdm.h:50
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define FreeLibrary(x)
Definition: compat.h:607
#define GetProcessHeap()
Definition: compat.h:595
#define CPL_EXIT
Definition: cpl.h:18
LPWSTR cmd
Definition: cpanel.h:48
unsigned count
Definition: cpanel.h:49
HWND hWnd
Definition: cpanel.h:47
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HMODULE hModule
Definition: cpanel.h:50
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by Control_DoLaunch(), Control_WndProc(), and CControlPanelEnum::RegisterCPanelApp().