I'm trying to read printer port configuration using XcvData but it fails with error 87 (invalid parameter). I have no problem adding a port or setting port configuration. I've seen some c# code samples that do exactly what I do so I'm not sure what causes the failures. Any suggestions will be appreciated. Thanks.
Sample code:
PRINTER_DEFAULTS defaults = { NULL, NULL, SERVER_ACCESS_ADMINISTER };
HANDLE hPrinter;
if (::OpenPrinter(L", XcvMonitor Standard TCP/IP Port", hPrinter, &defaults))
{
CONFIG_INFO_DATA_1 configInfoData1;
memset(&configInfoData1, 0, sizeof(configInfoData1));
configInfoData1.dwVersion = 1;
PORT_DATA_1 portData1;
// this initialization does not seem to help
memset(&portData1, 0, sizeof(portData1));
portData1.cbSize = sizeof(portData1);
DWORD dwStatus = 0;
DWORD dwNeeded = 0;
// this always fails with dwStatus 87 (invalid parameter)
if (XcvData(hPrinter, L"GetConfigInfo", (PBYTE)&configInfoData1,
sizeof(configInfoData1), (PBYTE)&portData1, sizeof(portData1), &dwNeeded, &dwStatus))
{
if (dwStatus != 0)
{
[...]
// throw exception
}
_ASSERTE(dwNeeded > 0);
[...]
}
// this works fine
if (XcvData(hPrinter, L"ConfigPort", (PBYTE)&m_portData1, sizeof(m_portData1),
NULL, 0, &dwNeeded, &dwStatus))
{
[...]
}
[...]
}