mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[MSPORTS] Check and show which parallel port is in use.
This commit is contained in:
parent
bf59669065
commit
c444231b87
17 changed files with 118 additions and 5 deletions
|
@ -38,4 +38,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -38,4 +38,5 @@ BEGIN
|
||||||
IDS_PARITY "Gerade,Ungerade,Keine,Mark,Space"
|
IDS_PARITY "Gerade,Ungerade,Keine,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,Keine"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,Keine"
|
||||||
|
IDS_PORT_IN_USE " (wird benutzt)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -38,4 +38,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -38,4 +38,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -38,4 +38,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -38,4 +38,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -38,4 +38,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -46,4 +46,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -44,4 +44,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -44,4 +44,5 @@ BEGIN
|
||||||
IDS_PARITY "Чёт,Нечёт,Нет,Маркер,Пробел"
|
IDS_PARITY "Чёт,Нечёт,Нет,Маркер,Пробел"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Аппаратное,Нет"
|
IDS_FLOWCONTROL "Xon / Xoff,Аппаратное,Нет"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -42,4 +42,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -40,4 +40,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -46,4 +46,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -40,4 +40,5 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
|
@ -40,5 +40,6 @@ BEGIN
|
||||||
IDS_PARITY "Even,Odd,None,Mark,Space"
|
IDS_PARITY "Even,Odd,None,Mark,Space"
|
||||||
IDS_STOPBITS "1,1.5,2"
|
IDS_STOPBITS "1,1.5,2"
|
||||||
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
IDS_FLOWCONTROL "Xon / Xoff,Hardware,None"
|
||||||
|
IDS_PORT_IN_USE " (in use)"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
|
@ -8,18 +8,83 @@
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct _PORT_DATA
|
typedef struct _PORT_DATA
|
||||||
{
|
{
|
||||||
HDEVINFO DeviceInfoSet;
|
HDEVINFO DeviceInfoSet;
|
||||||
PSP_DEVINFO_DATA DeviceInfoData;
|
PSP_DEVINFO_DATA DeviceInfoData;
|
||||||
|
|
||||||
WCHAR szPortName[16];
|
WCHAR szPortName[16];
|
||||||
|
DWORD dwPortNumber;
|
||||||
DWORD dwFilterResourceMethod;
|
DWORD dwFilterResourceMethod;
|
||||||
DWORD dwLegacy;
|
DWORD dwLegacy;
|
||||||
|
|
||||||
} PORT_DATA, *PPORT_DATA;
|
} PORT_DATA, *PPORT_DATA;
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
GetUsedPorts(
|
||||||
|
PDWORD pPortMap)
|
||||||
|
{
|
||||||
|
WCHAR szDeviceName[64];
|
||||||
|
WCHAR szDosDeviceName[64];
|
||||||
|
DWORD dwIndex, dwType, dwPortNumber;
|
||||||
|
DWORD dwDeviceNameSize, dwDosDeviceNameSize;
|
||||||
|
PWSTR ptr;
|
||||||
|
HKEY hKey;
|
||||||
|
DWORD dwError;
|
||||||
|
|
||||||
|
*pPortMap = 0;
|
||||||
|
|
||||||
|
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
|
L"Hardware\\DeviceMap\\PARALLEL PORTS",
|
||||||
|
0,
|
||||||
|
KEY_READ,
|
||||||
|
&hKey);
|
||||||
|
if (dwError == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
for (dwIndex = 0; ; dwIndex++)
|
||||||
|
{
|
||||||
|
dwDeviceNameSize = ARRAYSIZE(szDeviceName);
|
||||||
|
dwDosDeviceNameSize = sizeof(szDosDeviceName);
|
||||||
|
dwError = RegEnumValueW(hKey,
|
||||||
|
dwIndex,
|
||||||
|
szDeviceName,
|
||||||
|
&dwDeviceNameSize,
|
||||||
|
NULL,
|
||||||
|
&dwType,
|
||||||
|
(LPBYTE)szDosDeviceName,
|
||||||
|
&dwDosDeviceNameSize);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (dwType == REG_SZ)
|
||||||
|
{
|
||||||
|
TRACE("%S --> %S\n", szDeviceName, szDosDeviceName);
|
||||||
|
if (_wcsnicmp(szDosDeviceName, L"\\DosDevices\\LPT", wcslen(L"\\DosDevices\\LPT")) == 0)
|
||||||
|
{
|
||||||
|
ptr = szDosDeviceName + wcslen(L"\\DosDevices\\LPT");
|
||||||
|
if (wcschr(ptr, L'.') == NULL)
|
||||||
|
{
|
||||||
|
TRACE("Device number %S\n", ptr);
|
||||||
|
dwPortNumber = wcstoul(ptr, NULL, 10);
|
||||||
|
if (dwPortNumber != 0)
|
||||||
|
{
|
||||||
|
*pPortMap |=(1 << dwPortNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("Done\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
ReadPortSettings(
|
ReadPortSettings(
|
||||||
|
@ -33,6 +98,7 @@ ReadPortSettings(
|
||||||
|
|
||||||
pPortData->dwFilterResourceMethod = 1; /* Never use an interrupt */
|
pPortData->dwFilterResourceMethod = 1; /* Never use an interrupt */
|
||||||
pPortData->dwLegacy = 0; /* Disabled */
|
pPortData->dwLegacy = 0; /* Disabled */
|
||||||
|
pPortData->dwPortNumber = 0; /* Unknown */
|
||||||
|
|
||||||
hKey = SetupDiOpenDevRegKey(pPortData->DeviceInfoSet,
|
hKey = SetupDiOpenDevRegKey(pPortData->DeviceInfoSet,
|
||||||
pPortData->DeviceInfoData,
|
pPortData->DeviceInfoData,
|
||||||
|
@ -102,6 +168,7 @@ WritePortSettings(
|
||||||
DWORD dwDisposition;
|
DWORD dwDisposition;
|
||||||
DWORD dwFilterResourceMethod;
|
DWORD dwFilterResourceMethod;
|
||||||
DWORD dwLegacy;
|
DWORD dwLegacy;
|
||||||
|
DWORD dwPortNumber;
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
|
|
||||||
|
@ -169,9 +236,24 @@ WritePortSettings(
|
||||||
if (dwError == ERROR_SUCCESS)
|
if (dwError == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
FIXME("Notify the driver!\n");
|
FIXME("Notify the driver!\n");
|
||||||
|
|
||||||
|
pPortData->dwLegacy = dwLegacy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dwPortNumber = ComboBox_GetCurSel(GetDlgItem(hwnd, IDC_PARALLEL_NAME));
|
||||||
|
if (dwPortNumber != LB_ERR)
|
||||||
|
{
|
||||||
|
dwPortNumber++;
|
||||||
|
if (dwPortNumber != pPortData->dwPortNumber)
|
||||||
|
{
|
||||||
|
FIXME("Port name changed! LPT%lu --> LPT%lu", pPortData->dwPortNumber, dwPortNumber);
|
||||||
|
|
||||||
|
|
||||||
|
// pPortData->dwPortNumber = dwPortNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,9 +263,11 @@ OnInitDialog(HWND hwnd,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
WCHAR szBuffer[256];
|
||||||
|
WCHAR szPortInUse[64];
|
||||||
PPORT_DATA pPortData;
|
PPORT_DATA pPortData;
|
||||||
HWND hwndControl;
|
HWND hwndControl;
|
||||||
WCHAR szBuffer[256];
|
DWORD dwPortMap;
|
||||||
UINT i;
|
UINT i;
|
||||||
|
|
||||||
TRACE("OnInitDialog()\n");
|
TRACE("OnInitDialog()\n");
|
||||||
|
@ -214,18 +298,31 @@ OnInitDialog(HWND hwnd,
|
||||||
pPortData->dwLegacy ? BST_CHECKED : BST_UNCHECKED);
|
pPortData->dwLegacy ? BST_CHECKED : BST_UNCHECKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoadStringW(hInstance, IDS_PORT_IN_USE, szPortInUse, ARRAYSIZE(szPortInUse));
|
||||||
|
|
||||||
/* Fill the 'LPT Port Number' combobox */
|
/* Fill the 'LPT Port Number' combobox */
|
||||||
hwndControl = GetDlgItem(hwnd, IDC_PARALLEL_NAME);
|
hwndControl = GetDlgItem(hwnd, IDC_PARALLEL_NAME);
|
||||||
if (hwndControl)
|
if (hwndControl)
|
||||||
{
|
{
|
||||||
for (i = 0; i < 3; i++)
|
GetUsedPorts(&dwPortMap);
|
||||||
|
|
||||||
|
for (i = 1; i < 4; i++)
|
||||||
{
|
{
|
||||||
swprintf(szBuffer, L"LPT%lu", i + 1);
|
swprintf(szBuffer, L"LPT%lu", i);
|
||||||
|
|
||||||
|
if ((dwPortMap & (1 << i)) && (pPortData->dwPortNumber != i))
|
||||||
|
wcscat(szBuffer, szPortInUse);
|
||||||
|
|
||||||
ComboBox_AddString(hwndControl, szBuffer);
|
ComboBox_AddString(hwndControl, szBuffer);
|
||||||
|
|
||||||
|
if (_wcsicmp(pPortData->szPortName, szBuffer) == 0)
|
||||||
|
pPortData->dwPortNumber = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable it */
|
if (pPortData->dwPortNumber != 0)
|
||||||
EnableWindow(hwndControl, FALSE);
|
{
|
||||||
|
ComboBox_SetCurSel(hwndControl, pPortData->dwPortNumber - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -20,3 +20,4 @@
|
||||||
#define IDS_PARITY 11
|
#define IDS_PARITY 11
|
||||||
#define IDS_STOPBITS 12
|
#define IDS_STOPBITS 12
|
||||||
#define IDS_FLOWCONTROL 13
|
#define IDS_FLOWCONTROL 13
|
||||||
|
#define IDS_PORT_IN_USE 61
|
||||||
|
|
Loading…
Reference in a new issue