Assigning ports at install
Assigning ports at install
Referring to the earlier post, 'Vista 64 PDF creation', is there a way to specify a printer port during installation, or after installation? Looking for a script or other mechanism which can handle this automatically.
Re: Assigning ports at install
You can assign the printer port during installation. When using Install.exe, you can use the "-o portname" command line option to do so. When using PDFDriverInit from the DLL or ActiveX interfaces, you can add the port after the printer name separated by a semi-colon: "myprinter;port".
In both cases, the port should exist before attempting to attach the printer to it. If the port does not exist, you can create it using the sample code below. The print spooler has to be restarted in order to detect the new port:
In both cases, the port should exist before attempting to attach the printer to it. If the port does not exist, you can create it using the sample code below. The print spooler has to be restarted in order to detect the new port:
Code: Select all
/////////////////////////////////////////////////////////////////////////////
DWORD AddNulPort()
/////////////////////////////////////////////////////////////////////////////
{
// add a NUL: port for 64-bit installations
//
//@reg ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Ports" /v %Port% /t REG_SZ /f
//
HKEY hSoftKey = NULL;
DWORD dw = 0;
StopSpooler();
// add the NUL: registry entry under Ports
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\Ports"),
0, KEY_WRITE, &hSoftKey) == ERROR_SUCCESS)
{
dw = RegSetValueEx(hSoftKey, _T("NUL:"), 0, REG_SZ, (CONST BYTE *)"", 0 );
RegCloseKey(hSoftKey);
}
StartSpooler();
return dw;
}
Amyuni Development Team
Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com
Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com