ReactOS  0.4.15-dev-1070-ge1a01de
umandlg.h File Reference
#include <stdlib.h>
#include <windows.h>
#include <commctrl.h>
#include <tlhelp32.h>
#include <windowsx.h>
#include <debug.h>
#include <wchar.h>
#include <strsafe.h>
#include "resource.h"
Include dependency graph for umandlg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  UTILMAN_GLOBALS
 
struct  _UTILMAN_STATE
 
struct  _REGISTRY_SETTINGS
 
struct  _REGISTRY_DATA
 

Macros

#define MAX_BUFFER   256
 

Typedefs

typedef struct _UTILMAN_STATE UTILMAN_STATE
 
typedef struct _UTILMAN_STATEPUTILMAN_STATE
 
typedef struct _REGISTRY_SETTINGS REGISTRY_SETTINGS
 
typedef struct _REGISTRY_SETTINGSPREGISTRY_SETTINGS
 
typedef struct _REGISTRY_DATA REGISTRY_DATA
 
typedef struct _REGISTRY_DATAPREGISTRY_DATA
 
typedef enum _WRITE_REGISTRY WRITE_REGISTRY
 
typedef enum _WRITE_REGISTRYPWRITE_REGISTRY
 

Enumerations

enum  _WRITE_REGISTRY { REGISTRY_ACCESSIBILITY, REGISTRY_UTILMAN }
 

Functions

VOID InitUtilsList (IN BOOL bInitGui)
 
BOOL DlgInitHandler (IN HWND hDlg)
 
VOID ShowAboutDlg (IN HWND hDlgParent)
 
VOID GroupBoxUpdateTitle (VOID)
 
VOID UpdateUtilityState (IN BOOL bUtilState)
 
INT_PTR APIENTRY DlgProc (IN HWND hDlg, IN UINT Msg, IN WPARAM wParam, IN LPARAM lParam)
 
INT ListBoxRefreshContents (VOID)
 
BOOL WINAPI UManStartDlg (VOID)
 
DWORD GetProcessID (IN LPCWSTR lpszProcessName)
 
BOOL IsProcessRunning (IN LPCWSTR lpszProcessName)
 
BOOL LaunchProcess (IN LPCWSTR lpszProcessName)
 
BOOL CloseProcess (IN LPCWSTR lpszProcessName)
 
BOOL InitAppRegKey (IN HKEY hPredefinedKey, IN LPCWSTR lpszSubKey, OUT PHKEY phKey, OUT LPDWORD lpdwDisposition)
 
BOOL QueryAppSettings (IN HKEY hKey, IN LPCWSTR lpszSubKey, IN LPCWSTR lpszRegValue, OUT PVOID ReturnedData, IN OUT LPDWORD lpdwSizeData)
 
BOOL SaveAppSettings (IN HKEY hKey, IN LPCWSTR lpszRegValue, IN DWORD dwRegType, IN PVOID Data, IN DWORD cbSize)
 

Variables

UTILMAN_GLOBALS Globals
 
REGISTRY_SETTINGS Settings
 
REGISTRY_DATA RegData
 

Macro Definition Documentation

◆ MAX_BUFFER

#define MAX_BUFFER   256

Definition at line 26 of file umandlg.h.

Typedef Documentation

◆ PREGISTRY_DATA

◆ PREGISTRY_SETTINGS

◆ PUTILMAN_STATE

◆ PWRITE_REGISTRY

◆ REGISTRY_DATA

◆ REGISTRY_SETTINGS

◆ UTILMAN_STATE

◆ WRITE_REGISTRY

Enumeration Type Documentation

◆ _WRITE_REGISTRY

Enumerator
REGISTRY_ACCESSIBILITY 
REGISTRY_UTILMAN 

Definition at line 84 of file umandlg.h.

85 {
enum _WRITE_REGISTRY WRITE_REGISTRY
enum _WRITE_REGISTRY * PWRITE_REGISTRY

Function Documentation

◆ CloseProcess()

BOOL CloseProcess ( IN LPCWSTR  lpszProcessName)

@CloseProcess

Closes a process.

Parameters
[in]lpszProcessNameThe name of the executable process.
Returns
Returns TRUE if the process has been terminated successfully, FALSE otherwise.

Definition at line 192 of file process.c.

193 {
195  DWORD dwProcessID;
196 
197  /* Get the process ID */
198  dwProcessID = GetProcessID(lpszProcessName);
199  if (dwProcessID == 0)
200  {
201  return FALSE;
202  }
203 
204  /* Make sure that the given process ID is not ours, the parent process, so that we do not kill ourselves */
205  if (dwProcessID == GetCurrentProcessId())
206  {
207  return FALSE;
208  }
209 
210  /* Open the process so that we can terminate it */
211  hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessID);
212  if (!hProcess)
213  {
214  DPRINT("CloseProcess(): Failed to open the process for termination! (Error: %lu)", GetLastError());
215  return FALSE;
216  }
217 
218  /* Terminate it */
221  return TRUE;
222 }
#define CloseHandle
Definition: compat.h:487
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
#define PROCESS_TERMINATE
Definition: pstypes.h:149
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
DWORD GetProcessID(IN LPCWSTR lpszProcessName)
Definition: process.c:26
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158

Referenced by DlgProc().

◆ DlgInitHandler()

BOOL DlgInitHandler ( IN HWND  hDlg)

@DlgInitHandler

Function which processes several operations for WM_INITDIALOG.

Parameters
[in]hDlgThe handle object of the dialog.
Returns
TRUE to inform the system that WM_INITDIALOG has been processed and that it should set the keyboard focus to the control.

Definition at line 97 of file umandlg.c.

98 {
99  INT PosX, PosY;
100  RECT rc;
101  WCHAR szAboutDlg[MAX_BUFFER];
102  WCHAR szAppPath[MAX_BUFFER];
103  HMENU hSysMenu;
104 
105  /* Save the dialog handle */
106  Globals.hMainDlg = hDlg;
107 
108  /* Center the dialog on the screen */
109  GetWindowRect(hDlg, &rc);
110  PosX = (GetSystemMetrics(SM_CXSCREEN) - rc.right) / 2;
111  PosY = (GetSystemMetrics(SM_CYSCREEN) - rc.bottom) / 2;
112  SetWindowPos(hDlg, 0, PosX, PosY, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
113 
114  /* Extract the icon resource from the executable process */
115  GetModuleFileNameW(NULL, szAppPath, _countof(szAppPath));
116  Globals.hIcon = ExtractIconW(Globals.hInstance, szAppPath, 0);
117 
118  /* Set the icon within the dialog's title bar */
119  if (Globals.hIcon)
120  {
121  SendMessageW(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hIcon);
122  }
123 
124  /* Retrieve the system menu and append the "About" menu item onto it */
125  hSysMenu = GetSystemMenu(hDlg, FALSE);
126  if (hSysMenu != NULL)
127  {
128  if (LoadStringW(Globals.hInstance, IDM_ABOUT, szAboutDlg, _countof(szAboutDlg)))
129  {
130  AppendMenuW(hSysMenu, MF_SEPARATOR, 0, NULL);
131  AppendMenuW(hSysMenu, MF_STRING, IDM_ABOUT, szAboutDlg);
132  }
133  }
134 
135  /* Get the dialog items, specifically the dialog list box, the Start and Stop buttons */
139 
140  /* Initialize the GUI listbox */
142 
143  /* Set the selection to the first item */
145 
146  /* Refresh the list */
148 
149  /* Create a timer, we'll use it to control the state of our items in the listbox */
150  Globals.iTimer = SetTimer(hDlg, 0, 400, NULL);
151 
152  return TRUE;
153 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
VOID InitUtilsList(IN BOOL bInitGui)
Definition: umandlg.c:38
#define IDM_ABOUT
Definition: resource.h:29
#define TRUE
Definition: types.h:120
#define MF_STRING
Definition: winuser.h:138
HINSTANCE hInstance
Definition: umandlg.h:32
#define IDC_LISTBOX
Definition: resource.h:13
#define SWP_NOZORDER
Definition: winuser.h:1232
LONG right
Definition: windef.h:308
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex)
Definition: shell32_main.c:881
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define ICON_SMALL
Definition: tnclass.cpp:48
#define IDC_START
Definition: resource.h:135
#define SM_CXSCREEN
Definition: winuser.h:949
#define FALSE
Definition: types.h:117
#define IDC_STOP
Definition: resource.h:69
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
#define MF_SEPARATOR
Definition: winuser.h:137
LONG_PTR LPARAM
Definition: windef.h:208
HICON hIcon
Definition: umandlg.h:33
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define SM_CYSCREEN
Definition: winuser.h:950
HWND hDlgCtlStart
Definition: umandlg.h:36
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_BUFFER
Definition: precomp.h:20
int WINAPI GetSystemMetrics(_In_ int)
UTILMAN_GLOBALS Globals
Definition: umandlg.c:15
HWND hDlgCtlStop
Definition: umandlg.h:37
#define SWP_NOSIZE
Definition: winuser.h:1230
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND hMainDlg
Definition: umandlg.h:39
HWND hListDlg
Definition: umandlg.h:38
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
INT iSelectedIndex
Definition: umandlg.h:35
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
INT ListBoxRefreshContents(VOID)
Definition: umandlg.c:226
UINT_PTR iTimer
Definition: umandlg.h:34

Referenced by DlgProc().

◆ DlgProc()

INT_PTR APIENTRY DlgProc ( IN HWND  hDlg,
IN UINT  Msg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)

@DlgProc

Main dialog application procedure function.

Parameters
[in]hDlgThe handle object of the dialog.
[in]MsgMessage events (in unsigned int).
[in]wParamMessage parameter (in UINT_PTR).
[in]lParamMessage paramater (in LONG_PTR).
Returns
Returns 0 to inform the system that the procedure has been handled.

Definition at line 292 of file umandlg.c.

297 {
298  switch (Msg)
299  {
300  case WM_INITDIALOG:
301  DlgInitHandler(hDlg);
302  return TRUE;
303 
304  case WM_CLOSE:
305  KillTimer(hDlg, Globals.iTimer);
307  EndDialog(hDlg, FALSE);
308  break;
309 
310  case WM_COMMAND:
311  {
312  switch (LOWORD(wParam))
313  {
314  case IDC_OK:
315  case IDC_CANCEL:
316  EndDialog(hDlg, FALSE);
317  break;
318 
319  case IDC_LISTBOX:
320  {
321  switch (HIWORD(wParam))
322  {
323  case LBN_SELCHANGE:
324  {
325  /* Retrieve the index of the current selected item */
326  INT iIndex = SendMessageW(Globals.hListDlg, LB_GETCURSEL, 0, 0);
327  if ((iIndex == LB_ERR) || (iIndex >= _countof(EntriesList)))
328  break;
329 
330  /* Assign the selected index and check the utility's state */
331  Globals.iSelectedIndex = iIndex;
333  break;
334  }
335  break;
336  }
337  break;
338  }
339 
340  case IDC_START:
342  break;
343 
344  case IDC_STOP:
346  break;
347 
348  default:
349  break;
350  }
351  break;
352  }
353 
354  case WM_TIMER:
356  return 0;
357 
358  case WM_SYSCOMMAND:
359  {
360  switch (LOWORD(wParam))
361  {
362  case IDM_ABOUT:
363  ShowAboutDlg(hDlg);
364  break;
365  }
366  break;
367  }
368  }
369 
370  return 0;
371 }
#define IDM_ABOUT
Definition: resource.h:29
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define TRUE
Definition: types.h:120
BOOL CloseProcess(IN LPCWSTR lpszProcessName)
Definition: process.c:192
struct @1607 Msg[]
#define IDC_LISTBOX
Definition: resource.h:13
#define LBN_SELCHANGE
Definition: winuser.h:2057
int32_t INT
Definition: typedefs.h:58
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define IDC_START
Definition: resource.h:135
#define FALSE
Definition: types.h:117
#define LB_ERR
Definition: winuser.h:2407
BOOL LaunchProcess(IN LPCWSTR lpszProcessName)
Definition: process.c:117
#define IDC_STOP
Definition: resource.h:69
HICON hIcon
Definition: umandlg.h:33
#define IDC_CANCEL
Definition: resource.h:60
#define _countof(array)
Definition: sndvol32.h:68
#define WM_TIMER
Definition: winuser.h:1724
#define WM_CLOSE
Definition: winuser.h:1603
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL bState
Definition: umandlg.h:50
UTILMAN_GLOBALS Globals
Definition: umandlg.c:15
LPCWSTR lpszProgram
Definition: umandlg.h:47
UTILMAN_STATE EntriesList[]
Definition: umandlg.c:19
#define WM_COMMAND
Definition: winuser.h:1722
VOID UpdateUtilityState(IN BOOL bUtilState)
Definition: umandlg.c:208
VOID ShowAboutDlg(IN HWND hDlgParent)
Definition: umandlg.c:167
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LB_GETCURSEL
Definition: winuser.h:2021
HWND hListDlg
Definition: umandlg.h:38
BOOL DlgInitHandler(IN HWND hDlg)
Definition: umandlg.c:97
#define HIWORD(l)
Definition: typedefs.h:247
INT iSelectedIndex
Definition: umandlg.h:35
#define WM_SYSCOMMAND
Definition: winuser.h:1723
#define IDC_OK
Definition: resource.h:59
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82
INT ListBoxRefreshContents(VOID)
Definition: umandlg.c:226
UINT_PTR iTimer
Definition: umandlg.h:34

Referenced by UManStartDlg().

◆ GetProcessID()

DWORD GetProcessID ( IN LPCWSTR  lpszProcessName)

@GetProcessID

Returns the process executable ID based on the given executable name.

Parameters
[in]lpszProcessNameThe name of the executable process.
Returns
Returns the ID number of the process, otherwise 0.

Definition at line 26 of file process.c.

27 {
29 
30  /* Create a snapshot and check if the given process name matches with the one from the process entry structure */
32 
33  if (hSnapshot == INVALID_HANDLE_VALUE)
34  return 0;
35 
36  /* Get the whole size of the structure */
37  Process.dwSize = sizeof(Process);
38 
39  /* Enumerate the processes */
40  if (Process32FirstW(hSnapshot, &Process))
41  {
42  do
43  {
44  if (_wcsicmp(Process.szExeFile, lpszProcessName) == 0)
45  {
46  /* The names match, return the process ID we're interested */
47  CloseHandle(hSnapshot);
48  return Process.th32ProcessID;
49  }
50  }
51  while (Process32NextW(hSnapshot, &Process));
52  }
53 
54  CloseHandle(hSnapshot);
55  return 0;
56 }
#define CloseHandle
Definition: compat.h:487
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
BOOL WINAPI Process32FirstW(HANDLE hSnapshot, LPPROCESSENTRY32W lppe)
Definition: toolhelp.c:984
BOOL WINAPI Process32NextW(HANDLE hSnapshot, LPPROCESSENTRY32W lppe)
Definition: toolhelp.c:1073
#define TH32CS_SNAPPROCESS
Definition: tlhelp32.h:26
HANDLE WINAPI CreateToolhelp32Snapshot(DWORD dwFlags, DWORD th32ProcessID)
Definition: toolhelp.c:1255
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by CloseProcess(), and IsProcessRunning().

◆ GroupBoxUpdateTitle()

VOID GroupBoxUpdateTitle ( VOID  )

@GroupBoxUpdateTitle

Updates the title of the groupbox.

Returns
Nothing.

Definition at line 187 of file umandlg.c.

188 {
189  WCHAR szFormat[MAX_BUFFER];
190 
191  /* Format the string with the utility's name and set it to the listbox's title */
194 }
WCHAR szResource[MAX_BUFFER]
Definition: umandlg.h:49
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_BUFFER
Definition: precomp.h:20
WCHAR szGrpBoxTitle[MAX_BUFFER]
Definition: umandlg.h:42
UTILMAN_GLOBALS Globals
Definition: umandlg.c:15
UTILMAN_STATE EntriesList[]
Definition: umandlg.c:19
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
HWND hMainDlg
Definition: umandlg.h:39
#define IDC_GROUPBOX
Definition: resource.h:24
INT iSelectedIndex
Definition: umandlg.h:35

Referenced by UpdateUtilityState().

◆ InitAppRegKey()

BOOL InitAppRegKey ( IN HKEY  hPredefinedKey,
IN LPCWSTR  lpszSubKey,
OUT PHKEY  phKey,
OUT LPDWORD  lpdwDisposition 
)

@InitAppRegKey

Initialize a key. The function may not necessarily create it but open the key if it already exists. The disposition pointed lpdwDisposition determines that. This is a function helper.

Parameters
[in]hPredefinedKeyThe predefined key (e.g. HKEY_CLASSES_ROOT).
[in]lpszSubKeyThe path to the sub key to be created.
[out]phKeyA pointer that receives a handle to the key given by the function.
[out]lpdwDispositionA pointer that receives the disposition given by the function.
Returns
Returns TRUE if the function successfully created a key (or opened it), FALSE otherwise for failure.

Definition at line 51 of file registry.c.

55 {
56  LONG lResult;
57 
58  lResult = RegCreateKeyExW(hPredefinedKey,
59  lpszSubKey,
60  0,
61  NULL,
62  0,
63  KEY_WRITE,
64  NULL,
65  phKey,
66  lpdwDisposition);
67  if (lResult != ERROR_SUCCESS)
68  {
69  DPRINT("InitAppRegKey(): Failed to create the following key (or open the key) of path \"%S\". The error code is \"%li\".\n", lpszSubKey, lResult);
70  return FALSE;
71  }
72 
73  return TRUE;
74 }
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCreateKeyExW(IN HKEY hKey, IN LPCWSTR lpSubKey, IN DWORD Reserved, IN LPWSTR lpClass OPTIONAL, IN DWORD dwOptions, IN REGSAM samDesired, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes OPTIONAL, OUT PHKEY phkResult, OUT LPDWORD lpdwDisposition OPTIONAL)
Definition: registry.c:533
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define KEY_WRITE
Definition: nt_native.h:1031

◆ InitUtilsList()

VOID InitUtilsList ( IN BOOL  bInitGui)

@InitUtilsList

Initializes the list of accessibility utilities.

Parameters
[in]bInitGuiWhether we are initializing the UI list (TRUE) or the internal array (FALSE).
Returns
Nothing.

Definition at line 38 of file umandlg.c.

39 {
40  UINT i;
41 
42  if (!bInitGui)
43  {
44  // TODO: Load the list dynamically from the registry key
45  // hklm\software\microsoft\windows nt\currentversion\accessibility
46 
47  /* Initialize the resource utility strings only once */
48  for (i = 0; i < _countof(EntriesList); ++i)
49  {
51  EntriesList[i].szResource, _countof(EntriesList[i].szResource));
52 
54  }
55  }
56  else
57  {
58  INT iItem;
59  BOOL bIsRunning;
60  WCHAR szFormat[MAX_BUFFER];
61 
62  /* Reset the listbox */
64 
65  /* Add the utilities in the listbox */
66  for (i = 0; i < _countof(EntriesList); ++i)
67  {
68  bIsRunning = IsProcessRunning(EntriesList[i].lpszProgram);
69  EntriesList[i].bState = bIsRunning;
70 
71  /* Load the string and append the utility's name to the format */
72  StringCchPrintfW(szFormat, _countof(szFormat),
73  (bIsRunning ? Globals.szRunning : Globals.szNotRunning),
75 
76  /* Add the item in the listbox */
77  iItem = (INT)SendMessageW(Globals.hListDlg, LB_ADDSTRING, 0, (LPARAM)szFormat);
78  if (iItem != LB_ERR)
80  }
81  }
82 }
UINT uNameId
Definition: umandlg.h:48
#define LB_ADDSTRING
Definition: winuser.h:2013
#define INT
Definition: polytest.cpp:20
HINSTANCE hInstance
Definition: umandlg.h:32
WCHAR szResource[MAX_BUFFER]
Definition: umandlg.h:49
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
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 LB_RESETCONTENT
Definition: winuser.h:2037
#define FALSE
Definition: types.h:117
#define LB_ERR
Definition: winuser.h:2407
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_BUFFER
Definition: precomp.h:20
#define LB_SETITEMDATA
Definition: winuser.h:2047
BOOL bState
Definition: umandlg.h:50
UTILMAN_GLOBALS Globals
Definition: umandlg.c:15
UTILMAN_STATE EntriesList[]
Definition: umandlg.c:19
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
unsigned int UINT
Definition: ndis.h:50
HWND hListDlg
Definition: umandlg.h:38
BOOL IsProcessRunning(IN LPCWSTR lpszProcessName)
Definition: process.c:71
WCHAR szNotRunning[MAX_BUFFER]
Definition: umandlg.h:41
WCHAR szRunning[MAX_BUFFER]
Definition: umandlg.h:40

Referenced by DlgInitHandler(), and UManStartDlg().

◆ IsProcessRunning()

BOOL IsProcessRunning ( IN LPCWSTR  lpszProcessName)

@IsProcessRunning

Checks if a process is running.

Parameters
[in]lpszProcessNameThe name of the executable process.
Returns
Returns TRUE if the given process' name is running, FALSE otherwise.

Definition at line 71 of file process.c.

72 {
73  DWORD dwReturn, dwProcessID;
75 
76  /* Get the process ID */
77  dwProcessID = GetProcessID(lpszProcessName);
78  if (dwProcessID == 0)
79  {
80  return FALSE;
81  }
82 
83  /* Synchronize the process to get its signaling state */
84  hProcess = OpenProcess(SYNCHRONIZE, FALSE, dwProcessID);
85  if (!hProcess)
86  {
87  DPRINT("IsProcessRunning(): Failed to open the process! (Error: %lu)", GetLastError());
88  return FALSE;
89  }
90 
91  /* Wait for the process */
92  dwReturn = WaitForSingleObject(hProcess, 0);
93  if (dwReturn == WAIT_TIMEOUT)
94  {
95  /* The process is still running */
97  return TRUE;
98  }
99 
101  return FALSE;
102 }
#define CloseHandle
Definition: compat.h:487
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define SYNCHRONIZE
Definition: nt_native.h:61
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
DWORD GetProcessID(IN LPCWSTR lpszProcessName)
Definition: process.c:26

Referenced by InitUtilsList(), and ListBoxRefreshContents().

◆ LaunchProcess()

BOOL LaunchProcess ( IN LPCWSTR  lpszProcessName)

@LaunchProcess

Executes a process.

Parameters
[in]lpProcessNameThe name of the executable process.
Returns
Returns TRUE if the process has been launched successfully, FALSE otherwise.

Definition at line 117 of file process.c.

118 {
119  STARTUPINFOW si;
121  HANDLE hUserToken, hProcessToken;
122  BOOL bSuccess;
123  WCHAR ExpandedCmdLine[MAX_PATH];
124 
125  /* Expand the process path string */
126  ExpandEnvironmentStringsW(lpszProcessName, ExpandedCmdLine, ARRAYSIZE(ExpandedCmdLine));
127 
128  ZeroMemory(&pi, sizeof(pi));
129  ZeroMemory(&si, sizeof(si));
130  si.cb = sizeof(si);
133 
134  /* Get the token of the parent (current) process of the application */
136  if (!bSuccess)
137  {
138  DPRINT("OpenProcessToken() failed with error -> %lu\n", GetLastError());
139  return FALSE;
140  }
141 
142  /* Duplicate a new token so that we can use it to create our process */
144  if (!bSuccess)
145  {
146  DPRINT("DuplicateTokenEx() failed with error -> %lu\n", GetLastError());
148  return FALSE;
149  }
150 
151  /* Finally create the process */
152  bSuccess = CreateProcessAsUserW(hProcessToken,
153  NULL,
154  ExpandedCmdLine,
155  NULL,
156  NULL,
157  FALSE,
158  0, // DETACHED_PROCESS, NORMAL_PRIORITY_CLASS
159  NULL,
160  NULL,
161  &si,
162  &pi);
163 
164  if (!bSuccess)
165  {
166  DPRINT("CreateProcessAsUserW() failed with error -> %lu\n", GetLastError());
168  CloseHandle(hProcessToken);
169  return FALSE;
170  }
171 
172  CloseHandle(pi.hProcess);
173  CloseHandle(pi.hThread);
175  CloseHandle(hProcessToken);
176  return TRUE;
177 }
#define CloseHandle
Definition: compat.h:487
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
static BOOLEAN bSuccess
Definition: drive.cpp:419
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
HANDLE hUserToken
Definition: install.c:39
DWORD cb
Definition: winbase.h:830
#define TOKEN_QUERY
Definition: setypes.h:874
__wchar_t WCHAR
Definition: xmlstorage.h:180
static refpint_t pi[]
Definition: server.c:96
#define MAX_PATH
Definition: compat.h:34
#define TOKEN_ALL_ACCESS
Definition: setypes.h:892
BOOL WINAPI DuplicateTokenEx(IN HANDLE ExistingTokenHandle, IN DWORD dwDesiredAccess, IN LPSECURITY_ATTRIBUTES lpTokenAttributes OPTIONAL, IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, IN TOKEN_TYPE TokenType, OUT PHANDLE DuplicateTokenHandle)
Definition: security.c:3394
#define TOKEN_DUPLICATE
Definition: setypes.h:872
WORD wShowWindow
Definition: winbase.h:842
#define GetCurrentProcess()
Definition: compat.h:507
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW(_In_opt_ HANDLE hToken, _In_opt_ LPCWSTR lpApplicationName, _Inout_opt_ LPWSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, _In_ BOOL bInheritHandles, _In_ DWORD dwCreationFlags, _In_opt_ LPVOID lpEnvironment, _In_opt_ LPCWSTR lpCurrentDirectory, _In_ LPSTARTUPINFOW lpStartupInfo, _Out_ LPPROCESS_INFORMATION lpProcessInformation)
Definition: logon.c:281
#define SW_SHOWNORMAL
Definition: winuser.h:764
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
DWORD dwFlags
Definition: winbase.h:841

Referenced by DlgProc().

◆ ListBoxRefreshContents()

INT ListBoxRefreshContents ( VOID  )

@ListBoxRefreshContents

Handle the tasks on a periodic cycle. This function handles WM_TIMER message.

Returns
Returns 0 to inform the system that WM_TIMER has been processed.

Definition at line 226 of file umandlg.c.

227 {
228  UINT i;
229  INT iItem;
230  BOOL bIsRunning;
231  WCHAR szFormat[MAX_BUFFER];
232 
233  /* Disable listbox redraw */
235 
236  for (i = 0; i < _countof(EntriesList); ++i)
237  {
238  /* Check the utility's state */
239  bIsRunning = IsProcessRunning(EntriesList[i].lpszProgram);
240  if (bIsRunning != EntriesList[i].bState)
241  {
242  /* The utility's state has changed, save it */
243  EntriesList[i].bState = bIsRunning;
244 
245  /* Update the corresponding item in the listbox */
246  StringCchPrintfW(szFormat, _countof(szFormat),
247  (bIsRunning ? Globals.szRunning : Globals.szNotRunning),
249 
251  iItem = SendMessageW(Globals.hListDlg, LB_INSERTSTRING, (LPARAM)i, (LPARAM)szFormat);
252  if (iItem != LB_ERR)
254  }
255  }
256 
257  /* Re-enable listbox redraw */
259 
260  /*
261  * Check the previously selected item. This will help us determine what
262  * item has been selected and set its focus selection back. Furthermore, check
263  * the state of each accessibility tool and enable/disable the buttons.
264  */
267 
268  return 0;
269 }
#define LB_SETCURSEL
Definition: winuser.h:2045
#define TRUE
Definition: types.h:120
#define WM_SETREDRAW
Definition: winuser.h:1598
WCHAR szResource[MAX_BUFFER]
Definition: umandlg.h:49
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:58
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 FALSE
Definition: types.h:117
#define LB_ERR
Definition: winuser.h:2407
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_BUFFER
Definition: precomp.h:20
#define LB_SETITEMDATA
Definition: winuser.h:2047
BOOL bState
Definition: umandlg.h:50
UTILMAN_GLOBALS Globals
Definition: umandlg.c:15
UTILMAN_STATE EntriesList[]
Definition: umandlg.c:19
VOID UpdateUtilityState(IN BOOL bUtilState)
Definition: umandlg.c:208
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
unsigned int UINT
Definition: ndis.h:50
HWND hListDlg
Definition: umandlg.h:38
BOOL IsProcessRunning(IN LPCWSTR lpszProcessName)
Definition: process.c:71
#define LB_DELETESTRING
Definition: winuser.h:2014
INT iSelectedIndex
Definition: umandlg.h:35
#define LB_INSERTSTRING
Definition: winuser.h:2035
WCHAR szNotRunning[MAX_BUFFER]
Definition: umandlg.h:41
WCHAR szRunning[MAX_BUFFER]
Definition: umandlg.h:40

Referenced by DlgInitHandler(), and DlgProc().

◆ QueryAppSettings()

BOOL QueryAppSettings ( IN HKEY  hKey,
IN LPCWSTR  lpszSubKey,
IN LPCWSTR  lpszRegValue,
OUT PVOID  ReturnedData,
IN OUT LPDWORD  lpdwSizeData 
)

@QueryAppSettings

Query the setting from the application's key. This is a function helper.

Parameters
[in]hKeyA handle to a key.
[in]lpszSubKeyThe path to a sub-key.
[in]lpszRegValueThe registry value where we need to get the data from.
[out]ReturnedDataAn arbitrary pointer that receives the returned data. Being arbitrary, the data can be of any type.
[in,out]lpdwSizeDataA pointer to the returned data pointed by ReturnedData parameter that retrieves the size of the aforementioned data, in bytes.
Returns
Returns TRUE if the function successfully loaded the value we wanted, FALSE otherwise for failure.

Definition at line 103 of file registry.c.

108 {
109  LONG lResult;
110  HKEY hKeyQueryValue;
111 
112  lResult = RegOpenKeyExW(hKey,
113  lpszSubKey,
114  0,
115  KEY_READ,
116  &hKeyQueryValue);
117  if (lResult != ERROR_SUCCESS)
118  {
119  DPRINT("QueryAppSettings(): Failed to open the key of path \"%S\". The error code is \"%li\".\n", lpszSubKey, lResult);
120  return FALSE;
121  }
122 
123  lResult = RegQueryValueExW(hKeyQueryValue,
124  lpszRegValue,
125  NULL,
126  NULL,
127  (LPBYTE)&ReturnedData,
128  lpdwSizeData);
129  if (lResult != ERROR_SUCCESS)
130  {
131  DPRINT("QueryAppSettings(): Failed to query the data from value \"%S\". The error code is \"%li\".\n", lpszRegValue, lResult);
132  RegCloseKey(hKeyQueryValue);
133  return FALSE;
134  }
135 
136  RegCloseKey(hKeyQueryValue);
137  return TRUE;
138 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
LONG WINAPI RegQueryValueExW(IN HKEY hKey, IN LPCWSTR lpValueName, IN PULONG lpReserved, OUT PULONG lpType OPTIONAL, OUT PUCHAR lpData OPTIONAL, IN OUT PULONG lpcbData OPTIONAL)
Definition: registry.c:862
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366

◆ SaveAppSettings()

BOOL SaveAppSettings ( IN HKEY  hKey,
IN LPCWSTR  lpszRegValue,
IN DWORD  dwRegType,
IN PVOID  Data,
IN DWORD  cbSize 
)

@SaveAppSettings

Save an application's setting data to the Registry. This is a function helper.

Parameters
[in]hKeyA handle to a key.
[in]lpszRegValueThe path to the sub key where the value needs to be created.
[out]dwRegTypeThe type of registry value to be created (e.g. a REG_DWORD).
[in]DataA pointer to an arbitrary data for the value to be set. Being arbitrary, the data can be of any type (in conformity with the registry type pointed by dwRegType) otherwise the function might lead to a undefined behaviour.
[in]cbSizeThe size of the buffer data pointed by Data parameter, in bytes.
Returns
Returns TRUE if the function successfully saved the application's setting, FALSE otherwise for failure.

Definition at line 167 of file registry.c.

172 {
173  LONG lResult;
174  HKEY hKeySetValue;
175 
176  lResult = RegOpenKeyExW(hKey,
177  NULL,
178  0,
180  &hKeySetValue);
181  if (lResult != ERROR_SUCCESS)
182  {
183  DPRINT("SaveAppSettings(): Failed to open the key, the error code is \"%li\"!\n", lResult);
184  return FALSE;
185  }
186 
187  lResult = RegSetValueExW(hKeySetValue,
188  lpszRegValue,
189  0,
190  dwRegType,
191  (LPBYTE)&Data,
192  cbSize);
193  if (lResult != ERROR_SUCCESS)
194  {
195  DPRINT("SaveAppSettings(): Failed to set the \"%S\" value with data, the error code is \"%li\"!\n", lpszRegValue, lResult);
196  RegCloseKey(hKeySetValue);
197  return FALSE;
198  }
199 
200  RegCloseKey(hKeySetValue);
201  return TRUE;
202 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define TRUE
Definition: types.h:120
LONG WINAPI RegSetValueExW(IN HKEY hKey, IN LPCWSTR lpValueName OPTIONAL, IN ULONG Reserved, IN ULONG dwType, IN const UCHAR *lpData, IN ULONG cbData)
Definition: registry.c:656
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366

◆ ShowAboutDlg()

VOID ShowAboutDlg ( IN HWND  hDlgParent)

@ShowAboutDlg

Displays the Shell "About" dialog box.

Parameters
[in]hDlgParentA handle to the parent dialog window.
Returns
Nothing.

Definition at line 167 of file umandlg.c.

168 {
169  WCHAR szApp[MAX_BUFFER];
170  WCHAR szAuthors[MAX_BUFFER];
171 
173  LoadStringW(Globals.hInstance, IDS_AUTHORS, szAuthors, _countof(szAuthors));
174 
175  ShellAboutW(hDlgParent, szApp, szAuthors, Globals.hIcon);
176 }
HINSTANCE hInstance
Definition: umandlg.h:32
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HICON hIcon
Definition: umandlg.h:33
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_BUFFER
Definition: precomp.h:20
UTILMAN_GLOBALS Globals
Definition: umandlg.c:15
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
#define IDS_APP_NAME
Definition: resource.h:137
#define IDS_AUTHORS
Definition: resource.h:44

Referenced by DlgProc().

◆ UManStartDlg()

BOOL WINAPI UManStartDlg ( VOID  )

@UManStartDlg

Executes the dialog initialization mechanism and starts Utility Manager. The function is exported for use by the main process.

Returns
Returns TRUE when the operation has succeeded, FALSE otherwise.

Definition at line 383 of file umandlg.c.

384 {
385  HANDLE hMutex;
386  DWORD dwError;
387  INITCOMMONCONTROLSEX iccex;
388 
389  /* Create a mutant object for the program. */
390  hMutex = CreateMutexW(NULL, FALSE, L"Utilman");
391  if (hMutex)
392  {
393  /* Check if there's already a mutex for the program */
394  dwError = GetLastError();
395  if (dwError == ERROR_ALREADY_EXISTS)
396  {
397  /*
398  The program's instance is already here. That means
399  the program is running and we should not set a new instance
400  and mutex object.
401  */
403  return FALSE;
404  }
405  }
406 
407  /* Load the common controls for the program */
408  iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
410  InitCommonControlsEx(&iccex);
411 
418 
419  /* Initialize the list of accessibility utilities */
421 
422  /* Create the dialog box of the program */
426  DlgProc);
427 
428  /* Delete the mutex */
429  if (hMutex)
430  {
432  }
433 
434  return TRUE;
435 }
VOID InitUtilsList(IN BOOL bInitGui)
Definition: umandlg.c:38
#define CloseHandle
Definition: compat.h:487
#define TRUE
Definition: types.h:120
HINSTANCE hInstance
Definition: umandlg.h:32
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define IDS_GROUPBOX_OPTIONS_TITLE
Definition: resource.h:25
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
INT_PTR APIENTRY DlgProc(IN HWND hDlg, IN UINT Msg, IN WPARAM wParam, IN LPARAM lParam)
Definition: umandlg.c:292
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
HANDLE hMutex
Definition: mutex.c:11
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4374
#define IDD_MAIN_DIALOG
Definition: resource.h:6
#define _countof(array)
Definition: sndvol32.h:68
WCHAR szGrpBoxTitle[MAX_BUFFER]
Definition: umandlg.h:42
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDS_RUNNING
Definition: resource.h:257
UTILMAN_GLOBALS Globals
Definition: umandlg.c:15
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
#define IDS_NOTRUNNING
Definition: resource.h:20
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
#define ICC_STANDARD_CLASSES
Definition: commctrl.h:73
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
WCHAR szNotRunning[MAX_BUFFER]
Definition: umandlg.h:41
WCHAR szRunning[MAX_BUFFER]
Definition: umandlg.h:40

Referenced by wWinMain().

◆ UpdateUtilityState()

VOID UpdateUtilityState ( IN BOOL  bUtilState)

@UpdateUtilityState

Checks the state of the given accessibility tool.

Parameters
[in]bUtilStateState condition (boolean TRUE: started / FALSE: stopped).
Returns
Nothing.

Definition at line 208 of file umandlg.c.

209 {
210  Button_Enable(Globals.hDlgCtlStart, !bUtilState);
211  Button_Enable(Globals.hDlgCtlStop, bUtilState);
212 
213  /* Update the groupbox's title based on the selected utility item */
215 }
#define Button_Enable(hwndCtl, fEnable)
Definition: windowsx.h:5
VOID GroupBoxUpdateTitle(VOID)
Definition: umandlg.c:187
HWND hDlgCtlStart
Definition: umandlg.h:36
UTILMAN_GLOBALS Globals
Definition: umandlg.c:15
HWND hDlgCtlStop
Definition: umandlg.h:37

Referenced by DlgProc(), and ListBoxRefreshContents().

Variable Documentation

◆ Globals

UTILMAN_GLOBALS Globals

Definition at line 13 of file clipbrd.c.

◆ RegData

REGISTRY_DATA RegData

Definition at line 15 of file registry.c.

◆ Settings

Definition at line 26 of file charmap.c.