ReactOS  0.4.14-dev-606-g14ebc0b
settings.c File Reference
#include "precomp.h"
Include dependency graph for settings.c:

Go to the source code of this file.

Functions

VOID SaveAllSettings (PINFO pInfo)
 
BOOL SetIntegerToSettings (PRDPSETTINGS pRdpSettings, LPWSTR lpKey, INT Value)
 
BOOL SetStringToSettings (PRDPSETTINGS pRdpSettings, LPWSTR lpKey, LPWSTR lpValue)
 
INT GetIntegerFromSettings (PRDPSETTINGS pRdpSettings, LPWSTR lpKey)
 
LPWSTR GetStringFromSettings (PRDPSETTINGS pRdpSettings, LPWSTR lpKey)
 
static BOOL WriteRdpFile (HANDLE hFile, PRDPSETTINGS pRdpSettings)
 
static VOID ParseSettings (PRDPSETTINGS pRdpSettings, LPWSTR lpBuffer)
 
static LPWSTR ReadRdpFile (HANDLE hFile)
 
static HANDLE OpenRdpFile (LPWSTR path, BOOL bWrite)
 
static VOID CloseRdpFile (HANDLE hFile)
 
BOOL SaveRdpSettingsToFile (LPWSTR lpFile, PRDPSETTINGS pRdpSettings)
 
BOOL LoadRdpSettingsFromFile (PRDPSETTINGS pRdpSettings, LPWSTR lpFile)
 
BOOL InitRdpSettings (PRDPSETTINGS pRdpSettings)
 

Variables

LPWSTR lpSettings [NUM_SETTINGS]
 

Function Documentation

◆ CloseRdpFile()

static VOID CloseRdpFile ( HANDLE  hFile)
static

Definition at line 363 of file settings.c.

364 {
365  if (hFile)
367 }
#define CloseHandle
Definition: compat.h:406
_In_ HANDLE hFile
Definition: mswsock.h:90

Referenced by LoadRdpSettingsFromFile(), and SaveRdpSettingsToFile().

◆ GetIntegerFromSettings()

INT GetIntegerFromSettings ( PRDPSETTINGS  pRdpSettings,
LPWSTR  lpKey 
)

Definition at line 144 of file settings.c.

146 {
147  INT Value = -1;
148 
149  if (pRdpSettings)
150  {
151  INT i;
152 
153  for (i = 0; i < pRdpSettings->NumSettings; i++)
154  {
155  if (wcscmp(pRdpSettings->pSettings[i].Key, lpKey) == 0)
156  {
157  if (pRdpSettings->pSettings[i].Type == L'i')
158  {
159  Value = pRdpSettings->pSettings[i].Value.i;
160  break;
161  }
162  }
163  }
164  }
165 
166  return Value;
167 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
int32_t INT
Definition: typedefs.h:56
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
union _SETTINGS::@13 Value
PSETTINGS pSettings
Definition: precomp.h:45
INT i
Definition: precomp.h:38
static const WCHAR L[]
Definition: oid.c:1250
static LPCTSTR lpKey
Definition: virtmem.c:13
WCHAR Type
Definition: precomp.h:36
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WCHAR Key[MAXKEY]
Definition: precomp.h:35
INT NumSettings
Definition: precomp.h:46

Referenced by ReLoadDisplayPage(), and wWinMain().

◆ GetStringFromSettings()

LPWSTR GetStringFromSettings ( PRDPSETTINGS  pRdpSettings,
LPWSTR  lpKey 
)

Definition at line 171 of file settings.c.

173 {
174  LPWSTR lpValue = NULL;
175 
176  if (pRdpSettings)
177  {
178  INT i;
179 
180  for (i = 0; i < pRdpSettings->NumSettings; i++)
181  {
182  if (wcscmp(pRdpSettings->pSettings[i].Key, lpKey) == 0)
183  {
184  if (pRdpSettings->pSettings[i].Type == L's')
185  {
186  lpValue = pRdpSettings->pSettings[i].Value.s;
187  break;
188  }
189  }
190  }
191  }
192 
193  return lpValue;
194 }
int32_t INT
Definition: typedefs.h:56
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
smooth NULL
Definition: ftsmooth.c:416
union _SETTINGS::@13 Value
PSETTINGS pSettings
Definition: precomp.h:45
static const WCHAR L[]
Definition: oid.c:1250
static LPCTSTR lpKey
Definition: virtmem.c:13
WCHAR Type
Definition: precomp.h:36
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WCHAR Key[MAXKEY]
Definition: precomp.h:35
INT NumSettings
Definition: precomp.h:46
WCHAR * LPWSTR
Definition: xmlstorage.h:184
WCHAR s[MAXVALUE]
Definition: precomp.h:39

Referenced by ReLoadGeneralPage(), and wWinMain().

◆ InitRdpSettings()

BOOL InitRdpSettings ( PRDPSETTINGS  pRdpSettings)

Definition at line 476 of file settings.c.

477 {
478  BOOL bRet = FALSE;
479 
480  pRdpSettings->pSettings = HeapAlloc(GetProcessHeap(),
481  0,
482  sizeof(SETTINGS) * NUM_SETTINGS);
483  if (pRdpSettings->pSettings)
484  {
485  INT i;
486 
487  for (i = 0; i < NUM_SETTINGS; i++)
488  {
489  wcscpy(pRdpSettings->pSettings[i].Key, lpSettings[i]);
490  pRdpSettings->pSettings[i].Type = (WCHAR)0;
491  pRdpSettings->pSettings[i].Value.i = 0;
492  }
493 
494  pRdpSettings->NumSettings = NUM_SETTINGS;
495 
496  bRet = TRUE;
497  }
498 
499  return bRet;
500 }
#define TRUE
Definition: types.h:120
LPWSTR lpSettings[NUM_SETTINGS]
Definition: settings.c:5
int32_t INT
Definition: typedefs.h:56
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 NUM_SETTINGS
Definition: precomp.h:30
unsigned int BOOL
Definition: ntddk_ex.h:94
union _SETTINGS::@13 Value
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
PSETTINGS pSettings
Definition: precomp.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
INT i
Definition: precomp.h:38
WCHAR Type
Definition: precomp.h:36
WCHAR Key[MAXKEY]
Definition: precomp.h:35
INT NumSettings
Definition: precomp.h:46

Referenced by wWinMain().

◆ LoadRdpSettingsFromFile()

BOOL LoadRdpSettingsFromFile ( PRDPSETTINGS  pRdpSettings,
LPWSTR  lpFile 
)

Definition at line 419 of file settings.c.

421 {
422  WCHAR pszPath[MAX_PATH];
423  HANDLE hFile;
424  BOOL bRet = FALSE;
425 
426  /* use default file */
427  if (lpFile == NULL)
428  {
429  HRESULT hr;
430  LPITEMIDLIST lpidl= NULL;
431 
434  NULL,
435  0,
436  &lpidl);
437  if (hr == S_OK)
438  {
439  if (SHGetPathFromIDListW(lpidl, pszPath))
440  {
441  wcscat(pszPath, L"\\Default.rdp");
442  lpFile = pszPath;
443  CoTaskMemFree(lpidl);
444  }
445  }
446  }
447 
448  if (lpFile)
449  {
450  LPWSTR lpBuffer = NULL;
451 
452  hFile = OpenRdpFile(lpFile, FALSE);
453  if (hFile)
454  {
456  if (lpBuffer)
457  {
458  ParseSettings(pRdpSettings, lpBuffer);
459 
461  0,
462  lpBuffer);
463 
464  bRet = TRUE;
465  }
466 
468  }
469  }
470 
471  return bRet;
472 }
#define TRUE
Definition: types.h:120
static LPWSTR ReadRdpFile(HANDLE hFile)
Definition: settings.c:301
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
unsigned int BOOL
Definition: ntddk_ex.h:94
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
static HANDLE OpenRdpFile(LPWSTR path, BOOL bWrite)
Definition: settings.c:343
smooth NULL
Definition: ftsmooth.c:416
static VOID CloseRdpFile(HANDLE hFile)
Definition: settings.c:363
#define GetProcessHeap()
Definition: compat.h:403
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
_In_ HANDLE hFile
Definition: mswsock.h:90
static VOID ParseSettings(PRDPSETTINGS pRdpSettings, LPWSTR lpBuffer)
Definition: settings.c:245
#define S_OK
Definition: intsafe.h:59
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2606
WCHAR * LPWSTR
Definition: xmlstorage.h:184
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by DoOpenFile(), ParseCommandLine(), and wWinMain().

◆ OpenRdpFile()

static HANDLE OpenRdpFile ( LPWSTR  path,
BOOL  bWrite 
)
static

Definition at line 343 of file settings.c.

344 {
345  HANDLE hFile = NULL;
346 
347  if (path)
348  {
350  bWrite ? GENERIC_WRITE : GENERIC_READ,
351  0,
352  NULL,
353  bWrite ? CREATE_ALWAYS : OPEN_EXISTING,
355  NULL);
356  }
357 
358  return hFile;
359 }
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define CreateFileW
Definition: compat.h:408

Referenced by LoadRdpSettingsFromFile(), and SaveRdpSettingsToFile().

◆ ParseSettings()

static VOID ParseSettings ( PRDPSETTINGS  pRdpSettings,
LPWSTR  lpBuffer 
)
static

Definition at line 245 of file settings.c.

247 {
248  LPWSTR lpStr = lpBuffer;
249  WCHAR szSeps[] = L":\r\n";
250  WCHAR szNewline[] = L"\r\n";
251  LPWSTR lpToken;
252  BOOL bFound;
253  INT i;
254 
255  /* move past unicode byte order */
256  if (lpStr[0] == 0xFEFF || lpStr[0] == 0xFFFE)
257  lpStr += 1;
258 
259  lpToken = wcstok(lpStr, szSeps);
260  while (lpToken)
261  {
262  bFound = FALSE;
263 
264  for (i = 0; i < pRdpSettings->NumSettings && !bFound; i++)
265  {
266  if (wcscmp(lpToken, pRdpSettings->pSettings[i].Key) == 0)
267  {
268  lpToken = wcstok(NULL, szSeps);
269  if (lpToken[0] == L'i')
270  {
271  pRdpSettings->pSettings[i].Type = lpToken[0];
272  lpToken = wcstok(NULL, szSeps);
273  if (lpToken != NULL)
274  pRdpSettings->pSettings[i].Value.i = _wtoi(lpToken);
275  }
276  else if (lpToken[0] == L's')
277  {
278  pRdpSettings->pSettings[i].Type = lpToken[0];
279  if (lpToken[2] == 13 || lpToken[2] == 10 || lpToken[2] == 0)
280  lpToken[0] = 0; // terminate string
281  else
282  lpToken = wcstok(NULL, szNewline);
283  if (lpToken != NULL)
284  wcscpy(pRdpSettings->pSettings[i].Value.s, lpToken);
285  }
286  bFound = TRUE;
287  }
288  }
289 
290  /* move past the type and value */
291  if (!bFound)
292  lpToken = wcstok(NULL, szNewline);
293 
294  /* move to next key */
295  lpToken = wcstok(NULL, szSeps);
296  }
297 }
#define TRUE
Definition: types.h:120
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP wchar_t *__cdecl wcstok(_Inout_opt_z_ wchar_t *_Str, _In_z_ const wchar_t *_Delim)
int32_t INT
Definition: typedefs.h:56
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 TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
union _SETTINGS::@13 Value
PSETTINGS pSettings
Definition: precomp.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
INT i
Definition: precomp.h:38
static const WCHAR L[]
Definition: oid.c:1250
WCHAR Type
Definition: precomp.h:36
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WCHAR Key[MAXKEY]
Definition: precomp.h:35
INT NumSettings
Definition: precomp.h:46
WCHAR * LPWSTR
Definition: xmlstorage.h:184
WCHAR s[MAXVALUE]
Definition: precomp.h:39

Referenced by LoadRdpSettingsFromFile().

◆ ReadRdpFile()

static LPWSTR ReadRdpFile ( HANDLE  hFile)
static

Definition at line 301 of file settings.c.

302 {
303  LPWSTR lpBuffer = NULL;
304  DWORD BytesToRead, BytesRead;
305  BOOL bRes;
306 
307  if (hFile)
308  {
309  BytesToRead = GetFileSize(hFile, NULL);
310  if (BytesToRead)
311  {
313  0,
314  BytesToRead + 2);
315  if (lpBuffer)
316  {
317  bRes = ReadFile(hFile,
318  lpBuffer,
319  BytesToRead,
320  &BytesRead,
321  NULL);
322  if (bRes)
323  {
324  lpBuffer[BytesRead / 2] = 0;
325  }
326  else
327  {
329  0,
330  lpBuffer);
331 
332  lpBuffer = NULL;
333  }
334  }
335  }
336  }
337 
338  return lpBuffer;
339 }
unsigned int BOOL
Definition: ntddk_ex.h:94
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
_In_ HANDLE hFile
Definition: mswsock.h:90
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:402
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

Referenced by LoadRdpSettingsFromFile().

◆ SaveAllSettings()

VOID SaveAllSettings ( PINFO  pInfo)

Definition at line 16 of file settings.c.

17 {
18  INT ret;
19  WCHAR szValue[MAXVALUE];
20 
21  /* server */
22  if (GetDlgItemText(pInfo->hGeneralPage,
24  szValue,
25  MAXVALUE))
26  {
28  L"full address",
29  szValue);
30  }
31 
32  /* resolution and fullscreen*/
35  TBM_GETPOS,
36  0,
37  0);
38  if (ret != -1)
39  {
41  L"screen mode id",
44  L"desktopwidth",
47  L"desktopheight",
49  }
50 
51  /* bpp */
55  0,
56  0);
57  if (ret != CB_ERR)
58  {
62  ret,
63  0);
64  if (ret != CB_ERR)
65  {
67  L"session bpp",
68  ret);
69  }
70  }
71 
72  /* user name */
73  if (GetDlgItemText(pInfo->hGeneralPage,
75  szValue,
76  MAXVALUE))
77  {
79  L"username",
80  szValue);
81  }
82 }
BOOL SetIntegerToSettings(PRDPSETTINGS pRdpSettings, LPWSTR lpKey, INT Value)
Definition: settings.c:86
#define CB_GETITEMDATA
Definition: winuser.h:1932
#define TBM_GETRANGEMAX
Definition: commctrl.h:2029
#define IDC_NAMEEDIT
Definition: resource.h:22
#define SendDlgItemMessage
Definition: winuser.h:5817
PDISPLAY_DEVICE_ENTRY DisplayDeviceList
Definition: precomp.h:86
int32_t INT
Definition: typedefs.h:56
BOOL SetStringToSettings(PRDPSETTINGS pRdpSettings, LPWSTR lpKey, LPWSTR lpValue)
Definition: settings.c:115
HWND hGeneralPage
Definition: precomp.h:90
#define CB_GETCURSEL
Definition: winuser.h:1925
#define TBM_GETPOS
Definition: commctrl.h:2027
#define IDC_GEOSLIDER
Definition: resource.h:19
#define CB_ERR
Definition: winuser.h:2410
PRDPSETTINGS pRdpSettings
Definition: precomp.h:85
#define GetDlgItemText
Definition: winuser.h:5760
__wchar_t WCHAR
Definition: xmlstorage.h:180
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_SERVERCOMBO
Definition: resource.h:15
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define IDC_BPPCOMBO
Definition: resource.h:20
DWORD dmPelsWidth
Definition: precomp.h:54
PRESOLUTION_INFO Resolutions
Definition: precomp.h:77
DWORD dmPelsHeight
Definition: precomp.h:55
HWND hDisplayPage
Definition: precomp.h:91
#define MAXVALUE
Definition: precomp.h:29

Referenced by DlgProc(), DoSaveAs(), and GeneralDlgProc().

◆ SaveRdpSettingsToFile()

BOOL SaveRdpSettingsToFile ( LPWSTR  lpFile,
PRDPSETTINGS  pRdpSettings 
)

Definition at line 371 of file settings.c.

373 {
374  WCHAR pszPath[MAX_PATH];
375  HANDLE hFile;
376  BOOL bRet = FALSE;
377 
378  /* use default file */
379  if (lpFile == NULL)
380  {
381  HRESULT hr;
382  LPITEMIDLIST lpidl= NULL;
383 
386  NULL,
387  0,
388  &lpidl);
389  if (hr == S_OK)
390  {
391  if (SHGetPathFromIDListW(lpidl, pszPath))
392  {
393  wcscat(pszPath, L"\\Default.rdp");
394  lpFile = pszPath;
395  CoTaskMemFree(lpidl);
396  }
397  }
398  }
399 
400  if (lpFile)
401  {
402  hFile = OpenRdpFile(lpFile, TRUE);
403  if (hFile)
404  {
405  if (WriteRdpFile(hFile, pRdpSettings))
406  {
407  bRet = TRUE;
408  }
409 
411  }
412  }
413 
414  return bRet;
415 }
#define TRUE
Definition: types.h:120
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
unsigned int BOOL
Definition: ntddk_ex.h:94
static HANDLE OpenRdpFile(LPWSTR path, BOOL bWrite)
Definition: settings.c:343
smooth NULL
Definition: ftsmooth.c:416
static VOID CloseRdpFile(HANDLE hFile)
Definition: settings.c:363
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
_In_ HANDLE hFile
Definition: mswsock.h:90
#define S_OK
Definition: intsafe.h:59
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static BOOL WriteRdpFile(HANDLE hFile, PRDPSETTINGS pRdpSettings)
Definition: settings.c:198
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2606
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by DlgProc(), DoSaveAs(), and GeneralDlgProc().

◆ SetIntegerToSettings()

BOOL SetIntegerToSettings ( PRDPSETTINGS  pRdpSettings,
LPWSTR  lpKey,
INT  Value 
)

Definition at line 86 of file settings.c.

89 {
90  BOOL bRet = FALSE;
91 
92  if (pRdpSettings)
93  {
94  INT i;
95 
96  for (i = 0; i < pRdpSettings->NumSettings; i++)
97  {
98  if (wcscmp(pRdpSettings->pSettings[i].Key, lpKey) == 0)
99  {
100  if (pRdpSettings->pSettings[i].Type == 0)
101  pRdpSettings->pSettings[i].Type = L'i';
102 
103  pRdpSettings->pSettings[i].Value.i = Value;
104  bRet = TRUE;
105  break;
106  }
107  }
108  }
109 
110  return bRet;
111 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
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
union _SETTINGS::@13 Value
PSETTINGS pSettings
Definition: precomp.h:45
INT i
Definition: precomp.h:38
static const WCHAR L[]
Definition: oid.c:1250
static LPCTSTR lpKey
Definition: virtmem.c:13
WCHAR Type
Definition: precomp.h:36
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WCHAR Key[MAXKEY]
Definition: precomp.h:35
INT NumSettings
Definition: precomp.h:46

Referenced by ParseCommandLine(), and SaveAllSettings().

◆ SetStringToSettings()

BOOL SetStringToSettings ( PRDPSETTINGS  pRdpSettings,
LPWSTR  lpKey,
LPWSTR  lpValue 
)

Definition at line 115 of file settings.c.

118 {
119  BOOL bRet = FALSE;
120 
121  if (pRdpSettings)
122  {
123  INT i;
124 
125  for (i = 0; i < pRdpSettings->NumSettings; i++)
126  {
127  if (wcscmp(pRdpSettings->pSettings[i].Key, lpKey) == 0)
128  {
129  if (pRdpSettings->pSettings[i].Type == 0)
130  pRdpSettings->pSettings[i].Type = L's';
131 
132  wcscpy(pRdpSettings->pSettings[i].Value.s, lpValue);
133  bRet = TRUE;
134  break;
135  }
136  }
137  }
138 
139  return bRet;
140 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
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
union _SETTINGS::@13 Value
PSETTINGS pSettings
Definition: precomp.h:45
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
static LPCTSTR lpKey
Definition: virtmem.c:13
WCHAR Type
Definition: precomp.h:36
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WCHAR Key[MAXKEY]
Definition: precomp.h:35
INT NumSettings
Definition: precomp.h:46
WCHAR s[MAXVALUE]
Definition: precomp.h:39

Referenced by ParseCommandLine(), and SaveAllSettings().

◆ WriteRdpFile()

static BOOL WriteRdpFile ( HANDLE  hFile,
PRDPSETTINGS  pRdpSettings 
)
static

Definition at line 198 of file settings.c.

200 {
201  WCHAR line[MAXKEY + MAXVALUE + 4];
202  SIZE_T BytesToWrite;
204  BOOL bRet;
205  INT i, k;
206 
207  for (i = 0; i < pRdpSettings->NumSettings; i++)
208  {
209  /* only write out values in the lpSettings struct */
210  for (k = 0; k < NUM_SETTINGS; k++)
211  {
212  if (wcscmp(lpSettings[k], pRdpSettings->pSettings[i].Key) == 0)
213  {
214  if (pRdpSettings->pSettings[i].Type == L'i')
215  {
216  _snwprintf(line, MAXKEY + MAXVALUE + 4, L"%s:i:%d\r\n",
217  pRdpSettings->pSettings[i].Key,
218  pRdpSettings->pSettings[i].Value.i);
219  }
220  else
221  {
222  _snwprintf(line, MAXKEY + MAXVALUE + 4, L"%s:s:%s\r\n",
223  pRdpSettings->pSettings[i].Key,
224  pRdpSettings->pSettings[i].Value.s);
225  }
226 
227  BytesToWrite = wcslen(line) * sizeof(WCHAR);
228 
229  bRet = WriteFile(hFile,
230  line,
231  BytesToWrite,
232  &BytesWritten,
233  NULL);
234  if (!bRet || BytesWritten == 0)
235  return FALSE;
236  }
237  }
238  }
239 
240  return TRUE;
241 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define TRUE
Definition: types.h:120
LPWSTR lpSettings[NUM_SETTINGS]
Definition: settings.c:5
int32_t INT
Definition: typedefs.h:56
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 NUM_SETTINGS
Definition: precomp.h:30
unsigned int BOOL
Definition: ntddk_ex.h:94
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
smooth NULL
Definition: ftsmooth.c:416
union _SETTINGS::@13 Value
Definition: parser.c:48
PSETTINGS pSettings
Definition: precomp.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAXKEY
Definition: precomp.h:28
INT i
Definition: precomp.h:38
static const WCHAR L[]
Definition: oid.c:1250
_In_ HANDLE hFile
Definition: mswsock.h:90
WCHAR Type
Definition: precomp.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WCHAR Key[MAXKEY]
Definition: precomp.h:35
INT NumSettings
Definition: precomp.h:46
unsigned int ULONG
Definition: retypes.h:1
#define MAXVALUE
Definition: precomp.h:29
WCHAR s[MAXVALUE]
Definition: precomp.h:39
int k
Definition: mpi.c:3369
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by SaveRdpSettingsToFile().

Variable Documentation

◆ lpSettings

LPWSTR lpSettings[NUM_SETTINGS]
Initial value:
=
{
L"desktopwidth",
L"desktopheight",
L"session bpp",
L"full address",
L"username",
L"screen mode id",
}
static const WCHAR L[]
Definition: oid.c:1250

Definition at line 5 of file settings.c.

Referenced by InitRdpSettings(), and WriteRdpFile().