Print Driver Question
Hi,
I need to integrate some legacy non-RB (Crystal) reports in with my
application and am using the ppPrinter object in ppPrintr to handle the
setup dialogs for me to select the printer for the legacy reports. My
problem is that the PrinterInfo structure does not seem to contain the
driver name. I need the printer name, port, device context, and driver
name to set the printer and it contains all of these but the driver
name. The source code to ppPrinter seems to always set the driver to
'None' or nil. Any idea where I can get the driver name or how I can
modify the code to make sure the driver name is set?
Thanks,
Sean
I need to integrate some legacy non-RB (Crystal) reports in with my
application and am using the ppPrinter object in ppPrintr to handle the
setup dialogs for me to select the printer for the legacy reports. My
problem is that the PrinterInfo structure does not seem to contain the
driver name. I need the printer name, port, device context, and driver
name to set the printer and it contains all of these but the driver
name. The source code to ppPrinter seems to always set the driver to
'None' or nil. Any idea where I can get the driver name or how I can
modify the code to make sure the driver name is set?
Thanks,
Sean
This discussion has been closed.
Comments
driver in the win.ini file in the windows directory. The win.ini file can
be handled using .ini file routines. Assuming you're trying to find
thedriver name for a printer installed on your system, this should work.
You can look in the win.ini file outside of Delphi to see what it looks
like.
// get win.ini file in order to read in driver names
var
PrinterName: String;
WinIni : TIniFile;
WinIniFileName : array[0..MAX_PATH] of char;
DriverName : String;
begin
GetWindowsDirectory(WinIniFileName, sizeof(WinIniFileName));
StrCat(WinIniFileName, '\win.ini');
WinIni := TIniFile.Create(WinIniFileName);
DriverName := WinIni.ReadString('Devices', PrinterName, '');
DriverName := Copy(DriverName, 1, Pos(',', DriverName)-1);
WinIni.Free;
end;
--
-Phil
Thanks for the help, but it seems like there should be a more direct way
to get this information that doesn't rely on Win.Ini. The print dialog
function returns this information in the DevMode structure, but I can't
seem to find another way to get it without bringing up the dialog. For
the time being I have been able to substitute "WINSPOOL" as the driver
and it works fine on 95/98. Delphi & RB both pass a nil pointer as the
driver and I am wondering if the Crystal Engine just hasn't been updated
to accept a nil pointer. I'll see if I can find a Crystal newsgroup to
ask about this.
Sean