ReactOS  0.4.14-dev-115-g4576127
screensaver.c File Reference
#include "desk.h"
Include dependency graph for screensaver.c:

Go to the source code of this file.

Classes

struct  ScreenSaverItem
 
struct  _DATA
 

Macros

#define MAX_SCREENSAVERS   100
 

Typedefs

typedef struct _DATA DATA
 
typedef struct _DATAPDATA
 

Functions

static LPTSTR GetCurrentScreenSaverValue (LPTSTR lpValue)
 
static VOID SelectionChanged (HWND hwndDlg, PDATA pData)
 
static VOID SetScreenSaverPreviewBox (HWND hwndDlg, PDATA pData)
 
static BOOL WaitForSettingsDialog (HWND hwndDlg, HANDLE hProcess)
 
static VOID ScreensaverConfig (HWND hwndDlg, PDATA pData)
 
static VOID ScreensaverPreview (HWND hwndDlg, PDATA pData)
 
static VOID CheckRegScreenSaverIsSecure (HWND hwndDlg)
 
static VOID SearchScreenSavers (HWND hwndScreenSavers, LPCTSTR pszSearchPath, PDATA pData)
 
static VOID AddScreenSavers (HWND hwndDlg, PDATA pData)
 
static VOID SetScreenSaver (HWND hwndDlg, PDATA pData)
 
static BOOL OnInitDialog (HWND hwndDlg, PDATA pData)
 
INT_PTR CALLBACK ScreenSaverPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ MAX_SCREENSAVERS

#define MAX_SCREENSAVERS   100

Definition at line 13 of file screensaver.c.

Typedef Documentation

◆ DATA

typedef struct _DATA DATA

◆ PDATA

typedef struct _DATA * PDATA

Function Documentation

◆ AddScreenSavers()

static VOID AddScreenSavers ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 456 of file screensaver.c.

457 {
458  HWND hwndScreenSavers = GetDlgItem(hwndDlg, IDC_SCREENS_LIST);
459  TCHAR szSearchPath[MAX_PATH];
460  TCHAR szLocalPath[MAX_PATH];
461  INT i;
463  LPTSTR lpBackSlash;
464 
465  /* Add the "None" item */
466  ScreenSaverItem = pData->ScreenSaverItems;
467 
469 
471  IDS_NONE,
473  sizeof(ScreenSaverItem->szDisplayName) / sizeof(TCHAR));
474 
475  i = SendMessage(hwndScreenSavers,
476  CB_ADDSTRING,
477  0,
479 
480  SendMessage(hwndScreenSavers,
482  i,
483  (LPARAM)0);
484 
485  // Initialize number of items into the list
486  pData->ScreenSaverCount = 1;
487 
488  // Add all the screensavers where the applet is stored.
489  GetModuleFileName(hApplet, szLocalPath, MAX_PATH);
490  lpBackSlash = _tcsrchr(szLocalPath, _T('\\'));
491  if (lpBackSlash != NULL)
492  {
493  *lpBackSlash = '\0';
494  SearchScreenSavers(hwndScreenSavers, szLocalPath, pData);
495  }
496 
497  // Add all the screensavers in the C:\ReactOS\System32 directory.
498  GetSystemDirectory(szSearchPath, MAX_PATH);
499  if (lpBackSlash != NULL && _tcsicmp(szSearchPath, szLocalPath) != 0)
500  SearchScreenSavers(hwndScreenSavers, szSearchPath, pData);
501 
502  // Add all the screensavers in the C:\ReactOS directory.
503  GetWindowsDirectory(szSearchPath, MAX_PATH);
504  if (lpBackSlash != NULL && _tcsicmp(szSearchPath, szLocalPath) != 0)
505  SearchScreenSavers(hwndScreenSavers, szSearchPath, pData);
506 }
#define CB_SETITEMDATA
Definition: winuser.h:1948
static VOID SearchScreenSavers(HWND hwndScreenSavers, LPCTSTR pszSearchPath, PDATA pData)
Definition: screensaver.c:337
#define IDC_SCREENS_LIST
Definition: resource.h:30
#define _tcsicmp
Definition: xmlstorage.h:205
#define IDS_NONE
Definition: resource.h:122
HINSTANCE hApplet
Definition: access.c:17
int32_t INT
Definition: typedefs.h:56
CHAR * LPTSTR
Definition: xmlstorage.h:192
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 CB_ADDSTRING
Definition: winuser.h:1918
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
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MAX_PATH
Definition: compat.h:26
#define GetModuleFileName
Definition: winbase.h:3655
#define GetSystemDirectory
Definition: winbase.h:3666
#define SendMessage
Definition: winuser.h:5744
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
TCHAR szDisplayName[256]
Definition: screensaver.c:19
#define GetWindowsDirectory
Definition: winbase.h:3681
#define LoadString
Definition: winuser.h:5720

Referenced by OnInitDialog().

◆ CheckRegScreenSaverIsSecure()

static VOID CheckRegScreenSaverIsSecure ( HWND  hwndDlg)
static

Definition at line 292 of file screensaver.c.

293 {
294  HKEY hKey;
295  TCHAR szBuffer[2];
296  DWORD bufferSize = sizeof(szBuffer);
297  DWORD varType = REG_SZ;
298  LONG result;
299 
301  _T("Control Panel\\Desktop"),
302  0,
304  &hKey) == ERROR_SUCCESS)
305  {
306  result = RegQueryValueEx(hKey,
307  _T("ScreenSaverIsSecure"),
308  0,
309  &varType,
310  (LPBYTE)szBuffer,
311  &bufferSize);
312  RegCloseKey(hKey);
313 
314  if (result == ERROR_SUCCESS)
315  {
316  if (_ttoi(szBuffer) == 1)
317  {
318  SendDlgItemMessage(hwndDlg,
320  BM_SETCHECK,
322  0);
323  return;
324  }
325  }
326 
327  SendDlgItemMessage(hwndDlg,
329  BM_SETCHECK,
331  0);
332  }
333 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define IDC_SCREENS_USEPASSCHK
Definition: resource.h:34
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5743
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
char TCHAR
Definition: xmlstorage.h:189
#define BM_SETCHECK
Definition: winuser.h:1903
#define _T(x)
Definition: vfdio.h:22
unsigned long DWORD
Definition: ntddk_ex.h:95
#define BST_UNCHECKED
Definition: winuser.h:199
#define RegOpenKeyEx
Definition: winreg.h:520
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10
#define BST_CHECKED
Definition: winuser.h:197
GLuint64EXT * result
Definition: glext.h:11304
#define REG_SZ
Definition: layer.c:22

Referenced by OnInitDialog().

◆ GetCurrentScreenSaverValue()

static LPTSTR GetCurrentScreenSaverValue ( LPTSTR  lpValue)
static

Definition at line 33 of file screensaver.c.

34 {
35  HKEY hKey;
36  LPTSTR lpBuf = NULL;
38  LONG Ret;
39 
41  _T("Control Panel\\Desktop"),
42  0,
43  KEY_READ,
44  &hKey);
45  if (Ret != ERROR_SUCCESS)
46  return NULL;
47 
48  Ret = RegQueryValueEx(hKey,
49  lpValue,
50  0,
51  &Type,
52  NULL,
53  &BufSize);
54  if (Ret == ERROR_SUCCESS)
55  {
56  lpBuf = HeapAlloc(GetProcessHeap(),
57  0,
58  BufSize);
59  if (lpBuf)
60  {
61  Ret = RegQueryValueEx(hKey,
62  lpValue,
63  0,
64  &Type,
65  (LPBYTE)lpBuf,
66  &BufSize);
67  if (Ret != ERROR_SUCCESS)
68  {
69  HeapFree(GetProcessHeap(), 0, lpBuf);
70  lpBuf = NULL;
71  }
72  }
73  }
74 
75  RegCloseKey(hKey);
76 
77  return lpBuf;
78 }
#define RegQueryValueEx
Definition: winreg.h:524
Type
Definition: Type.h:6
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
CHAR * LPTSTR
Definition: xmlstorage.h:192
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define BufSize
Definition: FsRtlTunnel.c:28
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegOpenKeyEx
Definition: winreg.h:520
#define HeapFree(x, y, z)
Definition: compat.h:394
#define REG_SZ
Definition: layer.c:22

Referenced by OnInitDialog().

◆ OnInitDialog()

static BOOL OnInitDialog ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 582 of file screensaver.c.

583 {
584  LPTSTR lpCurSs;
585  HWND hwndSSCombo = GetDlgItem(hwndDlg, IDC_SCREENS_LIST);
586  INT Num;
587 
590  sizeof(DATA));
591  if (!pData)
592  {
593  EndDialog(hwndDlg, -1);
594  return FALSE;
595  }
596 
597  SetWindowLongPtr(hwndDlg,
598  DWLP_USER,
599  (LONG_PTR)pData);
600 
601  pData->Selection = -1;
602 
603  SendDlgItemMessage(hwndDlg,
605  UDM_SETRANGE,
606  0,
607  MAKELONG
608  ((short) 240, (short) 1));
609 
610  AddScreenSavers(hwndDlg,
611  pData);
612 
614 
615  /* Set the current screensaver in the combo box */
616  lpCurSs = GetCurrentScreenSaverValue(_T("SCRNSAVE.EXE"));
617  if (lpCurSs)
618  {
619  BOOL bFound = FALSE;
620  INT i;
621 
622  for (i = 0; i < MAX_SCREENSAVERS; i++)
623  {
624  if (!_tcscmp(lpCurSs, pData->ScreenSaverItems[i].szFilename))
625  {
626  bFound = TRUE;
627  break;
628  }
629  }
630 
631  if (bFound)
632  {
633  Num = SendMessage(hwndSSCombo,
635  -1,
636  (LPARAM)pData->ScreenSaverItems[i].szDisplayName);
637  if (Num != CB_ERR)
638  SendMessage(hwndSSCombo,
639  CB_SETCURSEL,
640  Num,
641  0);
642  }
643  else
644  {
645  SendMessage(hwndSSCombo,
646  CB_SETCURSEL,
647  0,
648  0);
649  }
650 
652  0,
653  lpCurSs);
654  }
655  else
656  {
657  /* Set screensaver to (none) */
658  SendMessage(hwndSSCombo,
659  CB_SETCURSEL,
660  0,
661  0);
662  }
663 
664  /* Set the current timeout */
665  lpCurSs = GetCurrentScreenSaverValue(_T("ScreenSaveTimeOut"));
666  if (lpCurSs)
667  {
668  UINT Time = _ttoi(lpCurSs);
669 
670  Time /= 60;
671 
672  SendDlgItemMessage(hwndDlg,
674  UDM_SETPOS32,
675  0,
676  Time);
677 
679  0,
680  lpCurSs);
681 
682  }
683 
684  SelectionChanged(hwndDlg,
685  pData);
686 
687  return TRUE;
688 }
#define TRUE
Definition: types.h:120
#define IDC_SCREENS_LIST
Definition: resource.h:30
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define SendDlgItemMessage
Definition: winuser.h:5743
int32_t INT
Definition: typedefs.h:56
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define IDC_SCREENS_TIME
Definition: resource.h:36
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
unsigned int BOOL
Definition: ntddk_ex.h:94
static VOID CheckRegScreenSaverIsSecure(HWND hwndDlg)
Definition: screensaver.c:292
#define MAKELONG(a, b)
Definition: typedefs.h:248
LONG_PTR LPARAM
Definition: windef.h:208
#define UDM_SETRANGE
Definition: commctrl.h:2113
#define CB_ERR
Definition: winuser.h:2410
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define UDM_SETPOS32
Definition: commctrl.h:2127
static VOID AddScreenSavers(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:456
#define DWLP_USER
Definition: winuser.h:866
#define CB_SETCURSEL
Definition: winuser.h:1943
static VOID SelectionChanged(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:82
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define SendMessage
Definition: winuser.h:5744
#define MAX_SCREENSAVERS
Definition: screensaver.c:13
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
static LPTSTR GetCurrentScreenSaverValue(LPTSTR lpValue)
Definition: screensaver.c:33
#define HeapFree(x, y, z)
Definition: compat.h:394
static PLARGE_INTEGER Time
Definition: time.c:105
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1922

Referenced by ScreenSaverPageProc().

◆ ScreensaverConfig()

static VOID ScreensaverConfig ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 196 of file screensaver.c.

197 {
198  /*
199  * /c:<hwnd> Run configuration, hwnd is handle of calling window
200  */
201 
202  TCHAR szCmdline[2048];
203  STARTUPINFO si;
205 
206  if (pData->Selection < 1)
207  return;
208 
209  _stprintf(szCmdline,
210  _T("%s /c:%Iu"),
211  pData->ScreenSaverItems[pData->Selection].szFilename,
212  (ULONG_PTR)hwndDlg);
213 
214  ZeroMemory(&si, sizeof(si));
215  si.cb = sizeof(si);
216  ZeroMemory(&pi, sizeof(pi));
217  if (CreateProcess(NULL,
218  szCmdline,
219  NULL,
220  NULL,
221  FALSE,
222  0,
223  NULL,
224  NULL,
225  &si,
226  &pi))
227  {
228  /* Kill off the previous preview process */
229  if (pData->PrevWindowPi.hProcess)
230  {
231  TerminateProcess(pData->PrevWindowPi.hProcess, 0);
232  CloseHandle(pData->PrevWindowPi.hProcess);
233  CloseHandle(pData->PrevWindowPi.hThread);
234  pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
235  }
236 
237  if (WaitForSettingsDialog(hwndDlg, pi.hProcess))
239  }
240 }
#define CloseHandle
Definition: compat.h:398
#define ZeroMemory
Definition: winbase.h:1642
static VOID SetScreenSaverPreviewBox(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:108
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
DWORD cb
Definition: winbase.h:803
static DWORD pi
Definition: protocol.c:150
#define CreateProcess
Definition: winbase.h:3582
#define _stprintf
Definition: utility.h:124
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
static BOOL WaitForSettingsDialog(HWND hwndDlg, HANDLE hProcess)
Definition: screensaver.c:151

Referenced by ScreenSaverPageProc().

◆ ScreenSaverPageProc()

INT_PTR CALLBACK ScreenSaverPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 692 of file screensaver.c.

696 {
697  PDATA pData;
698 
699  pData = (PDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
700 
701  switch (uMsg)
702  {
703  case WM_INITDIALOG:
704  {
705  OnInitDialog(hwndDlg, pData);
706  break;
707  }
708 
709  case WM_DESTROY:
710  {
711  if (pData->PrevWindowPi.hProcess)
712  {
713  TerminateProcess(pData->PrevWindowPi.hProcess, 0);
714  CloseHandle(pData->PrevWindowPi.hProcess);
715  CloseHandle(pData->PrevWindowPi.hThread);
716  }
718  0,
719  pData);
720  break;
721  }
722 
723  case WM_ENDSESSION:
724  {
725  SetScreenSaverPreviewBox(hwndDlg,
726  pData);
727  break;
728  }
729 
730  case WM_COMMAND:
731  {
732  DWORD controlId = LOWORD(wParam);
734 
735  switch (controlId)
736  {
737  case IDC_SCREENS_LIST:
738  {
739  if (HIWORD(wParam) == CBN_SELCHANGE)
740  {
741  SelectionChanged(hwndDlg, pData);
743  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
744  }
745  break;
746  }
747 
749  {
750  if (command == EN_CHANGE)
751  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
752  break;
753  }
754 
755  case IDC_SCREENS_POWER_BUTTON: // Start Powercfg.Cpl
756  {
757  if (command == BN_CLICKED)
758  WinExec("rundll32 shell32.dll,Control_RunDLL powercfg.cpl",SW_SHOWNORMAL);
759  break;
760  }
761 
762  case IDC_SCREENS_TESTSC: // Screensaver Preview
763  {
764  if (command == BN_CLICKED)
765  {
766  ScreensaverPreview(hwndDlg, pData);
768  }
769  break;
770  }
771 
772  case IDC_SCREENS_SETTINGS: // Screensaver Settings
773  {
774  if (command == BN_CLICKED)
775  ScreensaverConfig(hwndDlg, pData);
776  break;
777  }
778 
779  case IDC_SCREENS_USEPASSCHK: // Screensaver Is Secure
780  {
781  if (command == BN_CLICKED)
782  {
783  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
784  }
785  break;
786  }
787  }
788  break;
789  }
790 
791  case WM_NOTIFY:
792  {
793  LPNMHDR lpnm = (LPNMHDR)lParam;
794 
795  switch(lpnm->code)
796  {
797  case PSN_APPLY:
798  {
799  SetScreenSaver(hwndDlg, pData);
800  return TRUE;
801  }
802 
803  case PSN_SETACTIVE:
804  {
805  /* Enable screensaver preview support */
807  break;
808  }
809 
810  case PSN_KILLACTIVE:
811  {
812  /* Kill running preview screensaver */
813  if (pData->PrevWindowPi.hProcess)
814  {
815  TerminateProcess(pData->PrevWindowPi.hProcess, 0);
816  CloseHandle(pData->PrevWindowPi.hProcess);
817  CloseHandle(pData->PrevWindowPi.hThread);
818  pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
819  }
820  break;
821  }
822  }
823  }
824  break;
825  }
826 
827  return FALSE;
828 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define IDC_SCREENS_SETTINGS
Definition: resource.h:32
#define IDC_SCREENS_POWER_BUTTON
Definition: resource.h:31
#define IDC_SCREENS_LIST
Definition: resource.h:30
#define IDC_SCREENS_TIMEDELAY
Definition: resource.h:35
#define IDC_SCREENS_USEPASSCHK
Definition: resource.h:34
static BOOL OnInitDialog(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:582
UINT WINAPI DECLSPEC_HOTPATCH WinExec(LPCSTR lpCmdLine, UINT uCmdShow)
Definition: proc.c:4774
static VOID SetScreenSaver(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:510
#define PSN_APPLY
Definition: prsht.h:117
#define PSN_SETACTIVE
Definition: prsht.h:115
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
static VOID SetScreenSaverPreviewBox(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:108
UINT code
Definition: winuser.h:3133
#define PSN_KILLACTIVE
Definition: prsht.h:116
smooth NULL
Definition: ftsmooth.c:416
struct _DATA * PDATA
#define WM_DESTROY
Definition: winuser.h:1591
#define GetProcessHeap()
Definition: compat.h:395
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID ScreensaverPreview(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:244
#define WM_ENDSESSION
Definition: winuser.h:1609
static VOID ScreensaverConfig(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:196
#define DWLP_USER
Definition: winuser.h:866
#define IDC_SCREENS_TESTSC
Definition: resource.h:33
static VOID SelectionChanged(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:82
#define WM_COMMAND
Definition: winuser.h:1722
HWND WINAPI GetParent(_In_ HWND)
#define SW_SHOWNORMAL
Definition: winuser.h:764
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
#define CBN_SELCHANGE
Definition: winuser.h:1961
#define HIWORD(l)
Definition: typedefs.h:246
#define GetWindowLongPtr
Definition: treelist.c:73
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
#define WM_NOTIFY
Definition: richedit.h:61
#define EN_CHANGE
Definition: winuser.h:2004

◆ ScreensaverPreview()

static VOID ScreensaverPreview ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 244 of file screensaver.c.

245 {
246  /*
247  /s Run normal
248  */
249 
250  TCHAR szCmdline[2048];
251  STARTUPINFO si;
253 
254  if (pData->Selection < 1)
255  return;
256 
257  /* Kill off the previous preview process */
258  if (pData->PrevWindowPi.hProcess)
259  {
260  TerminateProcess(pData->PrevWindowPi.hProcess, 0);
261  CloseHandle(pData->PrevWindowPi.hProcess);
262  CloseHandle(pData->PrevWindowPi.hThread);
263  pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
264  }
265 
266  _stprintf(szCmdline,
267  _T("%s /s"),
268  pData->ScreenSaverItems[pData->Selection].szFilename);
269 
270  ZeroMemory(&si, sizeof(si));
271  si.cb = sizeof(si);
272  ZeroMemory(&pi, sizeof(pi));
273  if (CreateProcess(NULL,
274  szCmdline,
275  NULL,
276  NULL,
277  FALSE,
278  0,
279  NULL,
280  NULL,
281  &si,
282  &pi))
283  {
284  WaitForSingleObject(pi.hProcess, INFINITE);
285  CloseHandle(pi.hProcess);
286  CloseHandle(pi.hThread);
287  }
288 }
#define CloseHandle
Definition: compat.h:398
#define ZeroMemory
Definition: winbase.h:1642
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
DWORD cb
Definition: winbase.h:803
static DWORD pi
Definition: protocol.c:150
#define CreateProcess
Definition: winbase.h:3582
#define _stprintf
Definition: utility.h:124
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define INFINITE
Definition: serial.h:102

Referenced by ScreenSaverPageProc().

◆ SearchScreenSavers()

static VOID SearchScreenSavers ( HWND  hwndScreenSavers,
LPCTSTR  pszSearchPath,
PDATA  pData 
)
static

Definition at line 337 of file screensaver.c.

340 {
342  TCHAR szSearchPath[MAX_PATH];
343  HANDLE hFind;
345  HANDLE hModule;
346  UINT i, ScreenSaverCount;
347  HRESULT hr;
348 
349  ScreenSaverCount = pData->ScreenSaverCount;
350 
351  hr = StringCbCopy(szSearchPath, sizeof(szSearchPath), pszSearchPath);
352  if (FAILED(hr))
353  return;
354  hr = StringCbCat(szSearchPath, sizeof(szSearchPath), TEXT("\\*.scr"));
355  if (FAILED(hr))
356  return;
357 
358  hFind = FindFirstFile(szSearchPath, &fd);
359 
360  if (hFind == INVALID_HANDLE_VALUE)
361  return;
362 
363  while (ScreenSaverCount < MAX_SCREENSAVERS)
364  {
365  /* Don't add any hidden screensavers */
366  if ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0)
367  {
369 
370  hr = StringCbCopy(filename, sizeof(filename), pszSearchPath);
371  if (FAILED(hr))
372  {
373  FindClose(hFind);
374  return;
375  }
376  hr = StringCbCat(filename, sizeof(filename), _T("\\"));
377  if (FAILED(hr))
378  {
379  FindClose(hFind);
380  return;
381  }
382  hr = StringCbCat(filename, sizeof(filename), fd.cFileName);
383  if (FAILED(hr))
384  {
385  FindClose(hFind);
386  return;
387  }
388 
389  ScreenSaverItem = pData->ScreenSaverItems + ScreenSaverCount;
390 
392 
394  NULL,
396  if (hModule)
397  {
398  if (0 == LoadString(hModule,
399  1,
401  sizeof(ScreenSaverItem->szDisplayName) / sizeof(TCHAR)))
402  {
403  // If the string does not exists, copy the name of the file
405  if (FAILED(hr))
406  {
408  FindClose(hFind);
409  return;
410  }
411  ScreenSaverItem->szDisplayName[_tcslen(fd.cFileName)-4] = '\0';
412  }
414  }
415  else
416  {
418  if (FAILED(hr))
419  {
420  FindClose(hFind);
421  return;
422  }
423  }
424 
426  if (FAILED(hr))
427  {
428  FindClose(hFind);
429  return;
430  }
431 
432  i = SendMessage(hwndScreenSavers,
433  CB_ADDSTRING,
434  0,
436 
437  SendMessage(hwndScreenSavers,
439  i,
440  (LPARAM)ScreenSaverCount);
441 
442  ScreenSaverCount++;
443  }
444 
445  if (!FindNextFile(hFind, &fd))
446  break;
447  }
448 
449  FindClose(hFind);
450 
451  pData->ScreenSaverCount = ScreenSaverCount;
452 }
#define CB_SETITEMDATA
Definition: winuser.h:1948
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static int fd
Definition: io.c:51
const char * filename
Definition: ioapi.h:135
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
TCHAR szFilename[MAX_PATH]
Definition: screensaver.c:18
#define CB_ADDSTRING
Definition: winuser.h:1918
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define FindFirstFile
Definition: winbase.h:3606
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define FreeLibrary(x)
Definition: compat.h:405
#define StringCbCat
Definition: strsafe.h:334
LONG HRESULT
Definition: typedefs.h:77
#define FindNextFile
Definition: winbase.h:3612
#define MAX_PATH
Definition: compat.h:26
#define DONT_RESOLVE_DLL_REFERENCES
Definition: winbase.h:337
#define StringCbCopy
Definition: strsafe.h:155
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
#define TEXT(s)
Definition: k32.h:26
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
unsigned int UINT
Definition: ndis.h:50
#define LoadLibraryEx
Definition: winbase.h:3687
#define SendMessage
Definition: winuser.h:5744
#define MAX_SCREENSAVERS
Definition: screensaver.c:13
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
TCHAR szDisplayName[256]
Definition: screensaver.c:19
#define LoadString
Definition: winuser.h:5720
HMODULE hModule
Definition: animate.c:44
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by AddScreenSavers().

◆ SelectionChanged()

static VOID SelectionChanged ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 82 of file screensaver.c.

83 {
84  HWND hwndCombo;
85  BOOL bEnable;
86  INT i;
87 
88  hwndCombo = GetDlgItem(hwndDlg, IDC_SCREENS_LIST);
89 
90  i = (INT)SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
91  i = (INT)SendMessage(hwndCombo, CB_GETITEMDATA, i, 0);
92 
93  pData->Selection = i;
94 
95  bEnable = (i != 0);
96 
104 }
#define IDC_SCREENS_SETTINGS
Definition: resource.h:32
#define IDC_SCREENS_LIST
Definition: resource.h:30
#define IDC_SCREENS_TIMEDELAY
Definition: resource.h:35
#define CB_GETITEMDATA
Definition: winuser.h:1932
#define IDC_SCREENS_USEPASSCHK
Definition: resource.h:34
#define INT
Definition: polytest.cpp:20
int32_t INT
Definition: typedefs.h:56
#define CB_GETCURSEL
Definition: winuser.h:1925
#define IDC_SCREENS_TIME
Definition: resource.h:36
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDC_WAITTEXT
Definition: resource.h:37
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_SCREENS_TESTSC
Definition: resource.h:33
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
_In_ BOOL bEnable
Definition: winddi.h:3426
#define IDC_MINTEXT
Definition: resource.h:38
#define SendMessage
Definition: winuser.h:5744
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by OnInitDialog(), and ScreenSaverPageProc().

◆ SetScreenSaver()

static VOID SetScreenSaver ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 510 of file screensaver.c.

511 {
512  HKEY regKey;
513  BOOL DeleteMode = FALSE;
514 
516 
518  _T("Control Panel\\Desktop"),
519  0,
521  &regKey) == ERROR_SUCCESS)
522  {
523  INT Time;
524  BOOL bRet;
525  TCHAR Sec;
526  UINT Ret;
527 
528  /* Set the screensaver */
529  if (pData->ScreenSaverItems[pData->Selection].bIsScreenSaver)
530  {
531  SIZE_T Length = _tcslen(pData->ScreenSaverItems[pData->Selection].szFilename) * sizeof(TCHAR);
532  RegSetValueEx(regKey,
533  _T("SCRNSAVE.EXE"),
534  0,
535  REG_SZ,
536  (PBYTE)pData->ScreenSaverItems[pData->Selection].szFilename,
537  (DWORD)Length);
538 
540  }
541  else
542  {
543  /* Windows deletes the value if no screensaver is set */
544  RegDeleteValue(regKey, _T("SCRNSAVE.EXE"));
545  DeleteMode = TRUE;
546 
548  }
549 
550  /* Set the secure value */
551  Ret = SendDlgItemMessage(hwndDlg,
553  BM_GETCHECK,
554  0,
555  0);
556  Sec = (Ret == BST_CHECKED) ? _T('1') : _T('0');
557  RegSetValueEx(regKey,
558  _T("ScreenSaverIsSecure"),
559  0,
560  REG_SZ,
561  (PBYTE)&Sec,
562  sizeof(TCHAR));
563 
564  /* Set the screensaver time delay */
565  Time = GetDlgItemInt(hwndDlg,
567  &bRet,
568  FALSE);
569  if (Time == 0)
570  Time = 60;
571  else
572  Time *= 60;
573 
575 
576  RegCloseKey(regKey);
577  }
578 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDC_SCREENS_TIMEDELAY
Definition: resource.h:35
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define IDC_SCREENS_USEPASSCHK
Definition: resource.h:34
#define SystemParametersInfo
Definition: winuser.h:5759
#define SendDlgItemMessage
Definition: winuser.h:5743
int32_t INT
Definition: typedefs.h:56
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
#define BM_GETCHECK
Definition: winuser.h:1900
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:326
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
char TCHAR
Definition: xmlstorage.h:189
#define RegDeleteValue
Definition: winreg.h:508
#define _T(x)
Definition: vfdio.h:22
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define SPI_SETSCREENSAVEACTIVE
Definition: winuser.h:1348
UINT Sec[]
Definition: powershemes.c:41
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
#define RegOpenKeyEx
Definition: winreg.h:520
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
unsigned int UINT
Definition: ndis.h:50
#define SPIF_SENDCHANGE
Definition: winuser.h:1554
#define BST_CHECKED
Definition: winuser.h:197
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
BYTE * PBYTE
Definition: pedump.c:66
#define RegSetValueEx
Definition: winreg.h:533
static PLARGE_INTEGER Time
Definition: time.c:105
#define SPI_SETSCREENSAVETIMEOUT
Definition: winuser.h:1346
#define REG_SZ
Definition: layer.c:22

Referenced by ScreenSaverPageProc().

◆ SetScreenSaverPreviewBox()

static VOID SetScreenSaverPreviewBox ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 108 of file screensaver.c.

109 {
110  HWND hPreview = GetDlgItem(hwndDlg, IDC_SCREENS_PREVIEW);
111  STARTUPINFO si;
112  TCHAR szCmdline[2048];
113 
114  /* Kill off the previous preview process */
115  if (pData->PrevWindowPi.hProcess)
116  {
117  TerminateProcess(pData->PrevWindowPi.hProcess, 0);
118  CloseHandle(pData->PrevWindowPi.hProcess);
119  CloseHandle(pData->PrevWindowPi.hThread);
120  pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
121  }
122 
123  if (pData->Selection > 0)
124  {
125  _stprintf(szCmdline,
126  _T("%s /p %Iu"),
127  pData->ScreenSaverItems[pData->Selection].szFilename,
128  (ULONG_PTR)hPreview);
129 
130  ZeroMemory(&si, sizeof(si));
131  si.cb = sizeof(si);
132  ZeroMemory(&pData->PrevWindowPi, sizeof(pData->PrevWindowPi));
133 
134  if (!CreateProcess(NULL,
135  szCmdline,
136  NULL,
137  NULL,
138  FALSE,
139  0,
140  NULL,
141  NULL,
142  &si,
143  &pData->PrevWindowPi))
144  {
145  pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
146  }
147  }
148 }
#define CloseHandle
Definition: compat.h:398
#define ZeroMemory
Definition: winbase.h:1642
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
#define IDC_SCREENS_PREVIEW
Definition: resource.h:29
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
DWORD cb
Definition: winbase.h:803
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CreateProcess
Definition: winbase.h:3582
#define _stprintf
Definition: utility.h:124
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by ScreensaverConfig(), and ScreenSaverPageProc().

◆ WaitForSettingsDialog()

static BOOL WaitForSettingsDialog ( HWND  hwndDlg,
HANDLE  hProcess 
)
static

Definition at line 151 of file screensaver.c.

153 {
154  DWORD dwResult;
155  MSG msg;
156 
157  while (TRUE)
158  {
159  dwResult = MsgWaitForMultipleObjects(1,
160  &hProcess,
161  FALSE,
162  INFINITE,
163  QS_ALLINPUT);
164  if (dwResult == WAIT_OBJECT_0 + 1)
165  {
166  if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
167  {
168  if (msg.message == WM_QUIT)
169  {
170  return FALSE;
171  }
172  if (IsDialogMessage(hwndDlg, &msg))
173  {
176  }
177  }
178  else
179  {
180  return FALSE;
181  }
182  }
183  else if (dwResult == WAIT_OBJECT_0)
184  {
185  return TRUE;
186  }
187  else
188  {
189  return FALSE;
190  }
191  }
192 }
#define DispatchMessage
Definition: winuser.h:5666
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PeekMessage
Definition: winuser.h:5731
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define WM_QUIT
Definition: winuser.h:1605
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define IsDialogMessage
Definition: winuser.h:5710
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define QS_ALLINPUT
Definition: winuser.h:874
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182
#define INFINITE
Definition: serial.h:102

Referenced by ScreensaverConfig().