网络提供的安装processor的说明,只要搜索关键字: Installing a Print Processor
在安装processor时,需要注意
首先,将具体的processor.dll拷贝到对应的processor目录
64位 为 C:/Windows/System32/spool/prtprocs/x64
32位 为 C:/Windows/System32/spool/prtprocs/x32
然后,修改INF文件,增加如下字节:
[Model]
%str% = MPDATA02,USBPRINT/....
[Model.NTx86]
%str% = MPDATA02,USBPRINT/....
[Model.NTamd64]
%str% = MPDATA02,USBPRINT/....
[MPDATA02.NTx86]
CopyFiles = DRIVER_FILES, PRTPROCS
DataSection = DATA_NT
DriverVer = 12/22/2010,5.1.2.0
[MPDATA02.NTamd64]
CopyFiles = DRIVER_FILES, PRTPROCS
DataSection = DATA_NT
DriverVer = 12/22/2010,5.1.2.0
[DATA_NT]
DriverFile = ....
DataFile =....
ConfigFile = .....
HelpFile =....
LanguageMonitor = MONITOR NAME, MONITOR.DLL
PrintProcessor = Processor name ,processor.dll
[PRTPROCS]
pt2000pro.dll
再然后,需要考虑的一个重要问题是打印机与processor的对应上,对应的函数如下:
BOOL
DrvPrinterEvent(
LPWSTR pPrinterName,
INT Event,
DWORD Flags,
LPARAM lParam
)
{
PRINTER_DEFAULTS PrinterDef = {NULL, NULL, PRINTER_ALL_ACCESS};
HANDLE hPrinter;
LPPRINTER_INFO_2 pInfo = NULL;
DWORD cbNeeded;
TCHAR gszPrintProc[] = TEXT("<Print processor name>");
BOOL bRet = TRUE;
switch (Event)
{
case PRINTER_EVENT_INITIALIZE:
if (OpenPrinter(pPrinterName, &hPrinter, &PrinterDef))
{
if ( !GetPrinter( hPrinter, 2, (LPBYTE) pInfo, 0, &cbNeeded ) &&
(GetLastError() != ERROR_INSUFFICIENT_BUFFER) )
{
bRet = FALSE;
}
if (bRet == TRUE)
{
pInfo = (LPPRINTER_INFO_2) LocalAlloc(LPTR, cbNeeded);
bRet = pInfo ? TRUE : FALSE;
}
if (bRet == TRUE)
{
if (GetPrinter(hPrinter, 2, (LPBYTE) pInfo, cbNeeded, &cbNeeded))
{
pInfo->pPrintProcessor = gszPrintProc;
SetPrinter(hPrinter, 2, (LPBYTE) pInfo, 0);
}
else
{
bRet = FALSE;
}
if (pInfo)
{
LocalFree(pInfo);
}
}
ClosePrinter(hPrinter);
}
else // OpenPrinter failed
{
bRet = FALSE;
}
break;
// cases for other events
default:
break;
} // end switch
return bRet;
}
BOOL
DrvUpgradePrinter(
DWORD Level,
LPBYTE pDriverUpgradeInfo
)
{
HANDLE hPrinter;
PRINTER_DEFAULTS PrinterDef = {NULL, NULL, PRINTER_ALL_ACCESS};
PDRIVER_UPGRADE_INFO_2 pDUI2;
LPPRINTER_INFO_2 pInfo = NULL;
DWORD cbNeeded;
TCHAR gszPrintProc[] = TEXT("<Print processor name>");
TCHAR gszPrintDriver[] = TEXT("<Printer driver name>");
BOOL bRet = TRUE;
if ((Level == 2) &&
(pDUI2 = (PDRIVER_UPGRADE_INFO_2)pDriverUpgradeInfo) &&
(OpenPrinter(pDUI2->pPrinterName, &hPrinter, &PrinterDef)))
{
if ( !GetPrinter( hPrinter, 2, (LPBYTE) pInfo, 0, &cbNeeded ) &&
(GetLastError() != ERROR_INSUFFICIENT_BUFFER) )
{
bRet = FALSE;
}
if (bRet == TRUE)
{
pInfo = (LPPRINTER_INFO_2) LocalAlloc(LPTR, cbNeeded);
bRet = pInfo ? TRUE : FALSE;
}
if (bRet == TRUE)
{
if (GetPrinter(hPrinter, 2, (LPBYTE) pInfo, cbNeeded, &cbNeeded))
{
//
// This function is called for every printer queue that uses a driver
// for which one or more files were updated. However, we only want to
// update the printer queue's "driver" by a particular driver.
//
if ( !lstrcmpi(pInfo->pDriverName, gszPrintDriver) )
{
pInfo->pPrintProcessor = gszPrintProc;
SetPrinter(hPrinter, 2, (LPBYTE) pInfo, 0);
}
else // GetPrinter
{
bRet = FALSE;
}
if (pInfo)
{
LocalFree(pInfo);
}
ClosePrinter(hPrinter);
}
else // Level != 2 or pDUI2 == NULL or OpenPrinter failed
{
bRet = FALSE;
}
return bRet;
}
对应成功后,就可以完成安装了。
另外,需要特别注意的问题是:在使用setup.exe程序进行安装时:
首先,将processor。dll 拷贝到对应的目录当中;
然后使用addprintprocessor函数,进行安装。使用时需要特别注意的是第三个参数,不是全路径,而只是processor.dll 就可以了。