mrwilk


Our application needs to add the generic printer driver, and then add a printer that uses that driver. We have done this successfully on Windows 95/98/Me/2000/XP, but on Vista we can't get past the security. Our code looks (essentially) like this:

DRIVER_INFO_8 driverInfo;
ZeroMemory( &driverInfo, sizeof( driverInfo ) );
driverInfo.cVersion = 3;
driverInfo.pDriverPath = "UNIDRV.DLL";
driverInfo.pConfigFile = "UNIDRVUI.DLL";
driverInfo.pDataFile = "TTY.GPD";
driverInfo.pHelpFile = "UNIDRV.HLP";
driverInfo.pDependentFiles = "TTYRES.DLL\0TTY.INI\0TTY.DLL\0TTYUI.DLL\0TTYUI.HLP\0UNIRES.DLL\0STDNAMES.GPD\0STDDTYPE.GDL\0STDSCHEM.GDL\0STDSCHMX.GDL\0";
driverInfo.pEnvironment = "Windows NT x86";
driverInfo.pszMfgName = "Generic";
driverInfo.pszProvider = "Microsoft";
driverInfo.pszPrintProcessor = "winprint";
driverInfo.pName = "Generic / Text Only";
driverInfo.pDefaultDataType = "RAW";
BOOL result = AddPrinterDriver( NULL, 8, (LPBYTE) &driverInfo );
DWORD err = GetLastError();

We're not sure how many of these attributes are necessary, but the call also fails with a minimal definition. The "result" is always FALSE and the "err" is 5 (ERROR_ACCESS_DENIED). As administrators we appear to have SeLoadDriverPrivilege. All the required files exist in the default printer driver folder, as found using GetPrinterDriverDirectory().

Can anyone explain what we're doing wrong

Michael




databaseforum