ReactOS  0.4.13-dev-257-gfabbd7c
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 56 of file control.c.

57 {
58 #ifdef __REACTOS__
59  ACTCTXW ActCtx = {sizeof(ACTCTX), ACTCTX_FLAG_RESOURCE_NAME_VALID};
60  ULONG_PTR cookie;
61  BOOL bActivated;
62  WCHAR fileBuffer[MAX_PATH];
63 #endif
64  CPlApplet* applet;
65  DWORD len;
66  unsigned i;
67  CPLINFO info;
68  NEWCPLINFOW newinfo;
69 
70  if (!(applet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet))))
71  return applet;
72 
74  if (len > 0)
75  {
76  if (!(applet->cmd = HeapAlloc(GetProcessHeap(), 0, (len+1) * sizeof(WCHAR))))
77  {
78  WARN("Cannot allocate memory for applet path\n");
79  goto theError;
80  }
81  ExpandEnvironmentStringsW(cmd, applet->cmd, len+1);
82  }
83  else
84  {
85  WARN("Cannot expand applet path\n");
86  goto theError;
87  }
88 
89  applet->hWnd = hWnd;
90 
91 #ifdef __REACTOS__
92  StringCchCopy(fileBuffer, MAX_PATH, applet->cmd);
93  if (PathIsFileSpecW(fileBuffer))
94  SearchPath(NULL, fileBuffer, NULL, MAX_PATH, fileBuffer, NULL);
95  ActCtx.lpSource = fileBuffer;
96  ActCtx.lpResourceName = (LPCWSTR)123;
97  applet->hActCtx = CreateActCtx(&ActCtx);
98  bActivated = (applet->hActCtx != INVALID_HANDLE_VALUE ? ActivateActCtx(applet->hActCtx, &cookie) : FALSE);
99 #endif
100 
101  if (!(applet->hModule = LoadLibraryW(applet->cmd))) {
102  WARN("Cannot load control panel applet %s\n", debugstr_w(applet->cmd));
103  goto theError;
104  }
105  if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet"))) {
106  WARN("Not a valid control panel applet %s\n", debugstr_w(applet->cmd));
107  goto theError;
108  }
109  if (!applet->proc(hWnd, CPL_INIT, 0L, 0L)) {
110  WARN("Init of applet has failed\n");
111  goto theError;
112  }
113  if ((applet->count = applet->proc(hWnd, CPL_GETCOUNT, 0L, 0L)) == 0) {
114  WARN("No subprogram in applet\n");
115  applet->proc(applet->hWnd, CPL_EXIT, 0, 0);
116  goto theError;
117  }
118 
119  applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet,
120  FIELD_OFFSET( CPlApplet, info[applet->count] ));
121 
122  for (i = 0; i < applet->count; i++) {
123  ZeroMemory(&newinfo, sizeof(newinfo));
124  newinfo.dwSize = sizeof(NEWCPLINFOA);
125  applet->info[i].helpfile[0] = 0;
126  /* proc is supposed to return a null value upon success for
127  * CPL_INQUIRE and CPL_NEWINQUIRE
128  * However, real drivers don't seem to behave like this
129  * So, use introspection rather than return value
130  */
131  applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info);
132  applet->info[i].data = info.lData;
133 #ifdef __REACTOS__
134  applet->info[i].idIcon = info.idIcon;
135 #endif
136 
137  if (info.idIcon != CPL_DYNAMIC_RES)
138  applet->info[i].icon = LoadIconW(applet->hModule, MAKEINTRESOURCEW(info.idIcon));
139  if (info.idName != CPL_DYNAMIC_RES)
140  LoadStringW(applet->hModule, info.idName,
141  applet->info[i].name, sizeof(applet->info[i].name) / sizeof(WCHAR));
142  if (info.idInfo != CPL_DYNAMIC_RES)
143  LoadStringW(applet->hModule, info.idInfo,
144  applet->info[i].info, sizeof(applet->info[i].info) / sizeof(WCHAR));
145 
146  /* some broken control panels seem to return incorrect values in CPL_INQUIRE,
147  but proper data in CPL_NEWINQUIRE. if we get an empty string or a null
148  icon, see what we can get from CPL_NEWINQUIRE */
149 
150  if (!applet->info[i].name[0]) info.idName = CPL_DYNAMIC_RES;
151 
152  /* zero-length szInfo may not be a buggy applet, but it doesn't hurt for us
153  to check anyway */
154 
155  if (!applet->info[i].info[0]) info.idInfo = CPL_DYNAMIC_RES;
156 
157  if (applet->info[i].icon == NULL)
158  info.idIcon = CPL_DYNAMIC_RES;
159 
160  if ((info.idIcon == CPL_DYNAMIC_RES) || (info.idName == CPL_DYNAMIC_RES) ||
161  (info.idInfo == CPL_DYNAMIC_RES)) {
162  applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo);
163 
164  applet->info[i].data = newinfo.lData;
165  if (info.idIcon == CPL_DYNAMIC_RES) {
166  if (!newinfo.hIcon) WARN("couldn't get icon for applet %u\n", i);
167  applet->info[i].icon = newinfo.hIcon;
168  }
169  if (newinfo.dwSize == sizeof(NEWCPLINFOW)) {
170  if (info.idName == CPL_DYNAMIC_RES)
171  memcpy(applet->info[i].name, newinfo.szName, sizeof(newinfo.szName));
172  if (info.idInfo == CPL_DYNAMIC_RES)
173  memcpy(applet->info[i].info, newinfo.szInfo, sizeof(newinfo.szInfo));
174  memcpy(applet->info[i].helpfile, newinfo.szHelpFile, sizeof(newinfo.szHelpFile));
175  } else {
176  if (info.idName == CPL_DYNAMIC_RES)
178  sizeof(((LPNEWCPLINFOA)&newinfo)->szName) / sizeof(CHAR),
179  applet->info[i].name, sizeof(applet->info[i].name) / sizeof(WCHAR));
180  if (info.idInfo == CPL_DYNAMIC_RES)
181  MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szInfo,
182  sizeof(((LPNEWCPLINFOA)&newinfo)->szInfo) / sizeof(CHAR),
183  applet->info[i].info, sizeof(applet->info[i].info) / sizeof(WCHAR));
185  sizeof(((LPNEWCPLINFOA)&newinfo)->szHelpFile) / sizeof(CHAR),
186  applet->info[i].helpfile,
187  sizeof(applet->info[i].helpfile) / sizeof(WCHAR));
188  }
189  }
190  }
191 
192 #ifdef __REACTOS__
193  if (bActivated)
194  DeactivateActCtx(0, cookie);
195 #endif
196 
197 #ifndef __REACTOS__
198  list_add_head( &panel->applets, &applet->entry );
199 #endif
200 
201  return applet;
202 
203  theError:
204  FreeLibrary(applet->hModule);
205  HeapFree(GetProcessHeap(), 0, applet->cmd);
206  HeapFree(GetProcessHeap(), 0, applet);
207  return NULL;
208 }
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
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:99
char CHAR
Definition: xmlstorage.h:175
LONG(APIENTRY * APPLET_PROC)(HWND, UINT, LPARAM, LPARAM)
Definition: cpl.h:23
#define WARN(fmt,...)
Definition: debug.h:111
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:391
#define ZeroMemory
Definition: winbase.h:1635
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:3714
struct _test_info info[]
Definition: SetCursorPos.c:19
uint32_t ULONG_PTR
Definition: typedefs.h:63
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
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
APPLET_PROC proc
Definition: cpanel.h:51
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CPL_DYNAMIC_RES
Definition: cpl.h:11
#define debugstr_w
Definition: kernel32.h:32
#define CPL_NEWINQUIRE
Definition: cpl.h:19
BOOL WINAPI PathIsFileSpecW(LPCWSTR lpszPath)
Definition: path.c:2112
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define FreeLibrary(x)
Definition: compat.h:405
#define GetProcessHeap()
Definition: compat.h:395
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:26
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:246
#define CPL_INIT
Definition: cpl.h:12
TCHAR szHelpFile[]
Definition: scrnsave.c:30
#define CPL_INQUIRE
Definition: cpl.h:14
static const WCHAR L[]
Definition: oid.c:1250
#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
#define HeapReAlloc
Definition: compat.h:393
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
HMODULE hModule
Definition: cpanel.h:50
static const WCHAR szName[]
Definition: msipriv.h:1194
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define GetProcAddress(x, y)
Definition: compat.h:410
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define HeapFree(x, y, z)
Definition: compat.h:394
#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 40 of file control.c.

41 {
42  unsigned i;
43 
44  for (i = 0; i < applet->count; i++)
45  applet->proc(applet->hWnd, CPL_STOP, i, applet->info[i].data);
46 
47  if (applet->proc) applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L);
48  FreeLibrary(applet->hModule);
49 #ifndef __REACTOS__
50  list_remove( &applet->entry );
51 #endif
52  HeapFree(GetProcessHeap(), 0, applet->cmd);
53  HeapFree(GetProcessHeap(), 0, applet);
54 }
struct applet_info info[1]
Definition: cpanel.h:52
#define CPL_STOP
Definition: cpl.h:17
struct list entry
Definition: cpanel.h:43
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
APPLET_PROC proc
Definition: cpanel.h:51
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define FreeLibrary(x)
Definition: compat.h:405
#define GetProcessHeap()
Definition: compat.h:395
#define CPL_EXIT
Definition: cpl.h:18
LPWSTR cmd
Definition: cpanel.h:48
unsigned count
Definition: cpanel.h:49
static const WCHAR L[]
Definition: oid.c:1250
HWND hWnd
Definition: cpanel.h:47
HMODULE hModule
Definition: cpanel.h:50
#define HeapFree(x, y, z)
Definition: compat.h:394

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