Page 1 of 1

GetPrinters() fails

Posted: Wed Dec 14, 2011 6:17 pm
by StefanHaupt
Antonio,

I noticed, that the function GetPrinters() defined in xHarbour is not working anymore with fwh 1109. It returns an undefined value.

This small sample shows the error.

Code: Select all

#include "Fivewin.ch"

procedure Main ()

  LOCAL aPrn, cPrn

  aPrn := GetPrinters ()
  cPrn := GetDefaultPrinter ()

  ? Valtype (aPrn), Valtype (cPrn), cPrn

  RETURN
I found that these functions are replaced (?) in the file legacycp.c. But I don´t really understand, what happens in this file. I think, GetPrinters () is replaced with Win_PrinterList(), but this is one of the unresolved externals we had to define as dummy functions. What is this file for ?

Fact is, that it kills the functions GetPrinters() and GetDefaultPrinter() and others defined in xHarbour.

Antonio, could you please review this issue ? I´m using these function very often.

Re: GetPrinters() fails

Posted: Wed Dec 14, 2011 6:30 pm
by StefanHaupt
I just removed legacycp from the library and now it´s working fine again.

Is it ok to remove it or are there any side effects ?

Re: GetPrinters() fails

Posted: Wed Dec 14, 2011 7:08 pm
by wmormar
StefanHaupt,

Use aGetPrinters()

Rergards

Re: GetPrinters() fails

Posted: Thu Dec 15, 2011 8:04 am
by StefanHaupt
William,

yes, that would a possibility, but all other function, like GetPrinDefault(), PrinterExist(),... also don´t work.

And I don´t understand the reason of these replacements.

Re: GetPrinters() fails

Posted: Thu Dec 15, 2011 8:20 am
by wmormar
StefanHaupt,

this is xHarbour

PROCEDURE Main()
LOCAL cPrinter := GetDefaultPrinter()
? cPrinter
RETURN


PROCEDURE Main()
? PrinterExists( "HP LaserJet 1200 Series PCL" ) // result: .T.
? PrinterExists( "HP LASERJET 1200 SERIES PCL" ) // result: .F.
RETURN

Re: GetPrinters() fails

Posted: Thu Dec 15, 2011 9:07 am
by StefanHaupt
William,

GetDefaultPrinter fails here with fwh 11.09

Only if I remove legacycp.obj from fivehc.lib it is working again

Re: GetPrinters() fails

Posted: Thu Dec 15, 2011 10:45 am
by Antonio Linares
Stefan,

Please modify legacycp.c this way just leaving these functions:

HB_FUNC_EXTERN( WIN_PRINTEREXISTS ) ; HB_FUNC( PRINTEREXISTS ) { HB_FUNC_EXEC( WIN_PRINTEREXISTS ); }
HB_FUNC_EXTERN( WIN_PRINTERSTATUS ) ; HB_FUNC( XISPRINTER ) { HB_FUNC_EXEC( WIN_PRINTERSTATUS ); }
HB_FUNC_EXTERN( WIN_PRINTERPORTTONAME ) ; HB_FUNC( PRINTERPORTTONAME ) { HB_FUNC_EXEC( WIN_PRINTERPORTTONAME ); }
HB_FUNC_EXTERN( WIN_PRINTFILERAW ) ; HB_FUNC( PRINTFILERAW ) { HB_FUNC_EXEC( WIN_PRINTFILERAW ); }

thanks,

Re: GetPrinters() fails

Posted: Fri Dec 16, 2011 8:53 am
by StefanHaupt
Antonio,

ok, that solves the problem with GetPrinters() and GetdefaultPrinter(), but the other functions are still unavailable.

What was your intention, to replace these functions ?

Re: GetPrinters() fails

Posted: Fri Dec 16, 2011 10:58 am
by Antonio Linares
Stefan,

We had to use several files from Harbour to keep backwards compatibility with OLE support, but in fact we dont need the functions from that file so we are going to try to remove it entirely

Re: GetPrinters() fails

Posted: Fri Dec 16, 2011 11:14 am
by Otto
Hello Antonio,

I get the same error.
Best regards,
Otto

Error: Unresolved external '_HB_FUN_WIN_PRINTEREXISTS' referenced from C:\FWH\LIB\FIVEHC.LIB|LEGACYCP
Error: Unresolved external '_HB_FUN_WIN_PRINTERGETDEFAULT' referenced from C:\FWH\LIB\FIVEHC.LIB|LEGACYCP
Error: Unresolved external '_HB_FUN_WIN_PRINTERSTATUS' referenced from C:\FWH\LIB\FIVEHC.LIB|LEGACYCP
Error: Unresolved external '_HB_FUN_WIN_PRINTERPORTTONAME' referenced from C:\FWH\LIB\FIVEHC.LIB|LEGACYCP
Error: Unresolved external '_HB_FUN_WIN_PRINTFILERAW' referenced from C:\FWH\LIB\FIVEHC.LIB|LEGACYCP
Error: Unresolved external '_HB_FUN_WIN_PRINTERLIST' referenced from C:\FWH\LIB\FIVEHC.LIB|LEGACYCP
Error: Unresolved external '_HB_FUN_WIN_PRINTERSETDEFAULT' referenced from C:\FWH\LIB\FIVEHC.LIB|LEGACYCP

Re: GetPrinters() fails

Posted: Mon Dec 19, 2011 8:47 am
by StefanHaupt
Antonio Linares wrote: We had to use several files from Harbour to keep backwards compatibility with OLE support, but in fact we dont need the functions from that file so we are going to try to remove it entirely
Ok, thanks for your explanation. In the meantime I removed this obj from the lib and everything is working fine now :D

Re: GetPrinters() fails

Posted: Mon Dec 19, 2011 9:32 am
by Antonio Linares
Stefan,

Yes, thats a right solution, thanks :-)