Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Print Driver Question

edited November 2001 in General
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

Comments

  • edited November 2001
    The only way I know of to find the driver name is to look up the printer and
    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

  • edited November 2001
    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

This discussion has been closed.