Assigning ports at install

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
TDWiseley
Posts: 18
Joined: Wed Jul 18 2007

Assigning ports at install

Post by TDWiseley »

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.
Devteam
Posts: 119
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: Assigning ports at install

Post by Devteam »

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:

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
Post Reply