ReactOS 0.4.15-dev-7918-g2a2556c
parallel.c File Reference
#include "precomp.h"
Include dependency graph for parallel.c:

Go to the source code of this file.

Classes

struct  _PORT_DATA
 

Typedefs

typedef struct _PORT_DATA PORT_DATA
 
typedef struct _PORT_DATAPPORT_DATA
 

Functions

static VOID GetUsedPorts (PDWORD pPortMap)
 
static VOID ReadPortSettings (PPORT_DATA pPortData)
 
static DWORD ChangePortNumber (_In_ PPORT_DATA pPortData, _In_ DWORD dwNewPortNumber)
 
static VOID WritePortSettings (HWND hwnd, PPORT_DATA pPortData)
 
static BOOL OnInitDialog (HWND hwnd, WPARAM wParam, LPARAM lParam)
 
static VOID OnNotify (HWND hwnd, WPARAM wParam, LPARAM lParam)
 
static VOID OnDestroy (HWND hwnd)
 
static INT_PTR CALLBACK ParallelSettingsDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI ParallelPortPropPageProvider (PSP_PROPSHEETPAGE_REQUEST lpPropSheetPageRequest, LPFNADDPROPSHEETPAGE lpfnAddPropSheetPageProc, LPARAM lParam)
 

Typedef Documentation

◆ PORT_DATA

◆ PPORT_DATA

Function Documentation

◆ ChangePortNumber()

static DWORD ChangePortNumber ( _In_ PPORT_DATA  pPortData,
_In_ DWORD  dwNewPortNumber 
)
static

Definition at line 164 of file parallel.c.

167{
168 WCHAR szDeviceDescription[256];
169 WCHAR szFriendlyName[256];
170 WCHAR szNewPortName[16];
171 HKEY hDeviceKey = INVALID_HANDLE_VALUE;
172 DWORD dwError;
173
174 /* We are done if old and new port number are the same */
175 if (pPortData->dwPortNumber == dwNewPortNumber)
176 return ERROR_SUCCESS;
177
178 /* Build the new port name */
179 swprintf(szNewPortName, L"LPT%lu", dwNewPortNumber);
180
181 /* Open the devices hardware key */
182 hDeviceKey = SetupDiOpenDevRegKey(pPortData->DeviceInfoSet,
183 pPortData->DeviceInfoData,
185 0,
186 DIREG_DEV,
188 if (hDeviceKey == INVALID_HANDLE_VALUE)
189 {
190 return GetLastError();
191 }
192
193 /* Set the new 'PortName' value */
194 dwError = RegSetValueExW(hDeviceKey,
195 L"PortName",
196 0,
197 REG_SZ,
198 (LPBYTE)szNewPortName,
199 (wcslen(szNewPortName) + 1) * sizeof(WCHAR));
200 if (dwError != ERROR_SUCCESS)
201 goto done;
202
203 /* Save the new port name and number */
204 wcscpy(pPortData->szPortName, szNewPortName);
205 pPortData->dwPortNumber = dwNewPortNumber;
206
207 /* Get the device description... */
208 if (SetupDiGetDeviceRegistryProperty(pPortData->DeviceInfoSet,
209 pPortData->DeviceInfoData,
211 NULL,
212 (PBYTE)szDeviceDescription,
213 sizeof(szDeviceDescription),
214 NULL))
215 {
216 /* ... and use it to build a new friendly name */
217 swprintf(szFriendlyName,
218 L"%s (%s)",
219 szDeviceDescription,
220 szNewPortName);
221 }
222 else
223 {
224 /* ... or build a generic friendly name */
225 swprintf(szFriendlyName,
226 L"Parallel Port (%s)",
227 szNewPortName);
228 }
229
230 /* Set the friendly name for the device */
231 SetupDiSetDeviceRegistryProperty(pPortData->DeviceInfoSet,
232 pPortData->DeviceInfoData,
234 (PBYTE)szFriendlyName,
235 (wcslen(szFriendlyName) + 1) * sizeof(WCHAR));
236
237done:
238 if (hDeviceKey != INVALID_HANDLE_VALUE)
239 RegCloseKey(hDeviceKey);
240
241 return dwError;
242}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5934
#define swprintf
Definition: precomp.h:40
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SPDRP_DEVICEDESC
Definition: setupapi.h:507
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2603
#define DIREG_DEV
Definition: setupapi.h:181
#define SetupDiSetDeviceRegistryProperty
Definition: setupapi.h:2620
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
#define SPDRP_FRIENDLYNAME
Definition: setupapi.h:519
unsigned char * LPBYTE
Definition: typedefs.h:53
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by WritePortSettings().

◆ GetUsedPorts()

static VOID GetUsedPorts ( PDWORD  pPortMap)
static

Definition at line 27 of file parallel.c.

29{
31 WCHAR szDosDeviceName[64];
32 DWORD dwIndex, dwType, dwPortNumber;
33 DWORD dwDeviceNameSize, dwDosDeviceNameSize;
34 PWSTR ptr;
35 HKEY hKey;
36 DWORD dwError;
37
38 *pPortMap = 0;
39
41 L"Hardware\\DeviceMap\\PARALLEL PORTS",
42 0,
44 &hKey);
45 if (dwError == ERROR_SUCCESS)
46 {
47 for (dwIndex = 0; ; dwIndex++)
48 {
49 dwDeviceNameSize = ARRAYSIZE(szDeviceName);
50 dwDosDeviceNameSize = sizeof(szDosDeviceName);
51 dwError = RegEnumValueW(hKey,
52 dwIndex,
54 &dwDeviceNameSize,
55 NULL,
56 &dwType,
57 (LPBYTE)szDosDeviceName,
58 &dwDosDeviceNameSize);
59 if (dwError != ERROR_SUCCESS)
60 break;
61
62 if (dwType == REG_SZ)
63 {
64 TRACE("%S --> %S\n", szDeviceName, szDosDeviceName);
65 if (_wcsnicmp(szDosDeviceName, L"\\DosDevices\\LPT", wcslen(L"\\DosDevices\\LPT")) == 0)
66 {
67 ptr = szDosDeviceName + wcslen(L"\\DosDevices\\LPT");
68 if (wcschr(ptr, L'.') == NULL)
69 {
70 TRACE("Device number %S\n", ptr);
71 dwPortNumber = wcstoul(ptr, NULL, 10);
72 if (dwPortNumber != 0)
73 {
74 *pPortMap |=(1 << dwPortNumber);
75 }
76 }
77 }
78 }
79 }
80
82 }
83
84 TRACE("Done\n");
85}
static const WCHAR szDeviceName[]
Definition: provider.c:56
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
#define wcschr
Definition: compat.h:17
FxAutoRegKey hKey
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
static PVOID ptr
Definition: dispmode.c:27
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define TRACE(s)
Definition: solgame.cpp:4
uint16_t * PWSTR
Definition: typedefs.h:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by OnInitDialog(), and WritePortSettings().

◆ OnDestroy()

static VOID OnDestroy ( HWND  hwnd)
static

Definition at line 476 of file parallel.c.

478{
479 PPORT_DATA pPortData;
480
481 TRACE("OnDestroy()\n");
482
484 if (pPortData == NULL)
485 {
486 ERR("pPortData is NULL\n");
487 return;
488 }
489
490 HeapFree(GetProcessHeap(), 0, pPortData);
492}
#define ERR(fmt,...)
Definition: debug.h:110
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
struct _PORT_DATA * PPORT_DATA
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define DWLP_USER
Definition: winuser.h:872

Referenced by ParallelSettingsDlgProc().

◆ OnInitDialog()

static BOOL OnInitDialog ( HWND  hwnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 378 of file parallel.c.

381{
382 WCHAR szBuffer[256];
383 WCHAR szPortInUse[64];
384 PPORT_DATA pPortData;
385 HWND hwndControl;
386 DWORD dwPortMap;
387 UINT i;
388
389 TRACE("OnInitDialog()\n");
390
391 pPortData = (PPORT_DATA)((LPPROPSHEETPAGEW)lParam)->lParam;
392 if (pPortData == NULL)
393 {
394 ERR("pPortData is NULL\n");
395 return FALSE;
396 }
397
399
400 /* Read and parse the port settings */
401 ReadPortSettings(pPortData);
402
403 /* Set the 'Filter Resource Method' radiobuttons */
404 hwndControl = GetDlgItem(hwnd,
406 if (hwndControl)
407 Button_SetCheck(hwndControl, BST_CHECKED);
408
409 /* Disable the 'Enable legacy PNP detection' checkbox */
410 hwndControl = GetDlgItem(hwnd, IDC_PARALLEL_LEGACY);
411 if (hwndControl)
412 {
414 pPortData->dwLegacy ? BST_CHECKED : BST_UNCHECKED);
415 }
416
417 LoadStringW(hInstance, IDS_PORT_IN_USE, szPortInUse, ARRAYSIZE(szPortInUse));
418
419 /* Fill the 'LPT Port Number' combobox */
420 hwndControl = GetDlgItem(hwnd, IDC_PARALLEL_NAME);
421 if (hwndControl)
422 {
423 GetUsedPorts(&dwPortMap);
424
425 for (i = 1; i < 4; i++)
426 {
427 swprintf(szBuffer, L"LPT%lu", i);
428
429 if ((dwPortMap & (1 << i)) && (pPortData->dwPortNumber != i))
430 wcscat(szBuffer, szPortInUse);
431
432 ComboBox_AddString(hwndControl, szBuffer);
433
434 if (_wcsicmp(pPortData->szPortName, szBuffer) == 0)
435 pPortData->dwPortNumber = i;
436 }
437
438 if (pPortData->dwPortNumber != 0)
439 {
440 ComboBox_SetCurSel(hwndControl, pPortData->dwPortNumber - 1);
441 }
442 }
443
444 return TRUE;
445}
HINSTANCE hInstance
Definition: charmap.c:19
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static VOID GetUsedPorts(PDWORD pPortMap)
Definition: parallel.c:27
static VOID ReadPortSettings(PPORT_DATA pPortData)
Definition: parallel.c:90
#define IDS_PORT_IN_USE
Definition: resource.h:23
#define IDC_TRY_INTERRUPT
Definition: resource.h:13
#define IDC_PARALLEL_LEGACY
Definition: resource.h:16
#define IDC_PARALLEL_NAME
Definition: resource.h:17
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 UINT
Definition: ndis.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DWORD dwLegacy
Definition: parallel.c:20
DWORD dwPortNumber
Definition: parallel.c:18
WCHAR szPortName[16]
Definition: parallel.c:17
DWORD dwFilterResourceMethod
Definition: parallel.c:19
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:66
#define ComboBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:41
#define Button_SetCheck(hwndCtl, check)
Definition: windowsx.h:35
#define BST_UNCHECKED
Definition: winuser.h:199
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define BST_CHECKED
Definition: winuser.h:197

Referenced by ParallelSettingsDlgProc().

◆ OnNotify()

static VOID OnNotify ( HWND  hwnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 450 of file parallel.c.

454{
455 PPORT_DATA pPortData;
456
457 TRACE("OnNotify()\n");
458
460 if (pPortData == NULL)
461 {
462 ERR("pPortData is NULL\n");
463 return;
464 }
465
466 if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
467 {
468 TRACE("PSN_APPLY!\n");
469 WritePortSettings(hwnd, pPortData);
470 }
471}
static VOID WritePortSettings(HWND hwnd, PPORT_DATA pPortData)
Definition: parallel.c:247
#define PSN_APPLY
Definition: prsht.h:117
Definition: inflate.c:139

Referenced by ParallelSettingsDlgProc().

◆ ParallelPortPropPageProvider()

BOOL WINAPI ParallelPortPropPageProvider ( PSP_PROPSHEETPAGE_REQUEST  lpPropSheetPageRequest,
LPFNADDPROPSHEETPAGE  lpfnAddPropSheetPageProc,
LPARAM  lParam 
)

Definition at line 525 of file parallel.c.

528{
530 HPROPSHEETPAGE hPropSheetPage;
531 PPORT_DATA pPortData;
532
533 TRACE("ParallelPortPropPageProvider(%p %p %lx)\n",
534 lpPropSheetPageRequest, lpfnAddPropSheetPageProc, lParam);
535
536 pPortData = HeapAlloc(GetProcessHeap(),
538 sizeof(PORT_DATA));
539 if (pPortData == NULL)
540 {
541 ERR("Port data allocation failed!\n");
542 return FALSE;
543 }
544
545 pPortData->DeviceInfoSet = lpPropSheetPageRequest->DeviceInfoSet;
546 pPortData->DeviceInfoData = lpPropSheetPageRequest->DeviceInfoData;
547
548 if (lpPropSheetPageRequest->PageRequested == SPPSR_ENUM_ADV_DEVICE_PROPERTIES)
549 {
550 TRACE("SPPSR_ENUM_ADV_DEVICE_PROPERTIES\n");
551
552 PropSheetPage.dwSize = sizeof(PROPSHEETPAGEW);
553 PropSheetPage.dwFlags = 0;
554 PropSheetPage.hInstance = hInstance;
557 PropSheetPage.lParam = (LPARAM)pPortData;
558 PropSheetPage.pfnCallback = NULL;
559
560 hPropSheetPage = CreatePropertySheetPageW(&PropSheetPage);
561 if (hPropSheetPage == NULL)
562 {
563 ERR("CreatePropertySheetPageW() failed!\n");
564 return FALSE;
565 }
566
567 if (!(*lpfnAddPropSheetPageProc)(hPropSheetPage, lParam))
568 {
569 ERR("lpfnAddPropSheetPageProc() failed!\n");
570 DestroyPropertySheetPage(hPropSheetPage);
571 return FALSE;
572 }
573 }
574
575 TRACE("Done!\n");
576
577 return TRUE;
578}
HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage)
Definition: propsheet.c:3083
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3152
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static INT_PTR CALLBACK ParallelSettingsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: parallel.c:498
#define IDD_PARALLELSETTINGS
Definition: resource.h:12
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
struct _PROPSHEETPAGEW PROPSHEETPAGEW
#define SPPSR_ENUM_ADV_DEVICE_PROPERTIES
Definition: setupapi.h:615
PSP_DEVINFO_DATA DeviceInfoData
Definition: parallel.c:15
HDEVINFO DeviceInfoSet
Definition: parallel.c:14
PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1104
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKEINTRESOURCE
Definition: winuser.h:591

◆ ParallelSettingsDlgProc()

static INT_PTR CALLBACK ParallelSettingsDlgProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 498 of file parallel.c.

502{
503 TRACE("ParallelSettingsDlgProc()\n");
504
505 switch (uMsg)
506 {
507 case WM_INITDIALOG:
508 return OnInitDialog(hwnd, wParam, lParam);
509
510 case WM_NOTIFY:
512 break;
513
514 case WM_DESTROY:
516 break;
517 }
518
519 return FALSE;
520}
WPARAM wParam
Definition: combotst.c:138
static VOID OnDestroy(HWND hwnd)
Definition: parallel.c:476
static VOID OnNotify(HWND hwnd, WPARAM wParam, LPARAM lParam)
Definition: parallel.c:450
static BOOL OnInitDialog(HWND hwnd, WPARAM wParam, LPARAM lParam)
Definition: parallel.c:378
#define WM_NOTIFY
Definition: richedit.h:61
#define WM_INITDIALOG
Definition: winuser.h:1739
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by ParallelPortPropPageProvider().

◆ ReadPortSettings()

static VOID ReadPortSettings ( PPORT_DATA  pPortData)
static

Definition at line 90 of file parallel.c.

92{
94 HKEY hKey;
95 DWORD dwError;
96
97 TRACE("ReadPortSettings(%p)\n", pPortData);
98
99 pPortData->dwFilterResourceMethod = 1; /* Never use an interrupt */
100 pPortData->dwLegacy = 0; /* Disabled */
101 pPortData->dwPortNumber = 0; /* Unknown */
102
104 pPortData->DeviceInfoData,
106 0,
107 DIREG_DEV,
108 KEY_READ);
110 {
111 dwSize = sizeof(pPortData->szPortName);
112 dwError = RegQueryValueExW(hKey,
113 L"PortName",
114 NULL,
115 NULL,
116 (PBYTE)pPortData->szPortName,
117 &dwSize);
118 if (dwError != ERROR_SUCCESS)
119 {
120 ERR("RegQueryValueExW failed (Error %lu)\n", dwError);
121 }
122
123 dwSize = sizeof(pPortData->dwFilterResourceMethod);
124 dwError = RegQueryValueExW(hKey,
125 L"FilterResourceMethod",
126 NULL,
127 NULL,
128 (PBYTE)&pPortData->dwFilterResourceMethod,
129 &dwSize);
130 if (dwError != ERROR_SUCCESS)
131 {
132 ERR("RegQueryValueExW failed (Error %lu)\n", dwError);
133 }
134
136 }
137
139 L"SYSTEM\\CurrentControlSet\\Services\\Parport\\Parameters",
140 0,
141 KEY_READ,
142 &hKey);
143 if (dwError == ERROR_SUCCESS)
144 {
145 dwSize = sizeof(pPortData->dwLegacy);
146 dwError = RegQueryValueExW(hKey,
147 L"ParEnableLegacyZip",
148 NULL,
149 NULL,
150 (PBYTE)&pPortData->dwLegacy,
151 &dwSize);
152 if (dwError != ERROR_SUCCESS)
153 {
154 ERR("RegQueryValueExW failed (Error %lu)\n", dwError);
155 }
156
158 }
159}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by OnInitDialog().

◆ WritePortSettings()

static VOID WritePortSettings ( HWND  hwnd,
PPORT_DATA  pPortData 
)
static

Definition at line 247 of file parallel.c.

250{
251 SP_PROPCHANGE_PARAMS PropChangeParams;
252 DWORD dwDisposition;
253 DWORD dwFilterResourceMethod;
254 DWORD dwLegacy;
255 DWORD dwPortNumber;
256 DWORD dwPortMap;
257 HKEY hKey;
258 BOOL bChanged = FALSE;
259 DWORD dwError;
260
261 TRACE("WritePortSettings(%p)\n", pPortData);
262
263 dwFilterResourceMethod = 1;
265 dwFilterResourceMethod = 0;
267 dwFilterResourceMethod = 1;
269 dwFilterResourceMethod = 2;
270
271 if (dwFilterResourceMethod != pPortData->dwFilterResourceMethod)
272 {
274 pPortData->DeviceInfoData,
276 0,
277 DIREG_DEV,
278 KEY_WRITE);
280 {
281 dwError = RegSetValueExW(hKey,
282 L"FilterResourceMethod",
283 0,
284 REG_DWORD,
285 (PBYTE)&dwFilterResourceMethod,
286 sizeof(dwFilterResourceMethod));
288 if (dwError == ERROR_SUCCESS)
289 {
290 pPortData->dwFilterResourceMethod = dwFilterResourceMethod;
291 bChanged = TRUE;
292 }
293 }
294 }
295
296 dwLegacy = 0;
298 dwLegacy = 1;
299
300 if (dwLegacy != pPortData->dwLegacy)
301 {
303 L"SYSTEM\\CurrentControlSet\\Services\\Parport\\Parameters",
304 0,
305 NULL,
307 KEY_WRITE,
308 NULL,
309 &hKey,
310 &dwDisposition);
311 if (dwError == ERROR_SUCCESS)
312 {
313 dwError = RegSetValueExW(hKey,
314 L"ParEnableLegacyZip",
315 0,
316 REG_DWORD,
317 (LPBYTE)&dwLegacy,
318 sizeof(dwLegacy));
320
321 if (dwError == ERROR_SUCCESS)
322 {
323 pPortData->dwLegacy = dwLegacy;
324 bChanged = TRUE;
325 }
326 }
327 }
328
330 if (dwPortNumber != LB_ERR)
331 {
332 dwPortNumber++;
333 if (dwPortNumber != pPortData->dwPortNumber)
334 {
335 GetUsedPorts(&dwPortMap);
336
337 if (dwPortMap & 1 << dwPortNumber)
338 {
339 ERR("Port LPT%lu is already in use!\n", dwPortNumber);
340 }
341 else
342 {
343 ChangePortNumber(pPortData,
344 dwPortNumber);
345 bChanged = TRUE;
346 }
347 }
348 }
349
350 if (bChanged)
351 {
352 /* Notify the system */
355 0,
356 (LPARAM)pPortData->szPortName);
357
358 /* Notify the installer (and device) */
359 PropChangeParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
361 PropChangeParams.Scope = DICS_FLAG_GLOBAL;
362 PropChangeParams.StateChange = DICS_PROPCHANGE;
363
365 pPortData->DeviceInfoData,
366 (PSP_CLASSINSTALL_HEADER)&PropChangeParams,
367 sizeof(SP_PROPCHANGE_PARAMS));
368
370 pPortData->DeviceInfoSet,
371 pPortData->DeviceInfoData);
372 }
373}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
static DWORD ChangePortNumber(_In_ PPORT_DATA pPortData, _In_ DWORD dwNewPortNumber)
Definition: parallel.c:164
#define IDC_NEVER_INTERRUPT
Definition: resource.h:14
#define IDC_ANY_INTERRUPT
Definition: resource.h:15
BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION InstallFunction, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:4024
unsigned int BOOL
Definition: ntddk_ex.h:94
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define REG_DWORD
Definition: sdbapi.c:596
struct _SP_CLASSINSTALL_HEADER SP_CLASSINSTALL_HEADER
#define SetupDiSetClassInstallParams
Definition: setupapi.h:2617
#define DICS_PROPCHANGE
Definition: setupapi.h:116
#define DIF_PROPERTYCHANGE
Definition: setupapi.h:137
DI_FUNCTION InstallFunction
Definition: setupapi.h:904
SP_CLASSINSTALL_HEADER ClassInstallHeader
Definition: setupapi.h:916
#define ComboBox_GetCurSel(hwndCtl)
Definition: windowsx.h:49
#define Button_GetCheck(hwndCtl)
Definition: windowsx.h:31
#define LB_ERR
Definition: winuser.h:2432
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HWND_BROADCAST
Definition: winuser.h:1204
#define WM_WININICHANGE
Definition: winuser.h:1630

Referenced by OnNotify().